1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/ds/nsObserverService.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsObserverService_h___ 1.10 +#define nsObserverService_h___ 1.11 + 1.12 +#include "nsIObserverService.h" 1.13 +#include "nsObserverList.h" 1.14 +#include "nsIMemoryReporter.h" 1.15 +#include "nsTHashtable.h" 1.16 +#include "mozilla/Attributes.h" 1.17 + 1.18 +// {D07F5195-E3D1-11d2-8ACD-00105A1B8860} 1.19 +#define NS_OBSERVERSERVICE_CID \ 1.20 + { 0xd07f5195, 0xe3d1, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } } 1.21 + 1.22 +class nsIMemoryReporter; 1.23 + 1.24 +class nsObserverService MOZ_FINAL 1.25 + : public nsIObserverService 1.26 + , public nsIMemoryReporter 1.27 +{ 1.28 +public: 1.29 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_OBSERVERSERVICE_CID) 1.30 + 1.31 + nsObserverService(); 1.32 + 1.33 + NS_DECL_ISUPPORTS 1.34 + NS_DECL_NSIOBSERVERSERVICE 1.35 + NS_DECL_NSIMEMORYREPORTER 1.36 + 1.37 + void Shutdown(); 1.38 + 1.39 + static nsresult 1.40 + Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); 1.41 + 1.42 + // Unmark any strongly held observers implemented in JS so the cycle 1.43 + // collector will not traverse them. 1.44 + NS_IMETHOD UnmarkGrayStrongObservers(); 1.45 + 1.46 +private: 1.47 + ~nsObserverService(void); 1.48 + void RegisterReporter(); 1.49 + 1.50 + static const size_t kSuspectReferentCount = 100; 1.51 + static PLDHashOperator CountReferents(nsObserverList* aObserverList, 1.52 + void* aClosure); 1.53 + bool mShuttingDown; 1.54 + nsTHashtable<nsObserverList> mObserverTopicTable; 1.55 +}; 1.56 + 1.57 +NS_DEFINE_STATIC_IID_ACCESSOR(nsObserverService, NS_OBSERVERSERVICE_CID) 1.58 + 1.59 +#endif /* nsObserverService_h___ */