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 #include "config.h" | 5 #include "config.h" |
6 #include "ServiceWorkerRegistration.h" | 6 #include "ServiceWorkerRegistration.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) | 89 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) |
90 { | 90 { |
91 if (!executionContext()) { | 91 if (!executionContext()) { |
92 deleteIfNoExistingOwner(serviceWorker); | 92 deleteIfNoExistingOwner(serviceWorker); |
93 return; | 93 return; |
94 } | 94 } |
95 m_active = ServiceWorker::from(executionContext(), serviceWorker); | 95 m_active = ServiceWorker::from(executionContext(), serviceWorker); |
96 } | 96 } |
97 | 97 |
98 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::tak
e(ScriptPromiseResolver* resolver, WebType* registration) | 98 ServiceWorkerRegistration* ServiceWorkerRegistration::take(ScriptPromiseResolver
* resolver, WebType* registration) |
99 { | 99 { |
100 if (!registration) | 100 if (!registration) |
101 return nullptr; | 101 return 0; |
102 return getOrCreate(resolver->scriptState()->executionContext(), registration
); | 102 return getOrCreate(resolver->scriptState()->executionContext(), registration
); |
103 } | 103 } |
104 | 104 |
105 void ServiceWorkerRegistration::dispose(WebType* registration) | 105 void ServiceWorkerRegistration::dispose(WebType* registration) |
106 { | 106 { |
107 delete registration; | 107 delete registration; |
108 } | 108 } |
109 | 109 |
110 String ServiceWorkerRegistration::scope() const | 110 String ServiceWorkerRegistration::scope() const |
111 { | 111 { |
(...skipping 19 matching lines...) Expand all Loading... |
131 } | 131 } |
132 | 132 |
133 #ifdef DISABLE_SERVICEWORKER_UNREGISTER_RESOLVE_TO_BOOLEAN | 133 #ifdef DISABLE_SERVICEWORKER_UNREGISTER_RESOLVE_TO_BOOLEAN |
134 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und
efinedValue, ServiceWorkerError>(resolver)); | 134 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und
efinedValue, ServiceWorkerError>(resolver)); |
135 #else | 135 #else |
136 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo
leanValue, ServiceWorkerError>(resolver)); | 136 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo
leanValue, ServiceWorkerError>(resolver)); |
137 #endif | 137 #endif |
138 return promise; | 138 return promise; |
139 } | 139 } |
140 | 140 |
141 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get
OrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outer
Registration) | 141 ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionConte
xt* executionContext, WebServiceWorkerRegistration* outerRegistration) |
142 { | 142 { |
143 if (!outerRegistration) | 143 if (!outerRegistration) |
144 return nullptr; | 144 return 0; |
145 | 145 |
146 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); | 146 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); |
147 if (proxy) { | 147 if (proxy) { |
148 ServiceWorkerRegistration* existingRegistration = *proxy; | 148 ServiceWorkerRegistration* existingRegistration = *proxy; |
149 if (existingRegistration) { | 149 if (existingRegistration) { |
150 ASSERT(existingRegistration->executionContext() == executionContext)
; | 150 ASSERT(existingRegistration->executionContext() == executionContext)
; |
151 return existingRegistration; | 151 return existingRegistration; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 RefPtrWillBeRawPtr<ServiceWorkerRegistration> registration = adoptRefWillBeN
oop(new ServiceWorkerRegistration(executionContext, adoptPtr(outerRegistration))
); | 155 ServiceWorkerRegistration* registration = adoptRefCountedGarbageCollectedWil
lBeNoop(new ServiceWorkerRegistration(executionContext, adoptPtr(outerRegistrati
on))); |
156 registration->suspendIfNeeded(); | 156 registration->suspendIfNeeded(); |
157 return registration.release(); | 157 return registration; |
158 } | 158 } |
159 | 159 |
160 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) | 160 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) |
161 : ActiveDOMObject(executionContext) | 161 : ActiveDOMObject(executionContext) |
162 , WebServiceWorkerRegistrationProxy(this) | 162 , WebServiceWorkerRegistrationProxy(this) |
163 , m_outerRegistration(outerRegistration) | 163 , m_outerRegistration(outerRegistration) |
164 , m_provider(0) | 164 , m_provider(0) |
165 , m_stopped(false) | 165 , m_stopped(false) |
166 { | 166 { |
167 ASSERT(m_outerRegistration); | 167 ASSERT(m_outerRegistration); |
(...skipping 21 matching lines...) Expand all Loading... |
189 | 189 |
190 void ServiceWorkerRegistration::stop() | 190 void ServiceWorkerRegistration::stop() |
191 { | 191 { |
192 if (m_stopped) | 192 if (m_stopped) |
193 return; | 193 return; |
194 m_stopped = true; | 194 m_stopped = true; |
195 m_outerRegistration->proxyStopped(); | 195 m_outerRegistration->proxyStopped(); |
196 } | 196 } |
197 | 197 |
198 } // namespace blink | 198 } // namespace blink |
OLD | NEW |