| OLD | NEW |
| 1 // Copyright (c) 2009 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 "webkit/appcache/appcache_request_handler.h" | 8 #include "webkit/appcache/appcache_request_handler.h" |
| 9 | 9 |
| 10 namespace appcache { | 10 namespace appcache { |
| 11 | 11 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // this can occur... <html manifest=foo> <html manifest=bar></html></html> | 47 // this can occur... <html manifest=foo> <html manifest=bar></html></html> |
| 48 // We handle this by killing whatever loading we have initiated, and by | 48 // We handle this by killing whatever loading we have initiated, and by |
| 49 // unassociating any hosts we currently have associated... and starting | 49 // unassociating any hosts we currently have associated... and starting |
| 50 // anew with the inputs to this SelectCache call. | 50 // anew with the inputs to this SelectCache call. |
| 51 // TODO(michaeln): at some point determine what behavior the algorithms | 51 // TODO(michaeln): at some point determine what behavior the algorithms |
| 52 // described in the HTML5 draft produce and have our impl produce those | 52 // described in the HTML5 draft produce and have our impl produce those |
| 53 // results (or suggest changes to the algorihtms described in the spec | 53 // results (or suggest changes to the algorihtms described in the spec |
| 54 // if the resulting behavior is just too insane). | 54 // if the resulting behavior is just too insane). |
| 55 if (is_selection_pending()) { | 55 if (is_selection_pending()) { |
| 56 service_->storage()->CancelDelegateCallbacks(this); | 56 service_->storage()->CancelDelegateCallbacks(this); |
| 57 pending_selected_manifest_url_ = GURL::EmptyGURL(); | 57 pending_selected_manifest_url_ = GURL(); |
| 58 pending_selected_cache_id_ = kNoCacheId; | 58 pending_selected_cache_id_ = kNoCacheId; |
| 59 } else if (associated_cache()) { | 59 } else if (associated_cache()) { |
| 60 AssociateCache(NULL); | 60 AssociateCache(NULL); |
| 61 } | 61 } |
| 62 new_master_entry_url_ = GURL::EmptyGURL(); | 62 new_master_entry_url_ = GURL(); |
| 63 | 63 |
| 64 // 6.9.6 The application cache selection algorithm. | 64 // 6.9.6 The application cache selection algorithm. |
| 65 // The algorithm is started here and continues in FinishCacheSelection, | 65 // The algorithm is started here and continues in FinishCacheSelection, |
| 66 // after cache or group loading is complete. | 66 // after cache or group loading is complete. |
| 67 // Note: Foreign entries are detected on the client side and | 67 // Note: Foreign entries are detected on the client side and |
| 68 // MarkAsForeignEntry is called in that case, so that detection | 68 // MarkAsForeignEntry is called in that case, so that detection |
| 69 // step is skipped here. See WebApplicationCacheHostImpl.cc | 69 // step is skipped here. See WebApplicationCacheHostImpl.cc |
| 70 | 70 |
| 71 if (cache_document_was_loaded_from != kNoCacheId) { | 71 if (cache_document_was_loaded_from != kNoCacheId) { |
| 72 LoadSelectedCache(cache_document_was_loaded_from); | 72 LoadSelectedCache(cache_document_was_loaded_from); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 86 // TODO(michaeln): If there was a manifest URL, the user agent may report | 86 // TODO(michaeln): If there was a manifest URL, the user agent may report |
| 87 // to the user that it was ignored, to aid in application development. | 87 // to the user that it was ignored, to aid in application development. |
| 88 FinishCacheSelection(NULL, NULL); | 88 FinishCacheSelection(NULL, NULL); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency | 91 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency |
| 92 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, | 92 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, |
| 93 int64 cache_document_was_loaded_from) { | 93 int64 cache_document_was_loaded_from) { |
| 94 service_->storage()->MarkEntryAsForeign( | 94 service_->storage()->MarkEntryAsForeign( |
| 95 document_url, cache_document_was_loaded_from); | 95 document_url, cache_document_was_loaded_from); |
| 96 SelectCache(document_url, kNoCacheId, GURL::EmptyGURL()); | 96 SelectCache(document_url, kNoCacheId, GURL()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void AppCacheHost::GetStatusWithCallback(GetStatusCallback* callback, | 99 void AppCacheHost::GetStatusWithCallback(GetStatusCallback* callback, |
| 100 void* callback_param) { | 100 void* callback_param) { |
| 101 DCHECK(!pending_start_update_callback_ && | 101 DCHECK(!pending_start_update_callback_ && |
| 102 !pending_swap_cache_callback_ && | 102 !pending_swap_cache_callback_ && |
| 103 !pending_get_status_callback_); | 103 !pending_get_status_callback_); |
| 104 | 104 |
| 105 pending_get_status_callback_ = callback; | 105 pending_get_status_callback_ = callback; |
| 106 pending_callback_param_ = callback_param; | 106 pending_callback_param_ = callback_param; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 void AppCacheHost::LoadOrCreateGroup(const GURL& manifest_url) { | 230 void AppCacheHost::LoadOrCreateGroup(const GURL& manifest_url) { |
| 231 DCHECK(manifest_url.is_valid()); | 231 DCHECK(manifest_url.is_valid()); |
| 232 pending_selected_manifest_url_ = manifest_url; | 232 pending_selected_manifest_url_ = manifest_url; |
| 233 service_->storage()->LoadOrCreateGroup(manifest_url, this); | 233 service_->storage()->LoadOrCreateGroup(manifest_url, this); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void AppCacheHost::OnGroupLoaded(AppCacheGroup* group, | 236 void AppCacheHost::OnGroupLoaded(AppCacheGroup* group, |
| 237 const GURL& manifest_url) { | 237 const GURL& manifest_url) { |
| 238 DCHECK(manifest_url == pending_selected_manifest_url_); | 238 DCHECK(manifest_url == pending_selected_manifest_url_); |
| 239 pending_selected_manifest_url_ = GURL::EmptyGURL(); | 239 pending_selected_manifest_url_ = GURL(); |
| 240 FinishCacheSelection(NULL, group); | 240 FinishCacheSelection(NULL, group); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void AppCacheHost::LoadSelectedCache(int64 cache_id) { | 243 void AppCacheHost::LoadSelectedCache(int64 cache_id) { |
| 244 DCHECK(cache_id != kNoCacheId); | 244 DCHECK(cache_id != kNoCacheId); |
| 245 pending_selected_cache_id_ = cache_id; | 245 pending_selected_cache_id_ = cache_id; |
| 246 service_->storage()->LoadCache(cache_id, this); | 246 service_->storage()->LoadCache(cache_id, this); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void AppCacheHost::OnCacheLoaded(AppCache* cache, int64 cache_id) { | 249 void AppCacheHost::OnCacheLoaded(AppCache* cache, int64 cache_id) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 if (cache) { | 351 if (cache) { |
| 352 cache->AssociateHost(this); | 352 cache->AssociateHost(this); |
| 353 frontend_->OnCacheSelected(host_id_, cache->cache_id(), GetStatus()); | 353 frontend_->OnCacheSelected(host_id_, cache->cache_id(), GetStatus()); |
| 354 } else { | 354 } else { |
| 355 frontend_->OnCacheSelected(host_id_, kNoCacheId, UNCACHED); | 355 frontend_->OnCacheSelected(host_id_, kNoCacheId, UNCACHED); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 } // namespace appcache | 359 } // namespace appcache |
| OLD | NEW |