NavigatorBase::serviceWorker() should return a reference instead of a raw pointer
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2017 00:22:14 +0000 (00:22 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2017 00:22:14 +0000 (00:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180059

Reviewed by Geoffrey Garen.

NavigatorBase::serviceWorker() should return a reference instead of a raw pointer
as it can never return null.

* bindings/js/JSNavigatorCustom.cpp:
(WebCore::JSNavigator::visitAdditionalChildren):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::serviceWorkerContainer):
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::serviceWorker):
* page/NavigatorBase.h:

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSNavigatorCustom.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/page/NavigatorBase.cpp
Source/WebCore/page/NavigatorBase.h

index 10b7606..04f4319 100644 (file)
@@ -1,3 +1,21 @@
+2017-11-27  Chris Dumez  <cdumez@apple.com>
+
+        NavigatorBase::serviceWorker() should return a reference instead of a raw pointer
+        https://bugs.webkit.org/show_bug.cgi?id=180059
+
+        Reviewed by Geoffrey Garen.
+
+        NavigatorBase::serviceWorker() should return a reference instead of a raw pointer
+        as it can never return null.
+
+        * bindings/js/JSNavigatorCustom.cpp:
+        (WebCore::JSNavigator::visitAdditionalChildren):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::serviceWorkerContainer):
+        * page/NavigatorBase.cpp:
+        (WebCore::NavigatorBase::serviceWorker):
+        * page/NavigatorBase.h:
+
 2017-11-27  Antoine Quint  <graouts@apple.com>
 
         Pressing the space bar while watching a fullscreen video doesn't play or pause
index ada3a37..49cda06 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
 void JSNavigator::visitAdditionalChildren(SlotVisitor& visitor)
 {
 #if ENABLE(SERVICE_WORKER)
-    visitor.addOpaqueRoot(wrapped().serviceWorker());
+    visitor.addOpaqueRoot(&wrapped().serviceWorker());
 #else
     UNUSED_PARAM(visitor);
 #endif
index 495525f..b9eec93 100644 (file)
@@ -569,7 +569,7 @@ ServiceWorkerContainer* ScriptExecutionContext::serviceWorkerContainer()
     } else
         navigator = downcast<WorkerGlobalScope>(*this).optionalNavigator();
 
-    return navigator ? navigator->serviceWorker() : nullptr;
+    return navigator ? &navigator->serviceWorker() : nullptr;
 }
 #endif
 
index 66b6ad1..979eea5 100644 (file)
@@ -149,9 +149,9 @@ Vector<String> NavigatorBase::languages()
 }
 
 #if ENABLE(SERVICE_WORKER)
-ServiceWorkerContainer* NavigatorBase::serviceWorker()
+ServiceWorkerContainer& NavigatorBase::serviceWorker()
 {
-    return &m_serviceWorkerContainer;
+    return m_serviceWorkerContainer;
 }
 #endif
 
index ec6ce63..84b464d 100644 (file)
@@ -60,7 +60,7 @@ protected:
 
 #if ENABLE(SERVICE_WORKER)
 public:
-    ServiceWorkerContainer* serviceWorker();
+    ServiceWorkerContainer& serviceWorker();
 
 private:
     UniqueRef<ServiceWorkerContainer> m_serviceWorkerContainer;