| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 void AppCacheHost::AddObserver(Observer* observer) { | 75 void AppCacheHost::AddObserver(Observer* observer) { |
| 76 observers_.AddObserver(observer); | 76 observers_.AddObserver(observer); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void AppCacheHost::RemoveObserver(Observer* observer) { | 79 void AppCacheHost::RemoveObserver(Observer* observer) { |
| 80 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool AppCacheHost::SelectCache(const GURL& document_url, | 83 bool AppCacheHost::SelectCache(const GURL& document_url, |
| 84 const int64 cache_document_was_loaded_from, | 84 const int64_t cache_document_was_loaded_from, |
| 85 const GURL& manifest_url) { | 85 const GURL& manifest_url) { |
| 86 if (was_select_cache_called_) | 86 if (was_select_cache_called_) |
| 87 return false; | 87 return false; |
| 88 | 88 |
| 89 DCHECK(pending_start_update_callback_.is_null() && | 89 DCHECK(pending_start_update_callback_.is_null() && |
| 90 pending_swap_cache_callback_.is_null() && | 90 pending_swap_cache_callback_.is_null() && |
| 91 pending_get_status_callback_.is_null() && | 91 pending_get_status_callback_.is_null() && |
| 92 !is_selection_pending()); | 92 !is_selection_pending()); |
| 93 | 93 |
| 94 was_select_cache_called_ = true; | 94 was_select_cache_called_ = true; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 pending_get_status_callback_.is_null() && | 163 pending_get_status_callback_.is_null() && |
| 164 !is_selection_pending()); | 164 !is_selection_pending()); |
| 165 | 165 |
| 166 was_select_cache_called_ = true; | 166 was_select_cache_called_ = true; |
| 167 parent_process_id_ = parent_process_id; | 167 parent_process_id_ = parent_process_id; |
| 168 parent_host_id_ = parent_host_id; | 168 parent_host_id_ = parent_host_id; |
| 169 FinishCacheSelection(NULL, NULL); | 169 FinishCacheSelection(NULL, NULL); |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool AppCacheHost::SelectCacheForSharedWorker(int64 appcache_id) { | 173 bool AppCacheHost::SelectCacheForSharedWorker(int64_t appcache_id) { |
| 174 if (was_select_cache_called_) | 174 if (was_select_cache_called_) |
| 175 return false; | 175 return false; |
| 176 | 176 |
| 177 DCHECK(pending_start_update_callback_.is_null() && | 177 DCHECK(pending_start_update_callback_.is_null() && |
| 178 pending_swap_cache_callback_.is_null() && | 178 pending_swap_cache_callback_.is_null() && |
| 179 pending_get_status_callback_.is_null() && | 179 pending_get_status_callback_.is_null() && |
| 180 !is_selection_pending()); | 180 !is_selection_pending()); |
| 181 | 181 |
| 182 was_select_cache_called_ = true; | 182 was_select_cache_called_ = true; |
| 183 if (appcache_id != kAppCacheNoCacheId) { | 183 if (appcache_id != kAppCacheNoCacheId) { |
| 184 LoadSelectedCache(appcache_id); | 184 LoadSelectedCache(appcache_id); |
| 185 return true; | 185 return true; |
| 186 } | 186 } |
| 187 FinishCacheSelection(NULL, NULL); | 187 FinishCacheSelection(NULL, NULL); |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 | 190 |
| 191 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency | 191 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency |
| 192 bool AppCacheHost::MarkAsForeignEntry(const GURL& document_url, | 192 bool AppCacheHost::MarkAsForeignEntry(const GURL& document_url, |
| 193 int64 cache_document_was_loaded_from) { | 193 int64_t cache_document_was_loaded_from) { |
| 194 if (was_select_cache_called_) | 194 if (was_select_cache_called_) |
| 195 return false; | 195 return false; |
| 196 | 196 |
| 197 // The document url is not the resource url in the fallback case. | 197 // The document url is not the resource url in the fallback case. |
| 198 storage()->MarkEntryAsForeign( | 198 storage()->MarkEntryAsForeign( |
| 199 main_resource_was_namespace_entry_ ? namespace_entry_url_ : document_url, | 199 main_resource_was_namespace_entry_ ? namespace_entry_url_ : document_url, |
| 200 cache_document_was_loaded_from); | 200 cache_document_was_loaded_from); |
| 201 SelectCache(document_url, kAppCacheNoCacheId, GURL()); | 201 SelectCache(document_url, kAppCacheNoCacheId, GURL()); |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 storage()->LoadOrCreateGroup(manifest_url, this); | 371 storage()->LoadOrCreateGroup(manifest_url, this); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void AppCacheHost::OnGroupLoaded(AppCacheGroup* group, | 374 void AppCacheHost::OnGroupLoaded(AppCacheGroup* group, |
| 375 const GURL& manifest_url) { | 375 const GURL& manifest_url) { |
| 376 DCHECK(manifest_url == pending_selected_manifest_url_); | 376 DCHECK(manifest_url == pending_selected_manifest_url_); |
| 377 pending_selected_manifest_url_ = GURL(); | 377 pending_selected_manifest_url_ = GURL(); |
| 378 FinishCacheSelection(NULL, group); | 378 FinishCacheSelection(NULL, group); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void AppCacheHost::LoadSelectedCache(int64 cache_id) { | 381 void AppCacheHost::LoadSelectedCache(int64_t cache_id) { |
| 382 DCHECK(cache_id != kAppCacheNoCacheId); | 382 DCHECK(cache_id != kAppCacheNoCacheId); |
| 383 pending_selected_cache_id_ = cache_id; | 383 pending_selected_cache_id_ = cache_id; |
| 384 storage()->LoadCache(cache_id, this); | 384 storage()->LoadCache(cache_id, this); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void AppCacheHost::OnCacheLoaded(AppCache* cache, int64 cache_id) { | 387 void AppCacheHost::OnCacheLoaded(AppCache* cache, int64_t cache_id) { |
| 388 if (cache_id == pending_main_resource_cache_id_) { | 388 if (cache_id == pending_main_resource_cache_id_) { |
| 389 pending_main_resource_cache_id_ = kAppCacheNoCacheId; | 389 pending_main_resource_cache_id_ = kAppCacheNoCacheId; |
| 390 main_resource_cache_ = cache; | 390 main_resource_cache_ = cache; |
| 391 } else if (cache_id == pending_selected_cache_id_) { | 391 } else if (cache_id == pending_selected_cache_id_) { |
| 392 pending_selected_cache_id_ = kAppCacheNoCacheId; | 392 pending_selected_cache_id_ = kAppCacheNoCacheId; |
| 393 FinishCacheSelection(cache, NULL); | 393 FinishCacheSelection(cache, NULL); |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 | 396 |
| 397 void AppCacheHost::FinishCacheSelection( | 397 void AppCacheHost::FinishCacheSelection( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 swappable_cache_ = NULL; | 496 swappable_cache_ = NULL; |
| 497 } else { | 497 } else { |
| 498 AppCache* new_cache = group->newest_complete_cache(); | 498 AppCache* new_cache = group->newest_complete_cache(); |
| 499 if (new_cache != associated_cache_.get()) | 499 if (new_cache != associated_cache_.get()) |
| 500 swappable_cache_ = new_cache; | 500 swappable_cache_ = new_cache; |
| 501 else | 501 else |
| 502 swappable_cache_ = NULL; | 502 swappable_cache_ = NULL; |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 void AppCacheHost::LoadMainResourceCache(int64 cache_id) { | 506 void AppCacheHost::LoadMainResourceCache(int64_t cache_id) { |
| 507 DCHECK(cache_id != kAppCacheNoCacheId); | 507 DCHECK(cache_id != kAppCacheNoCacheId); |
| 508 if (pending_main_resource_cache_id_ == cache_id || | 508 if (pending_main_resource_cache_id_ == cache_id || |
| 509 (main_resource_cache_.get() && | 509 (main_resource_cache_.get() && |
| 510 main_resource_cache_->cache_id() == cache_id)) { | 510 main_resource_cache_->cache_id() == cache_id)) { |
| 511 return; | 511 return; |
| 512 } | 512 } |
| 513 pending_main_resource_cache_id_ = cache_id; | 513 pending_main_resource_cache_id_ = cache_id; |
| 514 storage()->LoadCache(cache_id, this); | 514 storage()->LoadCache(cache_id, this); |
| 515 } | 515 } |
| 516 | 516 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 associated_cache_info_pending_ = cache && !cache->is_complete(); | 567 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 568 AppCacheInfo info; | 568 AppCacheInfo info; |
| 569 if (cache) | 569 if (cache) |
| 570 cache->AssociateHost(this); | 570 cache->AssociateHost(this); |
| 571 | 571 |
| 572 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 572 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
| 573 frontend_->OnCacheSelected(host_id_, info); | 573 frontend_->OnCacheSelected(host_id_, info); |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace content | 576 } // namespace content |
| OLD | NEW |