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