| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/child/appcache/web_application_cache_host_impl.h" | 5 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "third_party/WebKit/public/platform/WebString.h" |
| 11 #include "third_party/WebKit/public/platform/WebURL.h" | 12 #include "third_party/WebKit/public/platform/WebURL.h" |
| 12 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 13 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 13 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 14 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 14 | 15 |
| 15 using blink::WebApplicationCacheHost; | 16 using blink::WebApplicationCacheHost; |
| 16 using blink::WebApplicationCacheHostClient; | 17 using blink::WebApplicationCacheHostClient; |
| 18 using blink::WebString; |
| 17 using blink::WebURLRequest; | 19 using blink::WebURLRequest; |
| 18 using blink::WebURL; | 20 using blink::WebURL; |
| 19 using blink::WebURLResponse; | 21 using blink::WebURLResponse; |
| 20 using blink::WebVector; | 22 using blink::WebVector; |
| 21 using appcache::AppCacheBackend; | 23 using appcache::AppCacheBackend; |
| 22 using appcache::AppCacheResourceInfo; | 24 using appcache::AppCacheResourceInfo; |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Emit logging output prior to calling out to script as we can get | 127 // Emit logging output prior to calling out to script as we can get |
| 126 // deleted within the script event handler. | 128 // deleted within the script event handler. |
| 127 const char* kFormatString = "Application Cache Progress event (%d of %d) %s"; | 129 const char* kFormatString = "Application Cache Progress event (%d of %d) %s"; |
| 128 std::string message = base::StringPrintf(kFormatString, num_complete, | 130 std::string message = base::StringPrintf(kFormatString, num_complete, |
| 129 num_total, url.spec().c_str()); | 131 num_total, url.spec().c_str()); |
| 130 OnLogMessage(appcache::LOG_INFO, message); | 132 OnLogMessage(appcache::LOG_INFO, message); |
| 131 status_ = appcache::DOWNLOADING; | 133 status_ = appcache::DOWNLOADING; |
| 132 client_->notifyProgressEventListener(url, num_total, num_complete); | 134 client_->notifyProgressEventListener(url, num_total, num_complete); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void WebApplicationCacheHostImpl::OnErrorEventRaised( | 137 void WebApplicationCacheHostImpl::OnErrorEventRaised(const std::string& message, |
| 136 const std::string& message) { | 138 const std::string& reason, |
| 139 const GURL& url, |
| 140 int status) { |
| 137 // Emit logging output prior to calling out to script as we can get | 141 // Emit logging output prior to calling out to script as we can get |
| 138 // deleted within the script event handler. | 142 // deleted within the script event handler. |
| 139 const char* kFormatString = "Application Cache Error event: %s"; | 143 const char* kFormatString = "Application Cache Error event: %s"; |
| 140 std::string full_message = base::StringPrintf(kFormatString, | 144 std::string full_message = base::StringPrintf(kFormatString, |
| 141 message.c_str()); | 145 message.c_str()); |
| 142 OnLogMessage(appcache::LOG_ERROR, full_message); | 146 OnLogMessage(appcache::LOG_ERROR, full_message); |
| 143 | 147 |
| 144 status_ = cache_info_.is_complete ? appcache::IDLE : appcache::UNCACHED; | 148 status_ = cache_info_.is_complete ? appcache::IDLE : appcache::UNCACHED; |
| 145 client_->notifyEventListener(static_cast<EventID>(appcache::ERROR_EVENT)); | 149 client_->notifyErrorEventListener(WebString::fromUTF8(reason), url, status); |
| 146 } | 150 } |
| 147 | 151 |
| 148 void WebApplicationCacheHostImpl::willStartMainResourceRequest( | 152 void WebApplicationCacheHostImpl::willStartMainResourceRequest( |
| 149 WebURLRequest& request, const WebApplicationCacheHost* spawning_host) { | 153 WebURLRequest& request, const WebApplicationCacheHost* spawning_host) { |
| 150 request.setAppCacheHostID(host_id_); | 154 request.setAppCacheHostID(host_id_); |
| 151 | 155 |
| 152 original_main_resource_url_ = ClearUrlRef(request.url()); | 156 original_main_resource_url_ = ClearUrlRef(request.url()); |
| 153 | 157 |
| 154 std::string method = request.httpMethod().utf8(); | 158 std::string method = request.httpMethod().utf8(); |
| 155 is_get_method_ = (method == appcache::kHttpGETMethod); | 159 is_get_method_ = (method == appcache::kHttpGETMethod); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 web_resources[i].isExplicit = resource_infos[i].is_explicit; | 303 web_resources[i].isExplicit = resource_infos[i].is_explicit; |
| 300 web_resources[i].isManifest = resource_infos[i].is_manifest; | 304 web_resources[i].isManifest = resource_infos[i].is_manifest; |
| 301 web_resources[i].isForeign = resource_infos[i].is_foreign; | 305 web_resources[i].isForeign = resource_infos[i].is_foreign; |
| 302 web_resources[i].isFallback = resource_infos[i].is_fallback; | 306 web_resources[i].isFallback = resource_infos[i].is_fallback; |
| 303 web_resources[i].url = resource_infos[i].url; | 307 web_resources[i].url = resource_infos[i].url; |
| 304 } | 308 } |
| 305 resources->swap(web_resources); | 309 resources->swap(web_resources); |
| 306 } | 310 } |
| 307 | 311 |
| 308 } // namespace content | 312 } // namespace content |
| OLD | NEW |