| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return registration; | 138 return registration; |
| 139 } | 139 } |
| 140 | 140 |
| 141 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) | 141 ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution
Context, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration) |
| 142 : ActiveDOMObject(executionContext) | 142 : ActiveDOMObject(executionContext) |
| 143 , m_outerRegistration(outerRegistration) | 143 , m_outerRegistration(outerRegistration) |
| 144 , m_provider(0) | 144 , m_provider(0) |
| 145 , m_stopped(false) | 145 , m_stopped(false) |
| 146 { | 146 { |
| 147 ASSERT(m_outerRegistration); | 147 ASSERT(m_outerRegistration); |
| 148 ThreadState::current()->registerPreFinalizer(*this); |
| 148 | 149 |
| 149 if (!executionContext) | 150 if (!executionContext) |
| 150 return; | 151 return; |
| 151 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) | 152 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) |
| 152 m_provider = client->provider(); | 153 m_provider = client->provider(); |
| 153 m_outerRegistration->setProxy(this); | 154 m_outerRegistration->setProxy(this); |
| 154 } | 155 } |
| 155 | 156 |
| 157 ServiceWorkerRegistration::~ServiceWorkerRegistration() |
| 158 { |
| 159 ASSERT(!m_outerRegistration); |
| 160 } |
| 161 |
| 162 void ServiceWorkerRegistration::dispose() |
| 163 { |
| 164 // See ServiceWorker::dispose() comment why this explicit dispose() action i
s needed. |
| 165 m_outerRegistration.clear(); |
| 166 } |
| 167 |
| 156 void ServiceWorkerRegistration::trace(Visitor* visitor) | 168 void ServiceWorkerRegistration::trace(Visitor* visitor) |
| 157 { | 169 { |
| 158 visitor->trace(m_installing); | 170 visitor->trace(m_installing); |
| 159 visitor->trace(m_waiting); | 171 visitor->trace(m_waiting); |
| 160 visitor->trace(m_active); | 172 visitor->trace(m_active); |
| 161 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerRegistratio
n>::trace(visitor); | 173 RefCountedGarbageCollectedEventTargetWithInlineData<ServiceWorkerRegistratio
n>::trace(visitor); |
| 162 HeapSupplementable<ServiceWorkerRegistration>::trace(visitor); | 174 HeapSupplementable<ServiceWorkerRegistration>::trace(visitor); |
| 163 ActiveDOMObject::trace(visitor); | 175 ActiveDOMObject::trace(visitor); |
| 164 } | 176 } |
| 165 | 177 |
| 166 bool ServiceWorkerRegistration::hasPendingActivity() const | 178 bool ServiceWorkerRegistration::hasPendingActivity() const |
| 167 { | 179 { |
| 168 return !m_stopped; | 180 return !m_stopped; |
| 169 } | 181 } |
| 170 | 182 |
| 171 void ServiceWorkerRegistration::stop() | 183 void ServiceWorkerRegistration::stop() |
| 172 { | 184 { |
| 173 if (m_stopped) | 185 if (m_stopped) |
| 174 return; | 186 return; |
| 175 m_stopped = true; | 187 m_stopped = true; |
| 176 m_outerRegistration->proxyStopped(); | 188 m_outerRegistration->proxyStopped(); |
| 177 } | 189 } |
| 178 | 190 |
| 179 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |