Bug 1601379 - part1 : allow inherited class to override 'Close()'. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 10 Dec 2019 18:26:29 +0000
changeset 2527048 4c431d395fc016b8053ee7be06b548819cb183c6
parent 2526795 f5d38101ac7c0bb452a09a08226f65d9e5d29f8c
child 2527049 abc3d9aeb765ce2426ca451ee6dc5bf1ccd02391
push id463252
push userreviewbot
push dateTue, 10 Dec 2019 18:27:09 +0000
treeherdertry@710b93e37772 [default view] [failures only]
bugs1601379
milestone73.0a1
Bug 1601379 - part1 : allow inherited class to override 'Close()'. Differential Diff: PHID-DIFF-ml4lfocmodboifma36zj
dom/media/mediacontrol/MediaControlKeysEvent.h
widget/cocoa/MediaHardwareKeysEventSourceMac.h
widget/cocoa/MediaHardwareKeysEventSourceMac.mm
--- a/dom/media/mediacontrol/MediaControlKeysEvent.h
+++ b/dom/media/mediacontrol/MediaControlKeysEvent.h
@@ -52,17 +52,17 @@ class MediaControlKeysEventSource : publ
  public:
   NS_DECL_ISUPPORTS
 
   MediaControlKeysEventSource() = default;
 
   virtual void AddListener(MediaControlKeysEventListener* aListener);
   virtual void RemoveListener(MediaControlKeysEventListener* aListener);
   size_t GetListenersNum() const;
-  void Close();
+  virtual void Close();
 
  protected:
   virtual ~MediaControlKeysEventSource() = default;
   nsTArray<RefPtr<MediaControlKeysEventListener>> mListeners;
 };
 
 }  // namespace dom
 }  // namespace mozilla
--- a/widget/cocoa/MediaHardwareKeysEventSourceMac.h
+++ b/widget/cocoa/MediaHardwareKeysEventSourceMac.h
@@ -13,22 +13,25 @@
 
 namespace mozilla {
 namespace widget {
 
 class MediaHardwareKeysEventSourceMac final
     : public mozilla::dom::MediaControlKeysEventSource {
  public:
   MediaHardwareKeysEventSourceMac();
-  ~MediaHardwareKeysEventSourceMac();
 
   static CGEventRef EventTapCallback(CGEventTapProxy proxy, CGEventType type,
                                      CGEventRef event, void* refcon);
 
+  void Close() override;
+
  private:
+  ~MediaHardwareKeysEventSourceMac() = default;
+
   void StartEventTap();
   void StopEventTap();
 
   // They are used to intercept mac hardware media keys.
   CFMachPortRef mEventTap = nullptr;
   CFRunLoopSourceRef mEventTapSource = nullptr;
 };
 
--- a/widget/cocoa/MediaHardwareKeysEventSourceMac.mm
+++ b/widget/cocoa/MediaHardwareKeysEventSourceMac.mm
@@ -65,19 +65,20 @@ static MediaControlKeysEvent ToMediaCont
 namespace mozilla {
 namespace widget {
 
 MediaHardwareKeysEventSourceMac::MediaHardwareKeysEventSourceMac() {
   LOG("Create MediaHardwareKeysEventSourceMac");
   StartEventTap();
 }
 
-MediaHardwareKeysEventSourceMac::~MediaHardwareKeysEventSourceMac() {
-  LOG("Destroy MediaHardwareKeysEventSourceMac");
+void MediaHardwareKeysEventSourceMac::Close() {
+  LOG("Close MediaHardwareKeysEventSourceMac");
   StopEventTap();
+  MediaControlKeysEventSource::Close();
 }
 
 void MediaHardwareKeysEventSourceMac::StartEventTap() {
   LOG("StartEventTap");
   MOZ_ASSERT(!mEventTap);
   MOZ_ASSERT(!mEventTapSource);
 
   // Add an event tap to intercept the system defined media key events.