| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/appcache/web_application_cache_host_impl.h" | 5 #include "webkit/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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return url.ReplaceComponents(replacements); | 46 return url.ReplaceComponents(replacements); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // anon namespace | 49 } // anon namespace |
| 50 | 50 |
| 51 WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) { | 51 WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) { |
| 52 return g_hosts_map.Get().Lookup(id); | 52 return g_hosts_map.Get().Lookup(id); |
| 53 } | 53 } |
| 54 | 54 |
| 55 WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromFrame( | 55 WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromFrame( |
| 56 WebFrame* frame) { | 56 const WebFrame* frame) { |
| 57 if (!frame) | 57 if (!frame) |
| 58 return NULL; | 58 return NULL; |
| 59 WebDataSource* data_source = frame->dataSource(); | 59 WebDataSource* data_source = frame->dataSource(); |
| 60 if (!data_source) | 60 if (!data_source) |
| 61 return NULL; | 61 return NULL; |
| 62 return static_cast<WebApplicationCacheHostImpl*> | 62 return static_cast<WebApplicationCacheHostImpl*> |
| 63 (data_source->applicationCacheHost()); | 63 (data_source->applicationCacheHost()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( | 66 WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 WebURLRequest& request, const WebFrame* frame) { | 159 WebURLRequest& request, const WebFrame* frame) { |
| 160 request.setAppCacheHostID(host_id_); | 160 request.setAppCacheHostID(host_id_); |
| 161 | 161 |
| 162 original_main_resource_url_ = ClearUrlRef(request.url()); | 162 original_main_resource_url_ = ClearUrlRef(request.url()); |
| 163 | 163 |
| 164 std::string method = request.httpMethod().utf8(); | 164 std::string method = request.httpMethod().utf8(); |
| 165 is_get_method_ = (method == kHttpGETMethod); | 165 is_get_method_ = (method == kHttpGETMethod); |
| 166 DCHECK(method == StringToUpperASCII(method)); | 166 DCHECK(method == StringToUpperASCII(method)); |
| 167 | 167 |
| 168 if (frame) { | 168 if (frame) { |
| 169 if (WebApplicationCacheHostImpl* parent = FromFrame(frame->parent())) | 169 const WebFrame* spawning_frame = frame->parent(); |
| 170 backend_->SetSpawningHostId(host_id_, parent->host_id()); | 170 if (!spawning_frame) |
| 171 else if (WebApplicationCacheHostImpl* opener = FromFrame(frame->opener())) | 171 spawning_frame = frame->opener(); |
| 172 backend_->SetSpawningHostId(host_id_, opener->host_id()); | 172 if (!spawning_frame) |
| 173 spawning_frame = frame; |
| 174 |
| 175 WebApplicationCacheHostImpl* spawning_host = FromFrame(spawning_frame); |
| 176 if (spawning_host && (spawning_host != this)) |
| 177 backend_->SetSpawningHostId(host_id_, spawning_host->host_id()); |
| 173 } | 178 } |
| 174 } | 179 } |
| 175 | 180 |
| 176 void WebApplicationCacheHostImpl::willStartSubResourceRequest( | 181 void WebApplicationCacheHostImpl::willStartSubResourceRequest( |
| 177 WebURLRequest& request) { | 182 WebURLRequest& request) { |
| 178 request.setAppCacheHostID(host_id_); | 183 request.setAppCacheHostID(host_id_); |
| 179 } | 184 } |
| 180 | 185 |
| 181 void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { | 186 void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { |
| 182 if (was_select_cache_called_) | 187 if (was_select_cache_called_) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 web_resources[i].isExplicit = resource_infos[i].is_explicit; | 314 web_resources[i].isExplicit = resource_infos[i].is_explicit; |
| 310 web_resources[i].isManifest = resource_infos[i].is_manifest; | 315 web_resources[i].isManifest = resource_infos[i].is_manifest; |
| 311 web_resources[i].isForeign = resource_infos[i].is_foreign; | 316 web_resources[i].isForeign = resource_infos[i].is_foreign; |
| 312 web_resources[i].isFallback = resource_infos[i].is_fallback; | 317 web_resources[i].isFallback = resource_infos[i].is_fallback; |
| 313 web_resources[i].url = resource_infos[i].url; | 318 web_resources[i].url = resource_infos[i].url; |
| 314 } | 319 } |
| 315 resources->swap(web_resources); | 320 resources->swap(web_resources); |
| 316 } | 321 } |
| 317 | 322 |
| 318 } // appcache namespace | 323 } // appcache namespace |
| OLD | NEW |