Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/base/nsISupportsImpl.cpp
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "nsISupportsImpl.h"
8
#include "mozilla/Assertions.h"
9
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
10
#include "nsThreadUtils.h"
11
#endif // MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
12
13
using namespace mozilla;
14
15
nsresult NS_FASTCALL
16
NS_TableDrivenQI(void* aThis, REFNSIID aIID, void** aInstancePtr,
17
                 const QITableEntry* aEntries)
18
20.8M
{
19
79.7M
  do {
20
79.7M
    if (aIID.Equals(*aEntries->iid)) {
21
9.57M
      nsISupports* r = reinterpret_cast<nsISupports*>(
22
9.57M
        reinterpret_cast<char*>(aThis) + aEntries->offset);
23
9.57M
      NS_ADDREF(r);
24
9.57M
      *aInstancePtr = r;
25
9.57M
      return NS_OK;
26
9.57M
    }
27
70.2M
28
70.2M
    ++aEntries;
29
70.2M
  } while (aEntries->iid);
30
20.8M
31
20.8M
  *aInstancePtr = nullptr;
32
11.3M
  return NS_ERROR_NO_INTERFACE;
33
20.8M
}
34
35
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
36
nsAutoOwningThread::nsAutoOwningThread()
37
  : mThread(GetCurrentVirtualThread())
38
{
39
}
40
41
void
42
nsAutoOwningThread::AssertCurrentThreadOwnsMe(const char* msg) const
43
{
44
  if (MOZ_UNLIKELY(!IsCurrentThread())) {
45
    // `msg` is a string literal by construction.
46
    MOZ_CRASH_UNSAFE_OOL(msg);
47
  }
48
}
49
50
bool
51
nsAutoOwningThread::IsCurrentThread() const
52
{
53
  return mThread == GetCurrentVirtualThread();
54
}
55
#endif