| 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/ActiveDOMObject.h" | 10 #include "core/dom/SuspendableObject.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, | 31 public ActiveScriptWrappable, |
| 32 public ActiveDOMObject, | 32 public SuspendableObject, |
| 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 // ScriptWrappable overrides. | 40 // ScriptWrappable overrides. |
| 41 bool hasPendingActivity() const final; | 41 bool hasPendingActivity() const final; |
| 42 | 42 |
| 43 // EventTarget overrides. | 43 // EventTarget overrides. |
| 44 const AtomicString& interfaceName() const override; | 44 const AtomicString& interfaceName() const override; |
| 45 ExecutionContext* getExecutionContext() const override { | 45 ExecutionContext* getExecutionContext() const override { |
| 46 return ActiveDOMObject::getExecutionContext(); | 46 return SuspendableObject::getExecutionContext(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // WebServiceWorkerRegistrationProxy overrides. | 49 // WebServiceWorkerRegistrationProxy overrides. |
| 50 void dispatchUpdateFoundEvent() override; | 50 void dispatchUpdateFoundEvent() override; |
| 51 void setInstalling(std::unique_ptr<WebServiceWorker::Handle>) override; | 51 void setInstalling(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 52 void setWaiting(std::unique_ptr<WebServiceWorker::Handle>) override; | 52 void setWaiting(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 53 void setActive(std::unique_ptr<WebServiceWorker::Handle>) override; | 53 void setActive(std::unique_ptr<WebServiceWorker::Handle>) override; |
| 54 | 54 |
| 55 // Returns an existing registration object for the handle if it exists. | 55 // Returns an existing registration object for the handle if it exists. |
| 56 // Otherwise, returns a new registration object. | 56 // Otherwise, returns a new registration object. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 ~ServiceWorkerRegistration() override; | 77 ~ServiceWorkerRegistration() override; |
| 78 | 78 |
| 79 DECLARE_VIRTUAL_TRACE(); | 79 DECLARE_VIRTUAL_TRACE(); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 ServiceWorkerRegistration( | 82 ServiceWorkerRegistration( |
| 83 ExecutionContext*, | 83 ExecutionContext*, |
| 84 std::unique_ptr<WebServiceWorkerRegistration::Handle>); | 84 std::unique_ptr<WebServiceWorkerRegistration::Handle>); |
| 85 void dispose(); | 85 void dispose(); |
| 86 | 86 |
| 87 // ActiveDOMObject overrides. | 87 // SuspendableObject overrides. |
| 88 void contextDestroyed() override; | 88 void contextDestroyed() override; |
| 89 | 89 |
| 90 // A handle to the registration representation in the embedder. | 90 // A handle to the registration representation in the embedder. |
| 91 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; | 91 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; |
| 92 | 92 |
| 93 Member<ServiceWorker> m_installing; | 93 Member<ServiceWorker> m_installing; |
| 94 Member<ServiceWorker> m_waiting; | 94 Member<ServiceWorker> m_waiting; |
| 95 Member<ServiceWorker> m_active; | 95 Member<ServiceWorker> m_active; |
| 96 Member<NavigationPreloadManager> m_navigationPreload; | 96 Member<NavigationPreloadManager> m_navigationPreload; |
| 97 | 97 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 for (auto& registration : *webServiceWorkerRegistrations) | 110 for (auto& registration : *webServiceWorkerRegistrations) |
| 111 registrations.append(ServiceWorkerRegistration::getOrCreate( | 111 registrations.append(ServiceWorkerRegistration::getOrCreate( |
| 112 resolver->getExecutionContext(), std::move(registration))); | 112 resolver->getExecutionContext(), std::move(registration))); |
| 113 return registrations; | 113 return registrations; |
| 114 } | 114 } |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace blink | 117 } // namespace blink |
| 118 | 118 |
| 119 #endif // ServiceWorkerRegistration_h | 119 #endif // ServiceWorkerRegistration_h |
| OLD | NEW |