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 "content/browser/appcache/appcache_host.h" | 5 #include "content/browser/appcache/appcache_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.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 "content/browser/appcache/appcache.h" | 11 #include "content/browser/appcache/appcache.h" |
12 #include "content/browser/appcache/appcache_backend_impl.h" | 12 #include "content/browser/appcache/appcache_backend_impl.h" |
13 #include "content/browser/appcache/appcache_policy.h" | 13 #include "content/browser/appcache/appcache_policy.h" |
| 14 #include "content/browser/appcache/appcache_request.h" |
14 #include "content/browser/appcache/appcache_request_handler.h" | 15 #include "content/browser/appcache/appcache_request_handler.h" |
15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
16 #include "storage/browser/quota/quota_manager_proxy.h" | 17 #include "storage/browser/quota/quota_manager_proxy.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 void FillCacheInfo(const AppCache* cache, | 23 void FillCacheInfo(const AppCache* cache, |
23 const GURL& manifest_url, | 24 const GURL& manifest_url, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 return backend ? backend->GetHost(spawning_host_id_) : NULL; | 306 return backend ? backend->GetHost(spawning_host_id_) : NULL; |
306 } | 307 } |
307 | 308 |
308 AppCacheHost* AppCacheHost::GetParentAppCacheHost() const { | 309 AppCacheHost* AppCacheHost::GetParentAppCacheHost() const { |
309 DCHECK(is_for_dedicated_worker()); | 310 DCHECK(is_for_dedicated_worker()); |
310 AppCacheBackendImpl* backend = service_->GetBackend(parent_process_id_); | 311 AppCacheBackendImpl* backend = service_->GetBackend(parent_process_id_); |
311 return backend ? backend->GetHost(parent_host_id_) : NULL; | 312 return backend ? backend->GetHost(parent_host_id_) : NULL; |
312 } | 313 } |
313 | 314 |
314 std::unique_ptr<AppCacheRequestHandler> AppCacheHost::CreateRequestHandler( | 315 std::unique_ptr<AppCacheRequestHandler> AppCacheHost::CreateRequestHandler( |
315 net::URLRequest* request, | 316 AppCacheRequest* request, |
316 ResourceType resource_type, | 317 ResourceType resource_type, |
317 bool should_reset_appcache) { | 318 bool should_reset_appcache) { |
318 if (is_for_dedicated_worker()) { | 319 if (is_for_dedicated_worker()) { |
319 AppCacheHost* parent_host = GetParentAppCacheHost(); | 320 AppCacheHost* parent_host = GetParentAppCacheHost(); |
320 if (parent_host) | 321 if (parent_host) |
321 return parent_host->CreateRequestHandler( | 322 return parent_host->CreateRequestHandler( |
322 request, resource_type, should_reset_appcache); | 323 request, resource_type, should_reset_appcache); |
323 return NULL; | 324 return NULL; |
324 } | 325 } |
325 | 326 |
326 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) { | 327 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) { |
327 // Store the first party origin so that it can be used later in SelectCache | 328 // Store the first party origin so that it can be used later in SelectCache |
328 // for checking whether the creation of the appcache is allowed. | 329 // for checking whether the creation of the appcache is allowed. |
329 first_party_url_ = request->first_party_for_cookies(); | 330 first_party_url_ = request->GetFirstPartyForCookies(); |
330 return base::WrapUnique( | 331 return base::WrapUnique(new AppCacheRequestHandler( |
331 new AppCacheRequestHandler(this, resource_type, should_reset_appcache)); | 332 this, resource_type, should_reset_appcache, request)); |
332 } | 333 } |
333 | 334 |
334 if ((associated_cache() && associated_cache()->is_complete()) || | 335 if ((associated_cache() && associated_cache()->is_complete()) || |
335 is_selection_pending()) { | 336 is_selection_pending()) { |
336 return base::WrapUnique( | 337 return base::WrapUnique(new AppCacheRequestHandler( |
337 new AppCacheRequestHandler(this, resource_type, should_reset_appcache)); | 338 this, resource_type, should_reset_appcache, request)); |
338 } | 339 } |
339 return NULL; | 340 return NULL; |
340 } | 341 } |
341 | 342 |
342 void AppCacheHost::GetResourceList( | 343 void AppCacheHost::GetResourceList( |
343 AppCacheResourceInfoVector* resource_infos) { | 344 AppCacheResourceInfoVector* resource_infos) { |
344 if (associated_cache_.get() && associated_cache_->is_complete()) | 345 if (associated_cache_.get() && associated_cache_->is_complete()) |
345 associated_cache_->ToResourceInfoVector(resource_infos); | 346 associated_cache_->ToResourceInfoVector(resource_infos); |
346 } | 347 } |
347 | 348 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 associated_cache_info_pending_ = cache && !cache->is_complete(); | 571 associated_cache_info_pending_ = cache && !cache->is_complete(); |
571 AppCacheInfo info; | 572 AppCacheInfo info; |
572 if (cache) | 573 if (cache) |
573 cache->AssociateHost(this); | 574 cache->AssociateHost(this); |
574 | 575 |
575 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 576 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
576 frontend_->OnCacheSelected(host_id_, info); | 577 frontend_->OnCacheSelected(host_id_, info); |
577 } | 578 } |
578 | 579 |
579 } // namespace content | 580 } // namespace content |
OLD | NEW |