| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using blink::WebURL; | 22 using blink::WebURL; |
| 23 using blink::WebURLResponse; | 23 using blink::WebURLResponse; |
| 24 using blink::WebVector; | 24 using blink::WebVector; |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Note: the order of the elements in this array must match those | 30 // Note: the order of the elements in this array must match those |
| 31 // of the EventID enum in appcache_interfaces.h. | 31 // of the EventID enum in appcache_interfaces.h. |
| 32 const char* kEventNames[] = { | 32 const char* const kEventNames[] = { |
| 33 "Checking", "Error", "NoUpdate", "Downloading", "Progress", | 33 "Checking", "Error", "NoUpdate", "Downloading", "Progress", |
| 34 "UpdateReady", "Cached", "Obsolete" | 34 "UpdateReady", "Cached", "Obsolete" |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 typedef IDMap<WebApplicationCacheHostImpl> HostsMap; | 37 typedef IDMap<WebApplicationCacheHostImpl> HostsMap; |
| 38 | 38 |
| 39 HostsMap* all_hosts() { | 39 HostsMap* all_hosts() { |
| 40 static HostsMap* map = new HostsMap; | 40 static HostsMap* map = new HostsMap; |
| 41 return map; | 41 return map; |
| 42 } | 42 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 void WebApplicationCacheHostImpl::OnEventRaised( | 90 void WebApplicationCacheHostImpl::OnEventRaised( |
| 91 AppCacheEventID event_id) { | 91 AppCacheEventID event_id) { |
| 92 DCHECK(event_id != | 92 DCHECK(event_id != |
| 93 APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. | 93 APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. |
| 94 DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. | 94 DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. |
| 95 | 95 |
| 96 // Emit logging output prior to calling out to script as we can get | 96 // Emit logging output prior to calling out to script as we can get |
| 97 // deleted within the script event handler. | 97 // deleted within the script event handler. |
| 98 const char* kFormatString = "Application Cache %s event"; | 98 const char kFormatString[] = "Application Cache %s event"; |
| 99 std::string message = base::StringPrintf(kFormatString, | 99 std::string message = base::StringPrintf(kFormatString, |
| 100 kEventNames[event_id]); | 100 kEventNames[event_id]); |
| 101 OnLogMessage(APPCACHE_LOG_INFO, message); | 101 OnLogMessage(APPCACHE_LOG_INFO, message); |
| 102 | 102 |
| 103 switch (event_id) { | 103 switch (event_id) { |
| 104 case APPCACHE_CHECKING_EVENT: | 104 case APPCACHE_CHECKING_EVENT: |
| 105 status_ = APPCACHE_STATUS_CHECKING; | 105 status_ = APPCACHE_STATUS_CHECKING; |
| 106 break; | 106 break; |
| 107 case APPCACHE_DOWNLOADING_EVENT: | 107 case APPCACHE_DOWNLOADING_EVENT: |
| 108 status_ = APPCACHE_STATUS_DOWNLOADING; | 108 status_ = APPCACHE_STATUS_DOWNLOADING; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 122 break; | 122 break; |
| 123 } | 123 } |
| 124 | 124 |
| 125 client_->notifyEventListener(static_cast<EventID>(event_id)); | 125 client_->notifyEventListener(static_cast<EventID>(event_id)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WebApplicationCacheHostImpl::OnProgressEventRaised( | 128 void WebApplicationCacheHostImpl::OnProgressEventRaised( |
| 129 const GURL& url, int num_total, int num_complete) { | 129 const GURL& url, int num_total, int num_complete) { |
| 130 // Emit logging output prior to calling out to script as we can get | 130 // Emit logging output prior to calling out to script as we can get |
| 131 // deleted within the script event handler. | 131 // deleted within the script event handler. |
| 132 const char* kFormatString = "Application Cache Progress event (%d of %d) %s"; | 132 const char kFormatString[] = "Application Cache Progress event (%d of %d) %s"; |
| 133 std::string message = base::StringPrintf(kFormatString, num_complete, | 133 std::string message = base::StringPrintf(kFormatString, num_complete, |
| 134 num_total, url.spec().c_str()); | 134 num_total, url.spec().c_str()); |
| 135 OnLogMessage(APPCACHE_LOG_INFO, message); | 135 OnLogMessage(APPCACHE_LOG_INFO, message); |
| 136 status_ = APPCACHE_STATUS_DOWNLOADING; | 136 status_ = APPCACHE_STATUS_DOWNLOADING; |
| 137 client_->notifyProgressEventListener(url, num_total, num_complete); | 137 client_->notifyProgressEventListener(url, num_total, num_complete); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void WebApplicationCacheHostImpl::OnErrorEventRaised( | 140 void WebApplicationCacheHostImpl::OnErrorEventRaised( |
| 141 const AppCacheErrorDetails& details) { | 141 const AppCacheErrorDetails& details) { |
| 142 // Emit logging output prior to calling out to script as we can get | 142 // Emit logging output prior to calling out to script as we can get |
| 143 // deleted within the script event handler. | 143 // deleted within the script event handler. |
| 144 const char* kFormatString = "Application Cache Error event: %s"; | 144 const char kFormatString[] = "Application Cache Error event: %s"; |
| 145 std::string full_message = | 145 std::string full_message = |
| 146 base::StringPrintf(kFormatString, details.message.c_str()); | 146 base::StringPrintf(kFormatString, details.message.c_str()); |
| 147 OnLogMessage(APPCACHE_LOG_ERROR, full_message); | 147 OnLogMessage(APPCACHE_LOG_ERROR, full_message); |
| 148 | 148 |
| 149 status_ = cache_info_.is_complete ? APPCACHE_STATUS_IDLE : | 149 status_ = cache_info_.is_complete ? APPCACHE_STATUS_IDLE : |
| 150 APPCACHE_STATUS_UNCACHED; | 150 APPCACHE_STATUS_UNCACHED; |
| 151 if (details.is_cross_origin) { | 151 if (details.is_cross_origin) { |
| 152 // Don't leak detailed information to script for cross-origin resources. | 152 // Don't leak detailed information to script for cross-origin resources. |
| 153 DCHECK_EQ(APPCACHE_RESOURCE_ERROR, details.reason); | 153 DCHECK_EQ(APPCACHE_RESOURCE_ERROR, details.reason); |
| 154 client_->notifyErrorEventListener( | 154 client_->notifyErrorEventListener( |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 web_resources[i].isExplicit = resource_infos[i].is_explicit; | 316 web_resources[i].isExplicit = resource_infos[i].is_explicit; |
| 317 web_resources[i].isManifest = resource_infos[i].is_manifest; | 317 web_resources[i].isManifest = resource_infos[i].is_manifest; |
| 318 web_resources[i].isForeign = resource_infos[i].is_foreign; | 318 web_resources[i].isForeign = resource_infos[i].is_foreign; |
| 319 web_resources[i].isFallback = resource_infos[i].is_fallback; | 319 web_resources[i].isFallback = resource_infos[i].is_fallback; |
| 320 web_resources[i].url = resource_infos[i].url; | 320 web_resources[i].url = resource_infos[i].url; |
| 321 } | 321 } |
| 322 resources->swap(web_resources); | 322 resources->swap(web_resources); |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace content | 325 } // namespace content |
| OLD | NEW |