| 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/ActiveDOMObject.h" |
| 11 #include "core/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 12 #include "modules/serviceworkers/NavigationPreloadManager.h" |
| 12 #include "modules/serviceworkers/ServiceWorker.h" | 13 #include "modules/serviceworkers/ServiceWorker.h" |
| 13 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 14 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 14 #include "platform/Supplementable.h" | 15 #include "platform/Supplementable.h" |
| 15 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" | 16 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" |
| 16 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistrationProx
y.h" | 17 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistrationProx
y.h" |
| 17 #include "wtf/Forward.h" | 18 #include "wtf/Forward.h" |
| 18 #include <memory> | 19 #include <memory> |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 55 |
| 55 // Returns an existing registration object for the handle if it exists. | 56 // Returns an existing registration object for the handle if it exists. |
| 56 // Otherwise, returns a new registration object. | 57 // Otherwise, returns a new registration object. |
| 57 static ServiceWorkerRegistration* getOrCreate( | 58 static ServiceWorkerRegistration* getOrCreate( |
| 58 ExecutionContext*, | 59 ExecutionContext*, |
| 59 std::unique_ptr<WebServiceWorkerRegistration::Handle>); | 60 std::unique_ptr<WebServiceWorkerRegistration::Handle>); |
| 60 | 61 |
| 61 ServiceWorker* installing() { return m_installing; } | 62 ServiceWorker* installing() { return m_installing; } |
| 62 ServiceWorker* waiting() { return m_waiting; } | 63 ServiceWorker* waiting() { return m_waiting; } |
| 63 ServiceWorker* active() { return m_active; } | 64 ServiceWorker* active() { return m_active; } |
| 65 NavigationPreloadManager* navigationPreload(); |
| 64 | 66 |
| 65 String scope() const; | 67 String scope() const; |
| 66 | 68 |
| 67 WebServiceWorkerRegistration* webRegistration() { | 69 WebServiceWorkerRegistration* webRegistration() { |
| 68 return m_handle->registration(); | 70 return m_handle->registration(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 ScriptPromise update(ScriptState*); | 73 ScriptPromise update(ScriptState*); |
| 72 ScriptPromise unregister(ScriptState*); | 74 ScriptPromise unregister(ScriptState*); |
| 73 | 75 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 85 | 87 |
| 86 // ActiveDOMObject overrides. | 88 // ActiveDOMObject overrides. |
| 87 void contextDestroyed() override; | 89 void contextDestroyed() override; |
| 88 | 90 |
| 89 // A handle to the registration representation in the embedder. | 91 // A handle to the registration representation in the embedder. |
| 90 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; | 92 std::unique_ptr<WebServiceWorkerRegistration::Handle> m_handle; |
| 91 | 93 |
| 92 Member<ServiceWorker> m_installing; | 94 Member<ServiceWorker> m_installing; |
| 93 Member<ServiceWorker> m_waiting; | 95 Member<ServiceWorker> m_waiting; |
| 94 Member<ServiceWorker> m_active; | 96 Member<ServiceWorker> m_active; |
| 97 Member<NavigationPreloadManager> m_navigationPreload; |
| 95 | 98 |
| 96 bool m_stopped; | 99 bool m_stopped; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 class ServiceWorkerRegistrationArray { | 102 class ServiceWorkerRegistrationArray { |
| 100 STATIC_ONLY(ServiceWorkerRegistrationArray); | 103 STATIC_ONLY(ServiceWorkerRegistrationArray); |
| 101 | 104 |
| 102 public: | 105 public: |
| 103 static HeapVector<Member<ServiceWorkerRegistration>> take( | 106 static HeapVector<Member<ServiceWorkerRegistration>> take( |
| 104 ScriptPromiseResolver* resolver, | 107 ScriptPromiseResolver* resolver, |
| 105 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>>* | 108 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>>* |
| 106 webServiceWorkerRegistrations) { | 109 webServiceWorkerRegistrations) { |
| 107 HeapVector<Member<ServiceWorkerRegistration>> registrations; | 110 HeapVector<Member<ServiceWorkerRegistration>> registrations; |
| 108 for (auto& registration : *webServiceWorkerRegistrations) | 111 for (auto& registration : *webServiceWorkerRegistrations) |
| 109 registrations.append(ServiceWorkerRegistration::getOrCreate( | 112 registrations.append(ServiceWorkerRegistration::getOrCreate( |
| 110 resolver->getExecutionContext(), std::move(registration))); | 113 resolver->getExecutionContext(), std::move(registration))); |
| 111 return registrations; | 114 return registrations; |
| 112 } | 115 } |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 } // namespace blink | 118 } // namespace blink |
| 116 | 119 |
| 117 #endif // ServiceWorkerRegistration_h | 120 #endif // ServiceWorkerRegistration_h |
| OLD | NEW |