| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/appcache_host.h" | 5 #include "webkit/appcache/appcache_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "webkit/appcache/appcache.h" | 10 #include "webkit/appcache/appcache.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 void AppCacheHost::RemoveObserver(Observer* observer) { | 59 void AppCacheHost::RemoveObserver(Observer* observer) { |
| 60 observers_.RemoveObserver(observer); | 60 observers_.RemoveObserver(observer); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AppCacheHost::SelectCache(const GURL& document_url, | 63 void AppCacheHost::SelectCache(const GURL& document_url, |
| 64 const int64 cache_document_was_loaded_from, | 64 const int64 cache_document_was_loaded_from, |
| 65 const GURL& manifest_url) { | 65 const GURL& manifest_url) { |
| 66 DCHECK(!pending_start_update_callback_ && | 66 DCHECK(!pending_start_update_callback_ && |
| 67 !pending_swap_cache_callback_ && | 67 !pending_swap_cache_callback_ && |
| 68 !pending_get_status_callback_); | 68 !pending_get_status_callback_ && |
| 69 !is_selection_pending()); |
| 69 | 70 |
| 70 if (main_resource_blocked_) | 71 if (main_resource_blocked_) |
| 71 frontend_->OnContentBlocked(host_id_, | 72 frontend_->OnContentBlocked(host_id_, |
| 72 blocked_manifest_url_); | 73 blocked_manifest_url_); |
| 73 | 74 |
| 74 // First we handle an unusual case of SelectCache being called a second | |
| 75 // time. Generally this shouldn't happen, but with bad content I think | |
| 76 // this can occur... <html manifest=foo> <html manifest=bar></html></html> | |
| 77 // We handle this by killing whatever loading we have initiated, and by | |
| 78 // unassociating any hosts we currently have associated... and starting | |
| 79 // anew with the inputs to this SelectCache call. | |
| 80 // TODO(michaeln): at some point determine what behavior the algorithms | |
| 81 // described in the HTML5 draft produce and have our impl produce those | |
| 82 // results (or suggest changes to the algorihtms described in the spec | |
| 83 // if the resulting behavior is just too insane). | |
| 84 if (is_selection_pending()) { | |
| 85 service_->storage()->CancelDelegateCallbacks(this); | |
| 86 pending_selected_manifest_url_ = GURL(); | |
| 87 pending_selected_cache_id_ = kNoCacheId; | |
| 88 } else if (associated_cache()) { | |
| 89 AssociateCache(NULL); | |
| 90 } | |
| 91 new_master_entry_url_ = GURL(); | |
| 92 | |
| 93 // 6.9.6 The application cache selection algorithm. | 75 // 6.9.6 The application cache selection algorithm. |
| 94 // The algorithm is started here and continues in FinishCacheSelection, | 76 // The algorithm is started here and continues in FinishCacheSelection, |
| 95 // after cache or group loading is complete. | 77 // after cache or group loading is complete. |
| 96 // Note: Foreign entries are detected on the client side and | 78 // Note: Foreign entries are detected on the client side and |
| 97 // MarkAsForeignEntry is called in that case, so that detection | 79 // MarkAsForeignEntry is called in that case, so that detection |
| 98 // step is skipped here. See WebApplicationCacheHostImpl.cc | 80 // step is skipped here. See WebApplicationCacheHostImpl.cc |
| 99 | 81 |
| 100 if (cache_document_was_loaded_from != kNoCacheId) { | 82 if (cache_document_was_loaded_from != kNoCacheId) { |
| 101 LoadSelectedCache(cache_document_was_loaded_from); | 83 LoadSelectedCache(cache_document_was_loaded_from); |
| 102 return; | 84 return; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 associated_cache_info_pending_ = cache && !cache->is_complete(); | 457 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 476 AppCacheInfo info; | 458 AppCacheInfo info; |
| 477 if (cache) { | 459 if (cache) { |
| 478 cache->AssociateHost(this); | 460 cache->AssociateHost(this); |
| 479 FillCacheInfo(cache, GetStatus(), &info); | 461 FillCacheInfo(cache, GetStatus(), &info); |
| 480 } | 462 } |
| 481 frontend_->OnCacheSelected(host_id_, info); | 463 frontend_->OnCacheSelected(host_id_, info); |
| 482 } | 464 } |
| 483 | 465 |
| 484 } // namespace appcache | 466 } // namespace appcache |
| OLD | NEW |