Source code

Revision control

Other Tools

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
// Call a method on each observer in a category cache, then call the same
10
// method on the observer array.
11
#define NOTIFY_OBSERVERS(canFire, array, type, method) \
12
PR_BEGIN_MACRO \
13
if (canFire) { \
14
ENUMERATE_WEAKARRAY(array, type, method) \
15
} \
16
PR_END_MACRO;
17
18
#define NOTIFY_BOOKMARKS_OBSERVERS(canFire, array, skipIf, method) \
19
PR_BEGIN_MACRO \
20
if (canFire) { \
21
for (uint32_t idx = 0; idx < array.Length(); ++idx) { \
22
const nsCOMPtr<nsINavBookmarkObserver>& e = \
23
array.ElementAt(idx).GetValue(); \
24
if (e) { \
25
if (skipIf(e)) continue; \
26
e->method; \
27
} \
28
} \
29
} \
30
PR_END_MACRO;
31
32
#define PLACES_FACTORY_SINGLETON_IMPLEMENTATION(_className, _sInstance) \
33
_className* _className::_sInstance = nullptr; \
34
\
35
already_AddRefed<_className> _className::GetSingleton() { \
36
if (_sInstance) { \
37
RefPtr<_className> ret = _sInstance; \
38
return ret.forget(); \
39
} \
40
_sInstance = new _className(); \
41
RefPtr<_className> ret = _sInstance; \
42
if (NS_FAILED(_sInstance->Init())) { \
43
/* Null out ret before _sInstance so the destructor doesn't assert */ \
44
ret = nullptr; \
45
_sInstance = nullptr; \
46
return nullptr; \
47
} \
48
return ret.forget(); \
49
}