Chromium Code Reviews| 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 "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "modules/serviceworkers/ServiceWorker.h" | 10 #include "modules/serviceworkers/ServiceWorker.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 // EventTarget overrides. | 36 // EventTarget overrides. |
| 37 const AtomicString& interfaceName() const override; | 37 const AtomicString& interfaceName() const override; |
| 38 ExecutionContext* executionContext() const override { return ActiveDOMObject ::executionContext(); } | 38 ExecutionContext* executionContext() const override { return ActiveDOMObject ::executionContext(); } |
| 39 | 39 |
| 40 // WebServiceWorkerRegistrationProxy overrides. | 40 // WebServiceWorkerRegistrationProxy overrides. |
| 41 void dispatchUpdateFoundEvent() override; | 41 void dispatchUpdateFoundEvent() override; |
| 42 void setInstalling(WebServiceWorker*) override; | 42 void setInstalling(WebServiceWorker*) override; |
| 43 void setWaiting(WebServiceWorker*) override; | 43 void setWaiting(WebServiceWorker*) override; |
| 44 void setActive(WebServiceWorker*) override; | 44 void setActive(WebServiceWorker*) override; |
| 45 | 45 |
| 46 static ServiceWorkerRegistration* from(ExecutionContext*, WebServiceWorkerRe gistration*); | 46 static ServiceWorkerRegistration* create(ExecutionContext*, PassOwnPtr<WebSe rviceWorkerRegistration>); |
| 47 static ServiceWorkerRegistration* take(ScriptPromiseResolver*, WebServiceWor kerRegistration*); | 47 static ServiceWorkerRegistration* take(ScriptPromiseResolver*, PassOwnPtr<We bServiceWorkerRegistration>); |
|
falken
2015/08/26 07:47:57
Can you document these functions? I don't intuitiv
nhiroki
2015/08/26 08:16:01
Removed take(). take() was used for CallbackPromis
| |
| 48 static void dispose(WebServiceWorkerRegistration*); | 48 static void dispose(WebServiceWorkerRegistration*); |
| 49 | 49 |
| 50 ServiceWorker* installing() { return m_installing; } | 50 ServiceWorker* installing() { return m_installing; } |
| 51 ServiceWorker* waiting() { return m_waiting; } | 51 ServiceWorker* waiting() { return m_waiting; } |
| 52 ServiceWorker* active() { return m_active; } | 52 ServiceWorker* active() { return m_active; } |
| 53 | 53 |
| 54 String scope() const; | 54 String scope() const; |
| 55 | 55 |
| 56 WebServiceWorkerRegistration* webRegistration() { return m_outerRegistration .get(); } | 56 WebServiceWorkerRegistration* webRegistration() { return m_outerRegistration .get(); } |
| 57 | 57 |
| 58 ScriptPromise update(ScriptState*); | 58 ScriptPromise update(ScriptState*); |
| 59 ScriptPromise unregister(ScriptState*); | 59 ScriptPromise unregister(ScriptState*); |
| 60 | 60 |
| 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(updatefound); | 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(updatefound); |
| 62 | 62 |
| 63 ~ServiceWorkerRegistration() override; | 63 ~ServiceWorkerRegistration() override; |
| 64 | 64 |
| 65 // Eager finalization needed to promptly release owned WebServiceWorkerRegis tration. | 65 // Eager finalization needed to promptly release owned WebServiceWorkerRegis tration. |
| 66 EAGERLY_FINALIZE(); | 66 EAGERLY_FINALIZE(); |
| 67 DECLARE_VIRTUAL_TRACE(); | 67 DECLARE_VIRTUAL_TRACE(); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 static ServiceWorkerRegistration* getOrCreate(ExecutionContext*, WebServiceW orkerRegistration*); | |
| 71 ServiceWorkerRegistration(ExecutionContext*, PassOwnPtr<WebServiceWorkerRegi stration>); | 70 ServiceWorkerRegistration(ExecutionContext*, PassOwnPtr<WebServiceWorkerRegi stration>); |
| 72 | 71 |
| 73 // ActiveDOMObject overrides. | 72 // ActiveDOMObject overrides. |
| 74 bool hasPendingActivity() const override; | 73 bool hasPendingActivity() const override; |
| 75 void stop() override; | 74 void stop() override; |
| 76 | 75 |
| 77 OwnPtr<WebServiceWorkerRegistration> m_outerRegistration; | 76 OwnPtr<WebServiceWorkerRegistration> m_outerRegistration; |
| 78 WebServiceWorkerProvider* m_provider; | 77 WebServiceWorkerProvider* m_provider; |
| 79 Member<ServiceWorker> m_installing; | 78 Member<ServiceWorker> m_installing; |
| 80 Member<ServiceWorker> m_waiting; | 79 Member<ServiceWorker> m_waiting; |
| 81 Member<ServiceWorker> m_active; | 80 Member<ServiceWorker> m_active; |
| 82 | 81 |
| 83 bool m_stopped; | 82 bool m_stopped; |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 class ServiceWorkerRegistrationArray { | 85 class ServiceWorkerRegistrationArray { |
| 87 STATIC_ONLY(ServiceWorkerRegistrationArray); | 86 STATIC_ONLY(ServiceWorkerRegistrationArray); |
| 88 public: | 87 public: |
| 89 static HeapVector<Member<ServiceWorkerRegistration>> take(ScriptPromiseResol ver* resolver, PassOwnPtr<WebVector<WebServiceWorkerRegistration*>> webServiceWo rkerRegistrations) | 88 static HeapVector<Member<ServiceWorkerRegistration>> take(ScriptPromiseResol ver* resolver, PassOwnPtr<WebVector<WebServiceWorkerRegistration*>> webServiceWo rkerRegistrations) |
| 90 { | 89 { |
| 91 HeapVector<Member<ServiceWorkerRegistration>> registrations; | 90 HeapVector<Member<ServiceWorkerRegistration>> registrations; |
| 92 for (WebServiceWorkerRegistration* registration : *webServiceWorkerRegis trations) | 91 for (WebServiceWorkerRegistration* registration : *webServiceWorkerRegis trations) |
| 93 registrations.append(ServiceWorkerRegistration::take(resolver, regis tration)); | 92 registrations.append(ServiceWorkerRegistration::take(resolver, adopt Ptr(registration))); |
| 94 return registrations; | 93 return registrations; |
| 95 } | 94 } |
| 96 | |
| 97 static void dispose(PassOwnPtr<WebVector<WebServiceWorkerRegistration*>> web ServiceWorkerRegistrations) | |
| 98 { | |
| 99 for (WebServiceWorkerRegistration* registration : *webServiceWorkerRegis trations) | |
| 100 ServiceWorkerRegistration::dispose(registration); | |
| 101 } | |
| 102 }; | 95 }; |
| 103 | 96 |
| 104 } // namespace blink | 97 } // namespace blink |
| 105 | 98 |
| 106 #endif // ServiceWorkerRegistration_h | 99 #endif // ServiceWorkerRegistration_h |
| OLD | NEW |