nsWindowDataSource.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  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. #include "nsIRDFDataSource.h"
  6. #include "nsIWindowMediatorListener.h"
  7. #include "nsIWindowDataSource.h"
  8. #include "nsIObserver.h"
  9. #include "nsHashKeys.h"
  10. #include "nsIRDFService.h"
  11. #include "nsIRDFContainer.h"
  12. #include "nsInterfaceHashtable.h"
  13. #include "nsCycleCollectionParticipant.h"
  14. // {C744CA3D-840B-460a-8D70-7CE63C51C958}
  15. #define NS_WINDOWDATASOURCE_CID \
  16. { 0xc744ca3d, 0x840b, 0x460a, \
  17. { 0x8d, 0x70, 0x7c, 0xe6, 0x3c, 0x51, 0xc9, 0x58 } }
  18. class nsWindowDataSource final : public nsIRDFDataSource,
  19. public nsIObserver,
  20. public nsIWindowMediatorListener,
  21. public nsIWindowDataSource
  22. {
  23. public:
  24. nsWindowDataSource() { }
  25. nsresult Init();
  26. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  27. NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWindowDataSource,
  28. nsIRDFDataSource)
  29. NS_DECL_NSIOBSERVER
  30. NS_DECL_NSIWINDOWMEDIATORLISTENER
  31. NS_DECL_NSIWINDOWDATASOURCE
  32. NS_DECL_NSIRDFDATASOURCE
  33. protected:
  34. virtual ~nsWindowDataSource();
  35. private:
  36. // mapping of window -> RDF resource
  37. nsInterfaceHashtable<nsPtrHashKey<nsIXULWindow>, nsIRDFResource> mWindowResources;
  38. static uint32_t windowCount;
  39. static uint32_t gRefCnt;
  40. nsCOMPtr<nsIRDFDataSource> mInner;
  41. nsCOMPtr<nsIRDFContainer> mContainer;
  42. static nsIRDFResource* kNC_Name;
  43. static nsIRDFResource* kNC_KeyIndex;
  44. static nsIRDFResource* kNC_WindowRoot;
  45. static nsIRDFService* gRDFService;
  46. };