Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/toolkit/components/places/nsPlacesMacros.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsIConsoleService.h"
7
#include "nsIScriptError.h"
8
9
#ifndef __FUNCTION__
10
#define __FUNCTION__ __func__
11
#endif
12
13
// Call a method on each observer in a category cache, then call the same
14
// method on the observer array.
15
#define NOTIFY_OBSERVERS(canFire, array, type, method)                         \
16
0
  PR_BEGIN_MACRO                                                               \
17
0
  if (canFire) {                                                               \
18
0
    ENUMERATE_WEAKARRAY(array, type, method)                                   \
19
0
  }                                                                            \
20
0
  PR_END_MACRO;
21
22
#define NOTIFY_BOOKMARKS_OBSERVERS(canFire, array, skipIf, method)             \
23
0
  PR_BEGIN_MACRO                                                               \
24
0
  if (canFire) {                                                               \
25
0
    for (uint32_t idx = 0; idx < array.Length(); ++idx) {                      \
26
0
      const nsCOMPtr<nsINavBookmarkObserver> &e = array.ElementAt(idx).GetValue(); \
27
0
      if (e) {                                                                 \
28
0
        if (skipIf(e))                                                         \
29
0
            continue;                                                          \
30
0
        e->method;                                                             \
31
0
      }                                                                        \
32
0
    }                                                                          \
33
0
  }                                                                            \
34
0
  PR_END_MACRO;
35
36
#define PLACES_FACTORY_SINGLETON_IMPLEMENTATION(_className, _sInstance)        \
37
  _className * _className::_sInstance = nullptr;                                \
38
                                                                               \
39
  already_AddRefed<_className>                                                 \
40
  _className::GetSingleton()                                                   \
41
0
  {                                                                            \
42
0
    if (_sInstance) {                                                          \
43
0
      RefPtr<_className> ret = _sInstance;                                   \
44
0
      return ret.forget();                                                     \
45
0
    }                                                                          \
46
0
    _sInstance = new _className();                                             \
47
0
    RefPtr<_className> ret = _sInstance;                                     \
48
0
    if (NS_FAILED(_sInstance->Init())) {                                       \
49
0
      /* Null out ret before _sInstance so the destructor doesn't assert */    \
50
0
      ret = nullptr;                                                           \
51
0
      _sInstance = nullptr;                                                    \
52
0
      return nullptr;                                                          \
53
0
    }                                                                          \
54
0
    return ret.forget();                                                       \
55
0
  }
Unexecuted instantiation: mozilla::places::Database::GetSingleton()
Unexecuted instantiation: nsAnnotationService::GetSingleton()
Unexecuted instantiation: nsFaviconService::GetSingleton()
Unexecuted instantiation: nsNavBookmarks::GetSingleton()
Unexecuted instantiation: nsNavHistory::GetSingleton()
56
57
#define PLACES_WARN_DEPRECATED()                                               \
58
  PR_BEGIN_MACRO                                                               \
59
  nsCString msg(__FUNCTION__);                                                 \
60
  msg.AppendLiteral(" is deprecated and will be removed in the next version.");\
61
  NS_WARNING(msg.get());                                                       \
62
  nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);\
63
  if (cs) {                                                                    \
64
    nsCOMPtr<nsIScriptError> e = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); \
65
    if (e && NS_SUCCEEDED(e->Init(NS_ConvertUTF8toUTF16(msg), EmptyString(),   \
66
                                  EmptyString(), 0, 0,                         \
67
                                  nsIScriptError::errorFlag, "Places"))) {     \
68
      cs->LogMessage(e);                                                       \
69
    }                                                                          \
70
  }                                                                            \
71
  PR_END_MACRO