Move Notifications APIs from DOMWindow.idl to DOMWindowNotifications.idl (Part 3)
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 22:35:53 +0000 (22:35 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 22:35:53 +0000 (22:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82027

Reviewed by Kentaro Hara.

Rather than watching for willDetachPage, NotificationCenter can just
override ActiveDOMObject::stop directly to be notified when it needs to
stop.

Switching NotificationCenter over to using ActiveDOMObject callbacks
frees DOMWindowNotification to implement reconnectFrame.  However, this
is only really a victory in princple because NotificationCenter always
returns false for canSuspend(), which means we'll never actually use
the reconnectFrame functionality.  However, this patch does move us
closer to the time when NotificationCenter can implement
ActiveDOMObject::suspend/resume to play nice with the PageCache.

* notifications/DOMWindowNotifications.cpp:
(WebCore::DOMWindowNotifications::disconnectFrame):
(WebCore::DOMWindowNotifications::reconnectFrame):
* notifications/DOMWindowNotifications.h:
(DOMWindowNotifications):
* notifications/NotificationCenter.cpp:
(WebCore::NotificationCenter::NotificationCenter):
(WebCore::NotificationCenter::stop):
* notifications/NotificationCenter.h:
(NotificationCenter):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111920 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/notifications/DOMWindowNotifications.cpp
Source/WebCore/notifications/DOMWindowNotifications.h
Source/WebCore/notifications/NotificationCenter.cpp
Source/WebCore/notifications/NotificationCenter.h

index 3e2ab78c4482fac5c04ac5abd0b79e1087e57b70..219511ff62c63a2d56dc9573691cbdb17af5a862 100644 (file)
@@ -1,3 +1,33 @@
+2012-03-23  Adam Barth  <abarth@webkit.org>
+
+        Move Notifications APIs from DOMWindow.idl to DOMWindowNotifications.idl (Part 3)
+        https://bugs.webkit.org/show_bug.cgi?id=82027
+
+        Reviewed by Kentaro Hara.
+
+        Rather than watching for willDetachPage, NotificationCenter can just
+        override ActiveDOMObject::stop directly to be notified when it needs to
+        stop.
+
+        Switching NotificationCenter over to using ActiveDOMObject callbacks
+        frees DOMWindowNotification to implement reconnectFrame.  However, this
+        is only really a victory in princple because NotificationCenter always
+        returns false for canSuspend(), which means we'll never actually use
+        the reconnectFrame functionality.  However, this patch does move us
+        closer to the time when NotificationCenter can implement
+        ActiveDOMObject::suspend/resume to play nice with the PageCache.
+
+        * notifications/DOMWindowNotifications.cpp:
+        (WebCore::DOMWindowNotifications::disconnectFrame):
+        (WebCore::DOMWindowNotifications::reconnectFrame):
+        * notifications/DOMWindowNotifications.h:
+        (DOMWindowNotifications):
+        * notifications/NotificationCenter.cpp:
+        (WebCore::NotificationCenter::NotificationCenter):
+        (WebCore::NotificationCenter::stop):
+        * notifications/NotificationCenter.h:
+        (NotificationCenter):
+
 2012-03-23  Daniel Cheng  <dcheng@chromium.org>
 
         [chromium] Support file drag out using DataTransferItemList::add(File)
index 2b4429aadb0e7b299c3b053c95c2c8c4957c1beb..86ca028aceae70873dab0a887401e3dfd52308ab 100644 (file)
@@ -65,14 +65,14 @@ NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow* windo
 
 void DOMWindowNotifications::disconnectFrame()
 {
-    reset();
+    m_suspendedNotificationCenter = m_notificationCenter.release();
     DOMWindowProperty::disconnectFrame();
 }
 
-void DOMWindowNotifications::willDetachPage()
+void DOMWindowNotifications::reconnectFrame(Frame* frame)
 {
-    reset();
-    DOMWindowProperty::willDetachPage();
+    DOMWindowProperty::reconnectFrame(frame);
+    m_notificationCenter = m_suspendedNotificationCenter.release();
 }
 
 NotificationCenter* DOMWindowNotifications::webkitNotifications()
@@ -98,14 +98,6 @@ NotificationCenter* DOMWindowNotifications::webkitNotifications()
     return m_notificationCenter.get();
 }
 
-void DOMWindowNotifications::reset()
-{
-    if (!m_notificationCenter)
-        return;
-    m_notificationCenter->disconnectFrame();
-    m_notificationCenter = 0;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
index 2ba65c2a131dfe5eb7391829f7cef451d6856e63..dbedef62c5da125e5426ea1b2ad6f15ed868667d 100644 (file)
@@ -46,17 +46,16 @@ public:
     static DOMWindowNotifications* from(DOMWindow*);
 
     virtual void disconnectFrame() OVERRIDE;
-    // FIXME: Support reconnectFrame().
-    virtual void willDetachPage() OVERRIDE;
+    virtual void reconnectFrame(Frame*) OVERRIDE;
 
 private:
     explicit DOMWindowNotifications(DOMWindow*);
 
     NotificationCenter* webkitNotifications();
-    void reset();
 
     DOMWindow* m_window;
     RefPtr<NotificationCenter> m_notificationCenter;
+    RefPtr<NotificationCenter> m_suspendedNotificationCenter;
 };
 
 } // namespace WebCore
index bccb327760c80c8cefccada524a1eaae6a807671..ec5c8ec1520f1c93091bf55e98928f21bf4ab7a2 100644 (file)
@@ -51,7 +51,9 @@ PassRefPtr<NotificationCenter> NotificationCenter::create(ScriptExecutionContext
 
 NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationClient* client)
     : ActiveDOMObject(context, this)
-    , m_client(client) { }
+    , m_client(client)
+{
+}
 
 int NotificationCenter::checkPermission()
 {
@@ -90,10 +92,8 @@ void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback)
     m_client->requestPermission(scriptExecutionContext(), callback);
 }
 
-void NotificationCenter::disconnectFrame()
+void NotificationCenter::stop()
 {
-    // Can be 0 if iframe was transferred into another page. In this case
-    // this method is invoked more then once.
     if (!m_client)
         return;
     m_client->cancelRequestsForPermission(scriptExecutionContext());
index 4ec29c532795c629eb3d44449302e8184ed715fd..a047abf81092bbabcf1647602033be2f2cf68a27 100644 (file)
@@ -80,7 +80,7 @@ public:
     int checkPermission();
     void requestPermission(PassRefPtr<VoidCallback>);
 
-    void disconnectFrame();
+    virtual void stop() OVERRIDE;
 
 private:
     NotificationCenter(ScriptExecutionContext*, NotificationClient*);