2009-03-25 13:31:36 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-03-25 13:31:36 -07:00
|
|
|
|
|
|
|
#include "prtypes.h"
|
2011-10-27 02:11:34 -07:00
|
|
|
|
2009-03-25 13:31:36 -07:00
|
|
|
// Call a method on each observer in a category cache, then call the same
|
|
|
|
// method on the observer array.
|
2010-01-16 03:38:04 -08:00
|
|
|
#define NOTIFY_OBSERVERS(canFire, cache, array, type, method) \
|
2009-03-25 13:31:36 -07:00
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
if (canFire) { \
|
|
|
|
const nsCOMArray<type> &entries = cache.GetEntries(); \
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t idx = 0; idx < entries.Count(); ++idx) \
|
2009-03-25 13:31:36 -07:00
|
|
|
entries[idx]->method; \
|
|
|
|
ENUMERATE_WEAKARRAY(array, type, method) \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO;
|
2009-12-01 05:00:45 -08:00
|
|
|
|
|
|
|
#define PLACES_FACTORY_SINGLETON_IMPLEMENTATION(_className, _sInstance) \
|
2012-07-30 07:20:58 -07:00
|
|
|
_className * _className::_sInstance = nullptr; \
|
2009-12-01 05:00:45 -08:00
|
|
|
\
|
|
|
|
_className * \
|
|
|
|
_className::GetSingleton() \
|
|
|
|
{ \
|
|
|
|
if (_sInstance) { \
|
|
|
|
NS_ADDREF(_sInstance); \
|
|
|
|
return _sInstance; \
|
|
|
|
} \
|
|
|
|
_sInstance = new _className(); \
|
|
|
|
if (_sInstance) { \
|
|
|
|
NS_ADDREF(_sInstance); \
|
2011-10-27 02:11:34 -07:00
|
|
|
if (NS_FAILED(_sInstance->Init())) { \
|
2009-12-01 05:00:45 -08:00
|
|
|
NS_RELEASE(_sInstance); \
|
2012-07-30 07:20:58 -07:00
|
|
|
_sInstance = nullptr; \
|
2011-10-27 02:11:34 -07:00
|
|
|
} \
|
2009-12-01 05:00:45 -08:00
|
|
|
} \
|
|
|
|
return _sInstance; \
|
2011-10-27 02:11:34 -07:00
|
|
|
}
|
2012-02-17 22:40:10 -08:00
|
|
|
|
|
|
|
#if !defined(MOZ_PER_WINDOW_PRIVATE_BROWSING) || !defined(DEBUG)
|
|
|
|
# define ENSURE_NOT_PRIVATE_BROWSING /* nothing */
|
|
|
|
#else
|
2012-11-17 07:53:27 -08:00
|
|
|
# define ENSURE_NOT_PRIVATE_BROWSING EnsureNotGlobalPrivateBrowsing()
|
2012-02-17 22:40:10 -08:00
|
|
|
#endif
|