| 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 "modules/serviceworkers/ServiceWorkerRegistration.h" | 5 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 std::unique_ptr<WebServiceWorker::Handle> handle) { | 59 std::unique_ptr<WebServiceWorker::Handle> handle) { |
| 60 if (!GetExecutionContext()) | 60 if (!GetExecutionContext()) |
| 61 return; | 61 return; |
| 62 active_ = ServiceWorker::From(GetExecutionContext(), | 62 active_ = ServiceWorker::From(GetExecutionContext(), |
| 63 WTF::WrapUnique(handle.release())); | 63 WTF::WrapUnique(handle.release())); |
| 64 } | 64 } |
| 65 | 65 |
| 66 ServiceWorkerRegistration* ServiceWorkerRegistration::GetOrCreate( | 66 ServiceWorkerRegistration* ServiceWorkerRegistration::GetOrCreate( |
| 67 ExecutionContext* execution_context, | 67 ExecutionContext* execution_context, |
| 68 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) { | 68 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) { |
| 69 ASSERT(handle); | 69 DCHECK(handle); |
| 70 | 70 |
| 71 ServiceWorkerRegistration* existing_registration = | 71 ServiceWorkerRegistration* existing_registration = |
| 72 static_cast<ServiceWorkerRegistration*>(handle->Registration()->Proxy()); | 72 static_cast<ServiceWorkerRegistration*>(handle->Registration()->Proxy()); |
| 73 if (existing_registration) { | 73 if (existing_registration) { |
| 74 ASSERT(existing_registration->GetExecutionContext() == execution_context); | 74 ASSERT(existing_registration->GetExecutionContext() == execution_context); |
| 75 return existing_registration; | 75 return existing_registration; |
| 76 } | 76 } |
| 77 | 77 |
| 78 return new ServiceWorkerRegistration(execution_context, std::move(handle)); | 78 return new ServiceWorkerRegistration(execution_context, std::move(handle)); |
| 79 } | 79 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 resolver)); | 126 resolver)); |
| 127 return promise; | 127 return promise; |
| 128 } | 128 } |
| 129 | 129 |
| 130 ServiceWorkerRegistration::ServiceWorkerRegistration( | 130 ServiceWorkerRegistration::ServiceWorkerRegistration( |
| 131 ExecutionContext* execution_context, | 131 ExecutionContext* execution_context, |
| 132 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) | 132 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) |
| 133 : ContextLifecycleObserver(execution_context), | 133 : ContextLifecycleObserver(execution_context), |
| 134 handle_(std::move(handle)), | 134 handle_(std::move(handle)), |
| 135 stopped_(false) { | 135 stopped_(false) { |
| 136 ASSERT(handle_); | 136 DCHECK(handle_); |
| 137 ASSERT(!handle_->Registration()->Proxy()); | 137 DCHECK(!handle_->Registration()->Proxy()); |
| 138 | 138 |
| 139 if (!execution_context) | 139 if (!execution_context) |
| 140 return; | 140 return; |
| 141 handle_->Registration()->SetProxy(this); | 141 handle_->Registration()->SetProxy(this); |
| 142 } | 142 } |
| 143 | 143 |
| 144 ServiceWorkerRegistration::~ServiceWorkerRegistration() {} | 144 ServiceWorkerRegistration::~ServiceWorkerRegistration() {} |
| 145 | 145 |
| 146 void ServiceWorkerRegistration::Dispose() { | 146 void ServiceWorkerRegistration::Dispose() { |
| 147 // Promptly clears a raw reference from content/ to an on-heap object | 147 // Promptly clears a raw reference from content/ to an on-heap object |
| (...skipping 12 matching lines...) Expand all Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) { | 162 void ServiceWorkerRegistration::ContextDestroyed(ExecutionContext*) { |
| 163 if (stopped_) | 163 if (stopped_) |
| 164 return; | 164 return; |
| 165 stopped_ = true; | 165 stopped_ = true; |
| 166 handle_->Registration()->ProxyStopped(); | 166 handle_->Registration()->ProxyStopped(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |