1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_PlacesObservers__ 8 #define mozilla_dom_PlacesObservers__ 9 10 #include "mozilla/AlreadyAddRefed.h" 11 #include "mozilla/dom/BindingDeclarations.h" 12 #include "mozilla/dom/PlacesObserversBinding.h" 13 #include "mozilla/dom/PlacesEvent.h" 14 #include "mozilla/ErrorResult.h" 15 #include "mozilla/places/INativePlacesEventCallback.h" 16 #include "nsIWeakReferenceUtils.h" 17 18 namespace mozilla { 19 20 namespace dom { 21 22 class PlacesObservers { 23 public: 24 static void AddListener(GlobalObject& aGlobal, 25 const nsTArray<PlacesEventType>& aEventTypes, 26 PlacesEventCallback& aCallback, ErrorResult& rv); 27 static void AddListener(GlobalObject& aGlobal, 28 const nsTArray<PlacesEventType>& aEventTypes, 29 PlacesWeakCallbackWrapper& aCallback, 30 ErrorResult& rv); 31 static void AddListener(const nsTArray<PlacesEventType>& aEventTypes, 32 places::INativePlacesEventCallback* aCallback); 33 static void RemoveListener(GlobalObject& aGlobal, 34 const nsTArray<PlacesEventType>& aEventTypes, 35 PlacesEventCallback& aCallback, ErrorResult& rv); 36 static void RemoveListener(GlobalObject& aGlobal, 37 const nsTArray<PlacesEventType>& aEventTypes, 38 PlacesWeakCallbackWrapper& aCallback, 39 ErrorResult& rv); 40 static void RemoveListener(const nsTArray<PlacesEventType>& aEventTypes, 41 places::INativePlacesEventCallback* aCallback); 42 43 MOZ_CAN_RUN_SCRIPT 44 static void NotifyListeners( 45 GlobalObject& aGlobal, 46 const Sequence<OwningNonNull<PlacesEvent>>& aEvents, ErrorResult& rv); 47 48 MOZ_CAN_RUN_SCRIPT 49 static void NotifyListeners( 50 const Sequence<OwningNonNull<PlacesEvent>>& aEvents); 51 52 private: 53 static void RemoveListener(uint32_t aFlags, PlacesEventCallback& aCallback); 54 static void RemoveListener(uint32_t aFlags, 55 PlacesWeakCallbackWrapper& aCallback); 56 static void RemoveListener(uint32_t aFlags, 57 places::INativePlacesEventCallback* aCallback); 58 }; 59 60 } // namespace dom 61 } // namespace mozilla 62 63 #endif // mozilla_dom_PlacesObservers__ 64