| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 using namespace blink; | 55 using namespace blink; |
| 56 | 56 |
| 57 namespace blink { | 57 namespace blink { |
| 58 | 58 |
| 59 // We provide a custom implementation of this class that calls out to the | 59 // We provide a custom implementation of this class that calls out to the |
| 60 // embedding application instead of using WebCore's built in appcache system. | 60 // embedding application instead of using WebCore's built in appcache system. |
| 61 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. | 61 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. |
| 62 | 62 |
| 63 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) | 63 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) |
| 64 : m_domApplicationCache(0) | 64 : m_domApplicationCache(nullptr) |
| 65 , m_documentLoader(documentLoader) | 65 , m_documentLoader(documentLoader) |
| 66 , m_defersEvents(true) | 66 , m_defersEvents(true) |
| 67 { | 67 { |
| 68 ASSERT(m_documentLoader); | 68 ASSERT(m_documentLoader); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ApplicationCacheHost::~ApplicationCacheHost() | 71 ApplicationCacheHost::~ApplicationCacheHost() |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 m_host->selectCacheWithoutManifest(); | 111 m_host->selectCacheWithoutManifest(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL) | 114 void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL) |
| 115 { | 115 { |
| 116 if (m_host && !m_host->selectCacheWithManifest(manifestURL)) { | 116 if (m_host && !m_host->selectCacheWithManifest(manifestURL)) { |
| 117 // It's a foreign entry, restart the current navigation from the top | 117 // It's a foreign entry, restart the current navigation from the top |
| 118 // of the navigation algorithm. The navigation will not result in the | 118 // of the navigation algorithm. The navigation will not result in the |
| 119 // same resource being loaded, because "foreign" entries are never picke
d | 119 // same resource being loaded, because "foreign" entries are never picke
d |
| 120 // during navigation. | 120 // during navigation. |
| 121 // see blink::ApplicationCacheGroup::selectCache() | 121 // see ApplicationCacheGroup::selectCache() |
| 122 LocalFrame* frame = m_documentLoader->frame(); | 122 LocalFrame* frame = m_documentLoader->frame(); |
| 123 frame->navigationScheduler().scheduleLocationChange(frame->document(), f
rame->document()->url(), Referrer(frame->document()->referrer(), frame->document
()->referrerPolicy())); | 123 frame->navigationScheduler().scheduleLocationChange(frame->document(), f
rame->document()->url(), Referrer(frame->document()->referrer(), frame->document
()->referrerPolicy())); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ApplicationCacheHost::didReceiveResponseForMainResource(const ResourceRespo
nse& response) | 127 void ApplicationCacheHost::didReceiveResponseForMainResource(const ResourceRespo
nse& response) |
| 128 { | 128 { |
| 129 if (m_host) { | 129 if (m_host) { |
| 130 WrappedResourceResponse wrapped(response); | 130 WrappedResourceResponse wrapped(response); |
| 131 m_host->didReceiveResponseForMainResource(wrapped); | 131 m_host->didReceiveResponseForMainResource(wrapped); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 157 m_host->willStartSubResourceRequest(wrapped); | 157 m_host->willStartSubResourceRequest(wrapped); |
| 158 } | 158 } |
| 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::notifyApplicationCache(EventID id, int progressTotal,
int progressDone, blink::WebApplicationCacheHost::ErrorReason errorReason, cons
t String& errorURL, int errorStatus, const String& errorMessage) | 167 void ApplicationCacheHost::notifyApplicationCache(EventID id, int progressTotal,
int progressDone, WebApplicationCacheHost::ErrorReason errorReason, const Strin
g& errorURL, int errorStatus, const String& errorMessage) |
| 168 { | 168 { |
| 169 if (id != PROGRESS_EVENT) | 169 if (id != PROGRESS_EVENT) |
| 170 InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader-
>frame()); | 170 InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader-
>frame()); |
| 171 | 171 |
| 172 if (m_defersEvents) { | 172 if (m_defersEvents) { |
| 173 // Event dispatching is deferred until document.onload has fired. | 173 // Event dispatching is deferred until document.onload has fired. |
| 174 m_deferredEvents.append(DeferredEvent(id, progressTotal, progressDone, e
rrorReason, errorURL, errorStatus, errorMessage)); | 174 m_deferredEvents.append(DeferredEvent(id, progressTotal, progressDone, e
rrorReason, errorURL, errorStatus, errorMessage)); |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 dispatchDOMEvent(id, progressTotal, progressDone, errorReason, errorURL, err
orStatus, errorMessage); | 177 dispatchDOMEvent(id, progressTotal, progressDone, errorReason, errorURL, err
orStatus, errorMessage); |
| 178 } | 178 } |
| 179 | 179 |
| 180 ApplicationCacheHost::CacheInfo ApplicationCacheHost::applicationCacheInfo() | 180 ApplicationCacheHost::CacheInfo ApplicationCacheHost::applicationCacheInfo() |
| 181 { | 181 { |
| 182 if (!m_host) | 182 if (!m_host) |
| 183 return CacheInfo(KURL(), 0, 0, 0); | 183 return CacheInfo(KURL(), 0, 0, 0); |
| 184 | 184 |
| 185 blink::WebApplicationCacheHost::CacheInfo webInfo; | 185 WebApplicationCacheHost::CacheInfo webInfo; |
| 186 m_host->getAssociatedCacheInfo(&webInfo); | 186 m_host->getAssociatedCacheInfo(&webInfo); |
| 187 return CacheInfo(webInfo.manifestURL, webInfo.creationTime, webInfo.updateTi
me, webInfo.totalSize); | 187 return CacheInfo(webInfo.manifestURL, webInfo.creationTime, webInfo.updateTi
me, webInfo.totalSize); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ApplicationCacheHost::fillResourceList(ResourceInfoList* resources) | 190 void ApplicationCacheHost::fillResourceList(ResourceInfoList* resources) |
| 191 { | 191 { |
| 192 if (!m_host) | 192 if (!m_host) |
| 193 return; | 193 return; |
| 194 | 194 |
| 195 blink::WebVector<blink::WebApplicationCacheHost::ResourceInfo> webResources; | 195 WebVector<WebApplicationCacheHost::ResourceInfo> webResources; |
| 196 m_host->getResourceList(&webResources); | 196 m_host->getResourceList(&webResources); |
| 197 for (size_t i = 0; i < webResources.size(); ++i) { | 197 for (size_t i = 0; i < webResources.size(); ++i) { |
| 198 resources->append(ResourceInfo( | 198 resources->append(ResourceInfo( |
| 199 webResources[i].url, webResources[i].isMaster, webResources[i].isMan
ifest, webResources[i].isFallback, | 199 webResources[i].url, webResources[i].isMaster, webResources[i].isMan
ifest, webResources[i].isFallback, |
| 200 webResources[i].isForeign, webResources[i].isExplicit, webResources[
i].size)); | 200 webResources[i].isForeign, webResources[i].isExplicit, webResources[
i].size)); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 void ApplicationCacheHost::stopDeferringEvents() | 204 void ApplicationCacheHost::stopDeferringEvents() |
| 205 { | 205 { |
| 206 RefPtr<DocumentLoader> protect(documentLoader()); | 206 RefPtr<DocumentLoader> protect(documentLoader()); |
| 207 for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { | 207 for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { |
| 208 const DeferredEvent& deferred = m_deferredEvents[i]; | 208 const DeferredEvent& deferred = m_deferredEvents[i]; |
| 209 dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.prog
ressDone, deferred.errorReason, deferred.errorURL, deferred.errorStatus, deferre
d.errorMessage); | 209 dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.prog
ressDone, deferred.errorReason, deferred.errorURL, deferred.errorStatus, deferre
d.errorMessage); |
| 210 } | 210 } |
| 211 m_deferredEvents.clear(); | 211 m_deferredEvents.clear(); |
| 212 m_defersEvents = false; | 212 m_defersEvents = false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ApplicationCacheHost::dispatchDOMEvent(EventID id, int progressTotal, int p
rogressDone, blink::WebApplicationCacheHost::ErrorReason errorReason, const Stri
ng& errorURL, int errorStatus, const String& errorMessage) | 215 void ApplicationCacheHost::dispatchDOMEvent(EventID id, int progressTotal, int p
rogressDone, WebApplicationCacheHost::ErrorReason errorReason, const String& err
orURL, int errorStatus, const String& errorMessage) |
| 216 { | 216 { |
| 217 if (m_domApplicationCache) { | 217 if (m_domApplicationCache) { |
| 218 const AtomicString& eventType = ApplicationCache::toEventType(id); | 218 const AtomicString& eventType = ApplicationCache::toEventType(id); |
| 219 RefPtrWillBeRawPtr<Event> event = nullptr; | 219 RefPtrWillBeRawPtr<Event> event = nullptr; |
| 220 if (id == PROGRESS_EVENT) | 220 if (id == PROGRESS_EVENT) |
| 221 event = ProgressEvent::create(eventType, true, progressDone, progres
sTotal); | 221 event = ProgressEvent::create(eventType, true, progressDone, progres
sTotal); |
| 222 else if (id == ERROR_EVENT) | 222 else if (id == ERROR_EVENT) |
| 223 event = ApplicationCacheErrorEvent::create(errorReason, errorURL, er
rorStatus, errorMessage); | 223 event = ApplicationCacheErrorEvent::create(errorReason, errorURL, er
rorStatus, errorMessage); |
| 224 else | 224 else |
| 225 event = Event::create(eventType); | 225 event = Event::create(eventType); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 255 { | 255 { |
| 256 ASSERT(m_documentLoader->frame()); | 256 ASSERT(m_documentLoader->frame()); |
| 257 return m_documentLoader->frame()->settings() && m_documentLoader->frame()->s
ettings()->offlineWebApplicationCacheEnabled(); | 257 return m_documentLoader->frame()->settings() && m_documentLoader->frame()->s
ettings()->offlineWebApplicationCacheEnabled(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void ApplicationCacheHost::didChangeCacheAssociation() | 260 void ApplicationCacheHost::didChangeCacheAssociation() |
| 261 { | 261 { |
| 262 // FIXME: Prod the inspector to update its notion of what cache the page is
using. | 262 // FIXME: Prod the inspector to update its notion of what cache the page is
using. |
| 263 } | 263 } |
| 264 | 264 |
| 265 void ApplicationCacheHost::notifyEventListener(blink::WebApplicationCacheHost::E
ventID eventID) | 265 void ApplicationCacheHost::notifyEventListener(WebApplicationCacheHost::EventID
eventID) |
| 266 { | 266 { |
| 267 notifyApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID),
0, 0, blink::WebApplicationCacheHost::UnknownError, String(), 0, String()); | 267 notifyApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID),
0, 0, WebApplicationCacheHost::UnknownError, String(), 0, String()); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void ApplicationCacheHost::notifyProgressEventListener(const blink::WebURL&, int
progressTotal, int progressDone) | 270 void ApplicationCacheHost::notifyProgressEventListener(const WebURL&, int progre
ssTotal, int progressDone) |
| 271 { | 271 { |
| 272 notifyApplicationCache(PROGRESS_EVENT, progressTotal, progressDone, blink::W
ebApplicationCacheHost::UnknownError, String(), 0, String()); | 272 notifyApplicationCache(PROGRESS_EVENT, progressTotal, progressDone, WebAppli
cationCacheHost::UnknownError, String(), 0, String()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void ApplicationCacheHost::notifyErrorEventListener(blink::WebApplicationCacheHo
st::ErrorReason reason, const blink::WebURL& url, int status, const blink::WebSt
ring& message) | 275 void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::Err
orReason reason, const WebURL& url, int status, const WebString& message) |
| 276 { | 276 { |
| 277 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess
age); | 277 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess
age); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void ApplicationCacheHost::trace(Visitor* visitor) |
| 281 { |
| 282 visitor->trace(m_domApplicationCache); |
| 283 } |
| 284 |
| 280 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |