| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration::Handle> handle) | 100 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration::Handle> handle) |
| 101 : ActiveScriptWrappable(this) | 101 : ActiveScriptWrappable(this) |
| 102 , ActiveDOMObject(executionContext) | 102 , ActiveDOMObject(executionContext) |
| 103 , m_handle(handle) | 103 , m_handle(handle) |
| 104 , m_provider(nullptr) | 104 , m_provider(nullptr) |
| 105 , m_stopped(false) | 105 , m_stopped(false) |
| 106 { | 106 { |
| 107 ASSERT(m_handle); | 107 ASSERT(m_handle); |
| 108 ASSERT(!m_handle->registration()->proxy()); | 108 ASSERT(!m_handle->registration()->proxy()); |
| 109 ThreadState::current()->registerPreFinalizer(this); |
| 109 | 110 |
| 110 if (!executionContext) | 111 if (!executionContext) |
| 111 return; | 112 return; |
| 112 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) | 113 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) |
| 113 m_provider = client->provider(); | 114 m_provider = client->provider(); |
| 114 m_handle->registration()->setProxy(this); | 115 m_handle->registration()->setProxy(this); |
| 115 } | 116 } |
| 116 | 117 |
| 117 ServiceWorkerRegistration::~ServiceWorkerRegistration() | 118 ServiceWorkerRegistration::~ServiceWorkerRegistration() |
| 118 { | 119 { |
| 119 } | 120 } |
| 120 | 121 |
| 122 void ServiceWorkerRegistration::dispose() |
| 123 { |
| 124 // Promptly clears a raw reference from content/ to an on-heap object |
| 125 // so that content/ doesn't access it in a lazy sweeping phase. |
| 126 m_handle.clear(); |
| 127 } |
| 128 |
| 121 DEFINE_TRACE(ServiceWorkerRegistration) | 129 DEFINE_TRACE(ServiceWorkerRegistration) |
| 122 { | 130 { |
| 123 visitor->trace(m_installing); | 131 visitor->trace(m_installing); |
| 124 visitor->trace(m_waiting); | 132 visitor->trace(m_waiting); |
| 125 visitor->trace(m_active); | 133 visitor->trace(m_active); |
| 126 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerRegistratio
n>::trace(visitor); | 134 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerRegistratio
n>::trace(visitor); |
| 127 ActiveDOMObject::trace(visitor); | 135 ActiveDOMObject::trace(visitor); |
| 128 Supplementable<ServiceWorkerRegistration>::trace(visitor); | 136 Supplementable<ServiceWorkerRegistration>::trace(visitor); |
| 129 } | 137 } |
| 130 | 138 |
| 131 bool ServiceWorkerRegistration::hasPendingActivity() const | 139 bool ServiceWorkerRegistration::hasPendingActivity() const |
| 132 { | 140 { |
| 133 return !m_stopped; | 141 return !m_stopped; |
| 134 } | 142 } |
| 135 | 143 |
| 136 void ServiceWorkerRegistration::stop() | 144 void ServiceWorkerRegistration::stop() |
| 137 { | 145 { |
| 138 if (m_stopped) | 146 if (m_stopped) |
| 139 return; | 147 return; |
| 140 m_stopped = true; | 148 m_stopped = true; |
| 141 m_handle->registration()->proxyStopped(); | 149 m_handle->registration()->proxyStopped(); |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |