| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ServiceWorkerRegistration_h | 5 #ifndef ServiceWorkerRegistration_h |
| 6 #define ServiceWorkerRegistration_h | 6 #define ServiceWorkerRegistration_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/SuspendableObject.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| 11 #include "core/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 12 #include "modules/serviceworkers/NavigationPreloadManager.h" | 12 #include "modules/serviceworkers/NavigationPreloadManager.h" |
| 13 #include "modules/serviceworkers/ServiceWorker.h" | 13 #include "modules/serviceworkers/ServiceWorker.h" |
| 14 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 14 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 15 #include "platform/Supplementable.h" | 15 #include "platform/Supplementable.h" |
| 16 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" | 16 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" |
| 17 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistrationProx
y.h" | 17 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistrationProx
y.h" |
| 18 #include "wtf/Forward.h" | 18 #include "wtf/Forward.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class ScriptPromise; | 23 class ScriptPromise; |
| 24 class ScriptState; | 24 class ScriptState; |
| 25 | 25 |
| 26 // The implementation of a service worker registration object in Blink. Actual | 26 // The implementation of a service worker registration object in Blink. Actual |
| 27 // registration representation is in the embedder and this class accesses it | 27 // registration representation is in the embedder and this class accesses it |
| 28 // via WebServiceWorkerRegistration::Handle object. | 28 // via WebServiceWorkerRegistration::Handle object. |
| 29 class ServiceWorkerRegistration final | 29 class ServiceWorkerRegistration final |
| 30 : public EventTargetWithInlineData, | 30 : public EventTargetWithInlineData, |
| 31 public ActiveScriptWrappable<ServiceWorkerRegistration>, | 31 public ActiveScriptWrappable<ServiceWorkerRegistration>, |
| 32 public SuspendableObject, | 32 public ContextLifecycleObserver, |
| 33 public WebServiceWorkerRegistrationProxy, | 33 public WebServiceWorkerRegistrationProxy, |
| 34 public Supplementable<ServiceWorkerRegistration> { | 34 public Supplementable<ServiceWorkerRegistration> { |
| 35 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
| 36 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorkerRegistration); | 36 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorkerRegistration); |
| 37 USING_PRE_FINALIZER(ServiceWorkerRegistration, dispose); | 37 USING_PRE_FINALIZER(ServiceWorkerRegistration, dispose); |
| 38 | 38 |
| 39 public: | 39 public: |
| 40 // Called from CallbackPromiseAdapter. | 40 // Called from CallbackPromiseAdapter. |
| 41 using WebType = std::unique_ptr<WebServiceWorkerRegistration::Handle>; | 41 using WebType = std::unique_ptr<WebServiceWorkerRegistration::Handle>; |
| 42 static ServiceWorkerRegistration* take( | 42 static ServiceWorkerRegistration* take( |
| 43 ScriptPromiseResolver*, | 43 ScriptPromiseResolver*, |
| 44 std::unique_ptr<WebServiceWorkerRegistration::Handle>); | 44 std::unique_ptr<WebServiceWorkerRegistration::Handle>); |
| 45 | 45 |
| 46 // ScriptWrappable overrides. | 46 // ScriptWrappable overrides. |
| 47 bool hasPendingActivity() const final; | 47 bool hasPendingActivity() const final; |
| 48 | 48 |
| 49 // EventTarget overrides. | 49 // EventTarget overrides. |
| 50 const AtomicString& interfaceName() const override; | 50 const AtomicString& interfaceName() const override; |
| 51 ExecutionContext* getExecutionContext() const override { | 51 ExecutionContext* getExecutionContext() const override { |
| 52 return SuspendableObject::getExecutionContext(); | 52 return ContextLifecycleObserver::getExecutionContext(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // WebServiceWorkerRegistrationProxy overrides. | 55 // WebServiceWorkerRegistrationProxy overrides. |
| 56 void dispatchUpdateFoundEvent() override; | 56 void dispatchUpdateFoundEvent() override; |
| 57 void setInstalling(std::unique_ptr<WebServiceWorker::Handle>) override; | 57 void setInstalling(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 58 void setWaiting(std::unique_ptr<WebServiceWorker::Handle>) override; | 58 void setWaiting(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 59 void setActive(std::unique_ptr<WebServiceWorker::Handle>) override; | 59 void setActive(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 60 | 60 |
| 61 // Returns an existing registration object for the handle if it exists. | 61 // Returns an existing registration object for the handle if it exists. |
| 62 // Otherwise, returns a new registration object. | 62 // Otherwise, returns a new registration object. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 83 ~ServiceWorkerRegistration() override; | 83 ~ServiceWorkerRegistration() override; |
| 84 | 84 |
| 85 DECLARE_VIRTUAL_TRACE(); | 85 DECLARE_VIRTUAL_TRACE(); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 ServiceWorkerRegistration( | 88 ServiceWorkerRegistration( |
| 89 ExecutionContext*, | 89 ExecutionContext*, |
| 90 std::unique_ptr<WebServiceWorkerRegistration::Handle>); | 90 std::unique_ptr<WebServiceWorkerRegistration::Handle>); |
| 91 void dispose(); | 91 void dispose(); |
| 92 | 92 |
| 93 // SuspendableObject overrides. | 93 // ContextLifecycleObserver overrides. |
| 94 void contextDestroyed() override; | 94 void contextDestroyed() override; |
| 95 | 95 |
| 96 // A handle to the registration representation in the embedder. | 96 // A handle to the registration representation in the embedder. |
| 97 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; | 97 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; |
| 98 | 98 |
| 99 Member<ServiceWorker> m_installing; | 99 Member<ServiceWorker> m_installing; |
| 100 Member<ServiceWorker> m_waiting; | 100 Member<ServiceWorker> m_waiting; |
| 101 Member<ServiceWorker> m_active; | 101 Member<ServiceWorker> m_active; |
| 102 Member<NavigationPreloadManager> m_navigationPreload; | 102 Member<NavigationPreloadManager> m_navigationPreload; |
| 103 | 103 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 119 registrations.append( | 119 registrations.append( |
| 120 ServiceWorkerRegistration::take(resolver, std::move(registration))); | 120 ServiceWorkerRegistration::take(resolver, std::move(registration))); |
| 121 } | 121 } |
| 122 return registrations; | 122 return registrations; |
| 123 } | 123 } |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| 127 | 127 |
| 128 #endif // ServiceWorkerRegistration_h | 128 #endif // ServiceWorkerRegistration_h |
| OLD | NEW |