OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 } | 159 } |
160 | 160 |
161 void ApplicationCacheHost::setApplicationCache(ApplicationCache* domApplicationC ache) | 161 void ApplicationCacheHost::setApplicationCache(ApplicationCache* domApplicationC ache) |
162 { | 162 { |
163 ASSERT(!m_domApplicationCache || !domApplicationCache); | 163 ASSERT(!m_domApplicationCache || !domApplicationCache); |
164 m_domApplicationCache = domApplicationCache; | 164 m_domApplicationCache = domApplicationCache; |
165 } | 165 } |
166 | 166 |
167 void ApplicationCacheHost::dispose() | 167 void ApplicationCacheHost::dispose() |
168 { | 168 { |
169 // FIXME: Oilpan: remove the dispose step when the owning DocumentLoader | 169 #if !ENABLE(OILPAN) |
haraken
2015/06/22 01:57:58
Can we move the #if !ENABLE(OILPAN) to the entire
sof
2015/06/22 06:49:18
Renamed as detachFromDocumentLoader() instead (cf.
| |
170 // becomes a garbage collected object. Until that time, have the | 170 // The owning DocumentLoader must explicitly dispose of and |
171 // DocumentLoader dispose and disable this ApplicationCacheHost when | 171 // disable this ApplicationCacheHost when it is finalized. |
172 // it is finalized. Releasing the WebApplicationCacheHost is needed | 172 // Releasing the WebApplicationCacheHost is needed to prevent |
173 // to prevent further embedder notifications, which risk accessing an | 173 // further embedder notifications, which risk accessing an |
174 // invalid DocumentLoader. | 174 // invalid DocumentLoader. |
175 setApplicationCache(0); | 175 setApplicationCache(0); |
176 m_host.clear(); | 176 m_host.clear(); |
177 m_documentLoader = nullptr; | 177 m_documentLoader = nullptr; |
haraken
2015/06/22 01:57:59
Now in non-oilpan, both DocumentLoader and Applica
sof
2015/06/22 05:03:46
That will not work. The Persistent<> on DocumentLo
haraken
2015/06/22 05:28:55
I'm not sure but maybe can we clear the Persistent
| |
178 #endif | |
178 } | 179 } |
179 | 180 |
180 void ApplicationCacheHost::notifyApplicationCache(EventID id, int progressTotal, int progressDone, WebApplicationCacheHost::ErrorReason errorReason, const Strin g& errorURL, int errorStatus, const String& errorMessage) | 181 void ApplicationCacheHost::notifyApplicationCache(EventID id, int progressTotal, int progressDone, WebApplicationCacheHost::ErrorReason errorReason, const Strin g& errorURL, int errorStatus, const String& errorMessage) |
181 { | 182 { |
182 if (id != PROGRESS_EVENT) | 183 if (id != PROGRESS_EVENT) |
183 InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader- >frame()); | 184 InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader- >frame()); |
184 | 185 |
185 if (m_defersEvents) { | 186 if (m_defersEvents) { |
186 // Event dispatching is deferred until document.onload has fired. | 187 // Event dispatching is deferred until document.onload has fired. |
187 m_deferredEvents.append(DeferredEvent(id, progressTotal, progressDone, e rrorReason, errorURL, errorStatus, errorMessage)); | 188 m_deferredEvents.append(DeferredEvent(id, progressTotal, progressDone, e rrorReason, errorURL, errorStatus, errorMessage)); |
(...skipping 21 matching lines...) Expand all Loading... | |
209 m_host->getResourceList(&webResources); | 210 m_host->getResourceList(&webResources); |
210 for (size_t i = 0; i < webResources.size(); ++i) { | 211 for (size_t i = 0; i < webResources.size(); ++i) { |
211 resources->append(ResourceInfo( | 212 resources->append(ResourceInfo( |
212 webResources[i].url, webResources[i].isMaster, webResources[i].isMan ifest, webResources[i].isFallback, | 213 webResources[i].url, webResources[i].isMaster, webResources[i].isMan ifest, webResources[i].isFallback, |
213 webResources[i].isForeign, webResources[i].isExplicit, webResources[ i].size)); | 214 webResources[i].isForeign, webResources[i].isExplicit, webResources[ i].size)); |
214 } | 215 } |
215 } | 216 } |
216 | 217 |
217 void ApplicationCacheHost::stopDeferringEvents() | 218 void ApplicationCacheHost::stopDeferringEvents() |
218 { | 219 { |
219 RefPtr<DocumentLoader> protect(documentLoader()); | 220 RefPtrWillBeRawPtr<DocumentLoader> protect(documentLoader()); |
220 for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { | 221 for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { |
221 const DeferredEvent& deferred = m_deferredEvents[i]; | 222 const DeferredEvent& deferred = m_deferredEvents[i]; |
222 dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.prog ressDone, deferred.errorReason, deferred.errorURL, deferred.errorStatus, deferre d.errorMessage); | 223 dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.prog ressDone, deferred.errorReason, deferred.errorURL, deferred.errorStatus, deferre d.errorMessage); |
223 } | 224 } |
224 m_deferredEvents.clear(); | 225 m_deferredEvents.clear(); |
225 m_defersEvents = false; | 226 m_defersEvents = false; |
226 } | 227 } |
227 | 228 |
228 void ApplicationCacheHost::dispatchDOMEvent(EventID id, int progressTotal, int p rogressDone, WebApplicationCacheHost::ErrorReason errorReason, const String& err orURL, int errorStatus, const String& errorMessage) | 229 void ApplicationCacheHost::dispatchDOMEvent(EventID id, int progressTotal, int p rogressDone, WebApplicationCacheHost::ErrorReason errorReason, const String& err orURL, int errorStatus, const String& errorMessage) |
229 { | 230 { |
230 if (m_domApplicationCache) { | 231 if (!m_domApplicationCache) |
231 const AtomicString& eventType = ApplicationCache::toEventType(id); | 232 return; |
232 RefPtrWillBeRawPtr<Event> event = nullptr; | 233 |
233 if (id == PROGRESS_EVENT) | 234 const AtomicString& eventType = ApplicationCache::toEventType(id); |
234 event = ProgressEvent::create(eventType, true, progressDone, progres sTotal); | 235 RefPtrWillBeRawPtr<Event> event = nullptr; |
235 else if (id == ERROR_EVENT) | 236 if (id == PROGRESS_EVENT) |
236 event = ApplicationCacheErrorEvent::create(errorReason, errorURL, er rorStatus, errorMessage); | 237 event = ProgressEvent::create(eventType, true, progressDone, progressTot al); |
237 else | 238 else if (id == ERROR_EVENT) |
238 event = Event::create(eventType); | 239 event = ApplicationCacheErrorEvent::create(errorReason, errorURL, errorS tatus, errorMessage); |
239 m_domApplicationCache->dispatchEvent(event, ASSERT_NO_EXCEPTION); | 240 else |
240 } | 241 event = Event::create(eventType); |
242 m_domApplicationCache->dispatchEvent(event, ASSERT_NO_EXCEPTION); | |
241 } | 243 } |
242 | 244 |
243 ApplicationCacheHost::Status ApplicationCacheHost::status() const | 245 ApplicationCacheHost::Status ApplicationCacheHost::status() const |
244 { | 246 { |
245 return m_host ? static_cast<Status>(m_host->status()) : UNCACHED; | 247 return m_host ? static_cast<Status>(m_host->status()) : UNCACHED; |
246 } | 248 } |
247 | 249 |
248 bool ApplicationCacheHost::update() | 250 bool ApplicationCacheHost::update() |
249 { | 251 { |
250 return m_host ? m_host->startUpdate() : false; | 252 return m_host ? m_host->startUpdate() : false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 } | 288 } |
287 | 289 |
288 void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::Err orReason reason, const WebURL& url, int status, const WebString& message) | 290 void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::Err orReason reason, const WebURL& url, int status, const WebString& message) |
289 { | 291 { |
290 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess age); | 292 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess age); |
291 } | 293 } |
292 | 294 |
293 DEFINE_TRACE(ApplicationCacheHost) | 295 DEFINE_TRACE(ApplicationCacheHost) |
294 { | 296 { |
295 visitor->trace(m_domApplicationCache); | 297 visitor->trace(m_domApplicationCache); |
298 visitor->trace(m_documentLoader); | |
296 } | 299 } |
297 | 300 |
298 } // namespace blink | 301 } // namespace blink |
OLD | NEW |