| 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 "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ASSERT(existingRegistration->getExecutionContext() == executionContext); | 67 ASSERT(existingRegistration->getExecutionContext() == executionContext); |
| 68 return existingRegistration; | 68 return existingRegistration; |
| 69 } | 69 } |
| 70 | 70 |
| 71 ServiceWorkerRegistration* newRegistration = | 71 ServiceWorkerRegistration* newRegistration = |
| 72 new ServiceWorkerRegistration(executionContext, std::move(handle)); | 72 new ServiceWorkerRegistration(executionContext, std::move(handle)); |
| 73 newRegistration->suspendIfNeeded(); | 73 newRegistration->suspendIfNeeded(); |
| 74 return newRegistration; | 74 return newRegistration; |
| 75 } | 75 } |
| 76 | 76 |
| 77 NavigationPreloadManager* ServiceWorkerRegistration::navigationPreload() { |
| 78 if (!m_navigationPreload) |
| 79 m_navigationPreload = NavigationPreloadManager::create(); |
| 80 return m_navigationPreload; |
| 81 } |
| 82 |
| 77 String ServiceWorkerRegistration::scope() const { | 83 String ServiceWorkerRegistration::scope() const { |
| 78 return m_handle->registration()->scope().string(); | 84 return m_handle->registration()->scope().string(); |
| 79 } | 85 } |
| 80 | 86 |
| 81 ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState) { | 87 ScriptPromise ServiceWorkerRegistration::update(ScriptState* scriptState) { |
| 82 ServiceWorkerContainerClient* client = | 88 ServiceWorkerContainerClient* client = |
| 83 ServiceWorkerContainerClient::from(getExecutionContext()); | 89 ServiceWorkerContainerClient::from(getExecutionContext()); |
| 84 if (!client || !client->provider()) | 90 if (!client || !client->provider()) |
| 85 return ScriptPromise::rejectWithDOMException( | 91 return ScriptPromise::rejectWithDOMException( |
| 86 scriptState, | 92 scriptState, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void ServiceWorkerRegistration::dispose() { | 141 void ServiceWorkerRegistration::dispose() { |
| 136 // Promptly clears a raw reference from content/ to an on-heap object | 142 // Promptly clears a raw reference from content/ to an on-heap object |
| 137 // so that content/ doesn't access it in a lazy sweeping phase. | 143 // so that content/ doesn't access it in a lazy sweeping phase. |
| 138 m_handle.reset(); | 144 m_handle.reset(); |
| 139 } | 145 } |
| 140 | 146 |
| 141 DEFINE_TRACE(ServiceWorkerRegistration) { | 147 DEFINE_TRACE(ServiceWorkerRegistration) { |
| 142 visitor->trace(m_installing); | 148 visitor->trace(m_installing); |
| 143 visitor->trace(m_waiting); | 149 visitor->trace(m_waiting); |
| 144 visitor->trace(m_active); | 150 visitor->trace(m_active); |
| 151 visitor->trace(m_navigationPreload); |
| 145 EventTargetWithInlineData::trace(visitor); | 152 EventTargetWithInlineData::trace(visitor); |
| 146 ActiveDOMObject::trace(visitor); | 153 ActiveDOMObject::trace(visitor); |
| 147 Supplementable<ServiceWorkerRegistration>::trace(visitor); | 154 Supplementable<ServiceWorkerRegistration>::trace(visitor); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void ServiceWorkerRegistration::contextDestroyed() { | 157 void ServiceWorkerRegistration::contextDestroyed() { |
| 151 if (m_stopped) | 158 if (m_stopped) |
| 152 return; | 159 return; |
| 153 m_stopped = true; | 160 m_stopped = true; |
| 154 m_handle->registration()->proxyStopped(); | 161 m_handle->registration()->proxyStopped(); |
| 155 } | 162 } |
| 156 | 163 |
| 157 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |