2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsObserverService_h___
|
|
|
|
#define nsObserverService_h___
|
|
|
|
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsObserverList.h"
|
2013-11-06 21:35:30 -08:00
|
|
|
#include "nsIMemoryReporter.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsTHashtable.h"
|
2012-06-05 16:51:58 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// {D07F5195-E3D1-11d2-8ACD-00105A1B8860}
|
|
|
|
#define NS_OBSERVERSERVICE_CID \
|
|
|
|
{ 0xd07f5195, 0xe3d1, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
|
|
|
|
|
2013-08-27 16:24:51 -07:00
|
|
|
class nsIMemoryReporter;
|
2013-08-26 11:56:23 -07:00
|
|
|
|
2013-11-06 21:35:30 -08:00
|
|
|
class nsObserverService MOZ_FINAL
|
2013-12-07 21:39:47 -08:00
|
|
|
: public nsIObserverService
|
|
|
|
, public nsIMemoryReporter
|
2013-11-06 21:35:30 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_OBSERVERSERVICE_CID)
|
|
|
|
|
|
|
|
nsObserverService();
|
|
|
|
|
2014-04-14 12:04:26 -07:00
|
|
|
NS_DECL_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIOBSERVERSERVICE
|
2013-12-07 21:39:47 -08:00
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void Shutdown();
|
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
static nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
|
|
|
|
2012-04-30 12:01:11 -07:00
|
|
|
// Unmark any strongly held observers implemented in JS so the cycle
|
|
|
|
// collector will not traverse them.
|
|
|
|
NS_IMETHOD UnmarkGrayStrongObservers();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
~nsObserverService(void);
|
2013-08-26 11:56:23 -07:00
|
|
|
void RegisterReporter();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-11-06 21:35:30 -08:00
|
|
|
static const size_t kSuspectReferentCount = 100;
|
|
|
|
static PLDHashOperator CountReferents(nsObserverList* aObserverList,
|
|
|
|
void* aClosure);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShuttingDown;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTHashtable<nsObserverList> mObserverTopicTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsObserverService, NS_OBSERVERSERVICE_CID)
|
|
|
|
|
|
|
|
#endif /* nsObserverService_h___ */
|