| 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 was_select_cache_called_(false), |
| 52 is_cache_selection_enabled_(true), | 53 is_cache_selection_enabled_(true), |
| 53 frontend_(frontend), service_(service), | 54 frontend_(frontend), service_(service), |
| 54 storage_(service->storage()), | 55 storage_(service->storage()), |
| 55 pending_callback_param_(NULL), | 56 pending_callback_param_(NULL), |
| 56 main_resource_was_namespace_entry_(false), | 57 main_resource_was_namespace_entry_(false), |
| 57 main_resource_blocked_(false), | 58 main_resource_blocked_(false), |
| 58 associated_cache_info_pending_(false) { | 59 associated_cache_info_pending_(false) { |
| 59 service_->AddObserver(this); | 60 service_->AddObserver(this); |
| 60 } | 61 } |
| 61 | 62 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 void AppCacheHost::RemoveObserver(Observer* observer) { | 79 void AppCacheHost::RemoveObserver(Observer* observer) { |
| 79 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void AppCacheHost::SelectCache(const GURL& document_url, | 83 void AppCacheHost::SelectCache(const GURL& document_url, |
| 83 const int64 cache_document_was_loaded_from, | 84 const int64 cache_document_was_loaded_from, |
| 84 const GURL& manifest_url) { | 85 const GURL& manifest_url) { |
| 85 DCHECK(pending_start_update_callback_.is_null() && | 86 DCHECK(pending_start_update_callback_.is_null() && |
| 86 pending_swap_cache_callback_.is_null() && | 87 pending_swap_cache_callback_.is_null() && |
| 87 pending_get_status_callback_.is_null() && | 88 pending_get_status_callback_.is_null() && |
| 88 !is_selection_pending()); | 89 !is_selection_pending() && !was_select_cache_called_); |
| 89 | 90 |
| 91 was_select_cache_called_ = true; |
| 90 if (!is_cache_selection_enabled_) { | 92 if (!is_cache_selection_enabled_) { |
| 91 FinishCacheSelection(NULL, NULL); | 93 FinishCacheSelection(NULL, NULL); |
| 92 return; | 94 return; |
| 93 } | 95 } |
| 94 | 96 |
| 95 origin_in_use_ = document_url.GetOrigin(); | 97 origin_in_use_ = document_url.GetOrigin(); |
| 96 if (service()->quota_manager_proxy() && !origin_in_use_.is_empty()) | 98 if (service()->quota_manager_proxy() && !origin_in_use_.is_empty()) |
| 97 service()->quota_manager_proxy()->NotifyOriginInUse(origin_in_use_); | 99 service()->quota_manager_proxy()->NotifyOriginInUse(origin_in_use_); |
| 98 | 100 |
| 99 if (main_resource_blocked_) | 101 if (main_resource_blocked_) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // TODO(michaeln): If there was a manifest URL, the user agent may report | 147 // TODO(michaeln): If there was a manifest URL, the user agent may report |
| 146 // to the user that it was ignored, to aid in application development. | 148 // to the user that it was ignored, to aid in application development. |
| 147 FinishCacheSelection(NULL, NULL); | 149 FinishCacheSelection(NULL, NULL); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void AppCacheHost::SelectCacheForWorker(int parent_process_id, | 152 void AppCacheHost::SelectCacheForWorker(int parent_process_id, |
| 151 int parent_host_id) { | 153 int parent_host_id) { |
| 152 DCHECK(pending_start_update_callback_.is_null() && | 154 DCHECK(pending_start_update_callback_.is_null() && |
| 153 pending_swap_cache_callback_.is_null() && | 155 pending_swap_cache_callback_.is_null() && |
| 154 pending_get_status_callback_.is_null() && | 156 pending_get_status_callback_.is_null() && |
| 155 !is_selection_pending()); | 157 !is_selection_pending() && !was_select_cache_called_); |
| 156 | 158 |
| 159 was_select_cache_called_ = true; |
| 157 parent_process_id_ = parent_process_id; | 160 parent_process_id_ = parent_process_id; |
| 158 parent_host_id_ = parent_host_id; | 161 parent_host_id_ = parent_host_id; |
| 159 FinishCacheSelection(NULL, NULL); | 162 FinishCacheSelection(NULL, NULL); |
| 160 } | 163 } |
| 161 | 164 |
| 162 void AppCacheHost::SelectCacheForSharedWorker(int64 appcache_id) { | 165 void AppCacheHost::SelectCacheForSharedWorker(int64 appcache_id) { |
| 163 DCHECK(pending_start_update_callback_.is_null() && | 166 DCHECK(pending_start_update_callback_.is_null() && |
| 164 pending_swap_cache_callback_.is_null() && | 167 pending_swap_cache_callback_.is_null() && |
| 165 pending_get_status_callback_.is_null() && | 168 pending_get_status_callback_.is_null() && |
| 166 !is_selection_pending()); | 169 !is_selection_pending() && !was_select_cache_called_); |
| 167 | 170 |
| 171 was_select_cache_called_ = true; |
| 168 if (appcache_id != kAppCacheNoCacheId) { | 172 if (appcache_id != kAppCacheNoCacheId) { |
| 169 LoadSelectedCache(appcache_id); | 173 LoadSelectedCache(appcache_id); |
| 170 return; | 174 return; |
| 171 } | 175 } |
| 172 FinishCacheSelection(NULL, NULL); | 176 FinishCacheSelection(NULL, NULL); |
| 173 } | 177 } |
| 174 | 178 |
| 175 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency | 179 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency |
| 176 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, | 180 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, |
| 177 int64 cache_document_was_loaded_from) { | 181 int64 cache_document_was_loaded_from) { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 associated_cache_info_pending_ = cache && !cache->is_complete(); | 551 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 548 AppCacheInfo info; | 552 AppCacheInfo info; |
| 549 if (cache) | 553 if (cache) |
| 550 cache->AssociateHost(this); | 554 cache->AssociateHost(this); |
| 551 | 555 |
| 552 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 556 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
| 553 frontend_->OnCacheSelected(host_id_, info); | 557 frontend_->OnCacheSelected(host_id_, info); |
| 554 } | 558 } |
| 555 | 559 |
| 556 } // namespace content | 560 } // namespace content |
| OLD | NEW |