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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) | 70 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) |
71 { | 71 { |
72 if (!executionContext()) { | 72 if (!executionContext()) { |
73 deleteIfNoExistingOwner(serviceWorker); | 73 deleteIfNoExistingOwner(serviceWorker); |
74 return; | 74 return; |
75 } | 75 } |
76 m_active = ServiceWorker::from(executionContext(), serviceWorker); | 76 m_active = ServiceWorker::from(executionContext(), serviceWorker); |
77 } | 77 } |
78 | 78 |
| 79 ServiceWorkerRegistration* ServiceWorkerRegistration::from(ExecutionContext* exe
cutionContext, WebType* registration) |
| 80 { |
| 81 if (!registration) |
| 82 return 0; |
| 83 return getOrCreate(executionContext, registration); |
| 84 } |
| 85 |
79 ServiceWorkerRegistration* ServiceWorkerRegistration::take(ScriptPromiseResolver
* resolver, WebType* registration) | 86 ServiceWorkerRegistration* ServiceWorkerRegistration::take(ScriptPromiseResolver
* resolver, WebType* registration) |
80 { | 87 { |
81 if (!registration) | 88 return from(resolver->scriptState()->executionContext(), registration); |
82 return 0; | |
83 return getOrCreate(resolver->scriptState()->executionContext(), registration
); | |
84 } | 89 } |
85 | 90 |
86 void ServiceWorkerRegistration::dispose(WebType* registration) | 91 void ServiceWorkerRegistration::dispose(WebType* registration) |
87 { | 92 { |
88 delete registration; | 93 delete registration; |
89 } | 94 } |
90 | 95 |
91 String ServiceWorkerRegistration::scope() const | 96 String ServiceWorkerRegistration::scope() const |
92 { | 97 { |
93 return m_outerRegistration->scope().string(); | 98 return m_outerRegistration->scope().string(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 171 |
167 void ServiceWorkerRegistration::stop() | 172 void ServiceWorkerRegistration::stop() |
168 { | 173 { |
169 if (m_stopped) | 174 if (m_stopped) |
170 return; | 175 return; |
171 m_stopped = true; | 176 m_stopped = true; |
172 m_outerRegistration->proxyStopped(); | 177 m_outerRegistration->proxyStopped(); |
173 } | 178 } |
174 | 179 |
175 } // namespace blink | 180 } // namespace blink |
OLD | NEW |