2011-02-05 Nate Chapin <japhet@chromium.org>
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 10:37:15 +0000 (10:37 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 10:37:15 +0000 (10:37 +0000)
        Reviewed by Adam Barth.

        Refactor: NotificationCenter shouldn't hold its own copy of the ScriptExecutionContext*
        when it inherits one from ActiveDOMObject.
        https://bugs.webkit.org/show_bug.cgi?id=53815

        * bindings/js/JSDesktopNotificationsCustom.cpp:
        (WebCore::JSNotificationCenter::requestPermission):
        * bindings/v8/custom/V8NotificationCenterCustom.cpp:
        (WebCore::V8NotificationCenter::requestPermissionCallback):
        * notifications/NotificationCenter.cpp:
        (WebCore::NotificationCenter::NotificationCenter):
        (WebCore::NotificationCenter::checkPermission):
        (WebCore::NotificationCenter::requestPermission):
        (WebCore::NotificationCenter::disconnectFrame):
        * notifications/NotificationCenter.h:
        (WebCore::NotificationCenter::createHTMLNotification):
        (WebCore::NotificationCenter::createNotification):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp
Source/WebCore/notifications/NotificationCenter.cpp
Source/WebCore/notifications/NotificationCenter.h

index cfa606c2995b84feda5f08aa69b7bd354bb2325b..6c2397e1ca08aab00aafe019d2126f08160bcfe1 100644 (file)
@@ -1,3 +1,24 @@
+2011-02-05  Nate Chapin  <japhet@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Refactor: NotificationCenter shouldn't hold its own copy of the ScriptExecutionContext*
+        when it inherits one from ActiveDOMObject.
+        https://bugs.webkit.org/show_bug.cgi?id=53815
+
+        * bindings/js/JSDesktopNotificationsCustom.cpp:
+        (WebCore::JSNotificationCenter::requestPermission):
+        * bindings/v8/custom/V8NotificationCenterCustom.cpp:
+        (WebCore::V8NotificationCenter::requestPermissionCallback):
+        * notifications/NotificationCenter.cpp:
+        (WebCore::NotificationCenter::NotificationCenter):
+        (WebCore::NotificationCenter::checkPermission):
+        (WebCore::NotificationCenter::requestPermission):
+        (WebCore::NotificationCenter::disconnectFrame):
+        * notifications/NotificationCenter.h:
+        (WebCore::NotificationCenter::createHTMLNotification):
+        (WebCore::NotificationCenter::createNotification):
+
 2011-02-04  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Maciej Stachowiak.
index 38334b936988337e95e3c7d0b3d29ec13e54ab72..16a962c5629a359d5dc7ce8e22bad85065e912ce 100644 (file)
@@ -47,7 +47,7 @@ namespace WebCore {
 
 JSValue JSNotificationCenter::requestPermission(ExecState* exec)
 {
-    ScriptExecutionContext* context = impl()->context();
+    ScriptExecutionContext* context = impl()->scriptExecutionContext();
 
     // Make sure that script execution context is valid.
     if (!context) {
index f1357bd3107698006d26eb793b160bb4bae4ea5c..c94afd90b7c6fcc15d2fca3eaf33885b0a996a56 100644 (file)
@@ -81,7 +81,7 @@ v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::
 {
     INC_STATS(L"DOM.NotificationCenter.RequestPermission()");
     NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder());
-    ScriptExecutionContext* context = notificationCenter->context();
+    ScriptExecutionContext* context = notificationCenter->scriptExecutionContext();
 
     // Make sure that script execution context is valid.
     if (!context)
index a2289ec5d05746c8f9069b6abd5ff6af5562416c..3d08055304ed197f83c2e0e4204b07dc5fc0956e 100644 (file)
@@ -42,21 +42,20 @@ namespace WebCore {
 
 NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationPresenter* presenter)
     : ActiveDOMObject(context, this)
-    , m_scriptExecutionContext(context)
     , m_notificationPresenter(presenter) {}
 
 int NotificationCenter::checkPermission()
 {
-    if (!presenter())
+    if (!presenter() || !scriptExecutionContext())
         return NotificationPresenter::PermissionDenied;
-    return m_notificationPresenter->checkPermission(m_scriptExecutionContext);
+    return m_notificationPresenter->checkPermission(scriptExecutionContext());
 }
 
 void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback)
 {
-    if (!presenter())
+    if (!presenter() || !scriptExecutionContext())
         return;
-    m_notificationPresenter->requestPermission(m_scriptExecutionContext, callback);
+    m_notificationPresenter->requestPermission(scriptExecutionContext(), callback);
 }
 
 void NotificationCenter::disconnectFrame()
@@ -66,9 +65,8 @@ void NotificationCenter::disconnectFrame()
     ASSERT(m_notificationPresenter);
     if (!m_notificationPresenter)
         return;
-    m_notificationPresenter->cancelRequestsForPermission(m_scriptExecutionContext);
+    m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext());
     m_notificationPresenter = 0;
-    m_scriptExecutionContext = 0;
 }
 
 } // namespace WebCore
index adad59df4a805223b7cc6f228ad8b2f21ec7ad5f..d12fbdf5dba099d37a0784fff43bca15aeeb448c 100644 (file)
@@ -58,7 +58,7 @@ namespace WebCore {
                 ec = SYNTAX_ERR;
                 return 0;
             }
-            return Notification::create(m_scriptExecutionContext->completeURL(URI), context(), ec, this);
+            return Notification::create(scriptExecutionContext()->completeURL(URI), scriptExecutionContext(), ec, this);
         }
 
         PassRefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
@@ -67,11 +67,10 @@ namespace WebCore {
                 ec = INVALID_STATE_ERR;
                 return 0;
             }
-            NotificationContents contents(iconURI.isEmpty() ? KURL() : m_scriptExecutionContext->completeURL(iconURI), title, body);
-            return Notification::create(contents, context(), ec, this);
+            NotificationContents contents(iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(iconURI), title, body);
+            return Notification::create(contents, scriptExecutionContext(), ec, this);
         }
 
-        ScriptExecutionContext* context() const { return m_scriptExecutionContext; }
         NotificationPresenter* presenter() const { return m_notificationPresenter; }
 
         int checkPermission();
@@ -82,7 +81,6 @@ namespace WebCore {
     private:
         NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
 
-        ScriptExecutionContext* m_scriptExecutionContext;
         NotificationPresenter* m_notificationPresenter;
     };