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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/browser/appcache/appcache.h" | 10 #include "content/browser/appcache/appcache.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 } // Anonymous namespace | 43 } // Anonymous namespace |
44 | 44 |
45 AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, | 45 AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, |
46 AppCacheServiceImpl* service) | 46 AppCacheServiceImpl* service) |
47 : host_id_(host_id), | 47 : host_id_(host_id), |
48 spawning_host_id_(kAppCacheNoHostId), spawning_process_id_(0), | 48 spawning_host_id_(kAppCacheNoHostId), spawning_process_id_(0), |
49 parent_host_id_(kAppCacheNoHostId), parent_process_id_(0), | 49 parent_host_id_(kAppCacheNoHostId), parent_process_id_(0), |
50 pending_main_resource_cache_id_(kAppCacheNoCacheId), | 50 pending_main_resource_cache_id_(kAppCacheNoCacheId), |
51 pending_selected_cache_id_(kAppCacheNoCacheId), | 51 pending_selected_cache_id_(kAppCacheNoCacheId), |
| 52 is_cache_selection_enabled_(true), |
52 frontend_(frontend), service_(service), | 53 frontend_(frontend), service_(service), |
53 storage_(service->storage()), | 54 storage_(service->storage()), |
54 pending_callback_param_(NULL), | 55 pending_callback_param_(NULL), |
55 main_resource_was_namespace_entry_(false), | 56 main_resource_was_namespace_entry_(false), |
56 main_resource_blocked_(false), | 57 main_resource_blocked_(false), |
57 associated_cache_info_pending_(false) { | 58 associated_cache_info_pending_(false) { |
58 service_->AddObserver(this); | 59 service_->AddObserver(this); |
59 } | 60 } |
60 | 61 |
61 AppCacheHost::~AppCacheHost() { | 62 AppCacheHost::~AppCacheHost() { |
(...skipping 17 matching lines...) Expand all Loading... |
79 } | 80 } |
80 | 81 |
81 void AppCacheHost::SelectCache(const GURL& document_url, | 82 void AppCacheHost::SelectCache(const GURL& document_url, |
82 const int64 cache_document_was_loaded_from, | 83 const int64 cache_document_was_loaded_from, |
83 const GURL& manifest_url) { | 84 const GURL& manifest_url) { |
84 DCHECK(pending_start_update_callback_.is_null() && | 85 DCHECK(pending_start_update_callback_.is_null() && |
85 pending_swap_cache_callback_.is_null() && | 86 pending_swap_cache_callback_.is_null() && |
86 pending_get_status_callback_.is_null() && | 87 pending_get_status_callback_.is_null() && |
87 !is_selection_pending()); | 88 !is_selection_pending()); |
88 | 89 |
| 90 if (!is_cache_selection_enabled_) { |
| 91 FinishCacheSelection(NULL, NULL); |
| 92 return; |
| 93 } |
| 94 |
89 origin_in_use_ = document_url.GetOrigin(); | 95 origin_in_use_ = document_url.GetOrigin(); |
90 if (service()->quota_manager_proxy() && !origin_in_use_.is_empty()) | 96 if (service()->quota_manager_proxy() && !origin_in_use_.is_empty()) |
91 service()->quota_manager_proxy()->NotifyOriginInUse(origin_in_use_); | 97 service()->quota_manager_proxy()->NotifyOriginInUse(origin_in_use_); |
92 | 98 |
93 if (main_resource_blocked_) | 99 if (main_resource_blocked_) |
94 frontend_->OnContentBlocked(host_id_, | 100 frontend_->OnContentBlocked(host_id_, |
95 blocked_manifest_url_); | 101 blocked_manifest_url_); |
96 | 102 |
97 // 6.9.6 The application cache selection algorithm. | 103 // 6.9.6 The application cache selection algorithm. |
98 // The algorithm is started here and continues in FinishCacheSelection, | 104 // The algorithm is started here and continues in FinishCacheSelection, |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 associated_cache_info_pending_ = cache && !cache->is_complete(); | 543 associated_cache_info_pending_ = cache && !cache->is_complete(); |
538 AppCacheInfo info; | 544 AppCacheInfo info; |
539 if (cache) | 545 if (cache) |
540 cache->AssociateHost(this); | 546 cache->AssociateHost(this); |
541 | 547 |
542 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 548 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
543 frontend_->OnCacheSelected(host_id_, info); | 549 frontend_->OnCacheSelected(host_id_, info); |
544 } | 550 } |
545 | 551 |
546 } // namespace content | 552 } // namespace content |
OLD | NEW |