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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo
leanValue, ServiceWorkerError>(resolver)); | 120 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo
leanValue, ServiceWorkerError>(resolver)); |
121 return promise; | 121 return promise; |
122 } | 122 } |
123 | 123 |
124 ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionConte
xt* executionContext, WebServiceWorkerRegistration* outerRegistration) | 124 ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionConte
xt* executionContext, WebServiceWorkerRegistration* outerRegistration) |
125 { | 125 { |
126 if (!outerRegistration) | 126 if (!outerRegistration) |
127 return 0; | 127 return 0; |
128 | 128 |
129 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); | 129 ServiceWorkerRegistration* existingRegistration = static_cast<ServiceWorkerR
egistration*>(outerRegistration->proxy()); |
130 if (proxy) { | 130 if (existingRegistration) { |
131 ServiceWorkerRegistration* existingRegistration = *proxy; | 131 ASSERT(existingRegistration->executionContext() == executionContext); |
132 if (existingRegistration) { | 132 return existingRegistration; |
133 ASSERT(existingRegistration->executionContext() == executionContext)
; | |
134 return existingRegistration; | |
135 } | |
136 } | 133 } |
137 | 134 |
138 ServiceWorkerRegistration* registration = new ServiceWorkerRegistration(exec
utionContext, adoptPtr(outerRegistration)); | 135 ServiceWorkerRegistration* registration = new ServiceWorkerRegistration(exec
utionContext, adoptPtr(outerRegistration)); |
139 registration->suspendIfNeeded(); | 136 registration->suspendIfNeeded(); |
140 return registration; | 137 return registration; |
141 } | 138 } |
142 | 139 |
143 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) | 140 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) |
144 : ActiveDOMObject(executionContext) | 141 : ActiveDOMObject(executionContext) |
145 , WebServiceWorkerRegistrationProxy(this) | |
146 , m_outerRegistration(outerRegistration) | 142 , m_outerRegistration(outerRegistration) |
147 , m_provider(0) | 143 , m_provider(0) |
148 , m_stopped(false) | 144 , m_stopped(false) |
149 { | 145 { |
150 ASSERT(m_outerRegistration); | 146 ASSERT(m_outerRegistration); |
151 | 147 |
152 if (!executionContext) | 148 if (!executionContext) |
153 return; | 149 return; |
154 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) | 150 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) |
155 m_provider = client->provider(); | 151 m_provider = client->provider(); |
(...skipping 16 matching lines...) Expand all Loading... |
172 | 168 |
173 void ServiceWorkerRegistration::stop() | 169 void ServiceWorkerRegistration::stop() |
174 { | 170 { |
175 if (m_stopped) | 171 if (m_stopped) |
176 return; | 172 return; |
177 m_stopped = true; | 173 m_stopped = true; |
178 m_outerRegistration->proxyStopped(); | 174 m_outerRegistration->proxyStopped(); |
179 } | 175 } |
180 | 176 |
181 } // namespace blink | 177 } // namespace blink |
OLD | NEW |