Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: webkit/appcache/appcache_host.cc

Issue 3529009: Fix http/tests/appcache/foreign-fallback.html (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
32 } // Anonymous namespace 32 } // Anonymous namespace
33 33
34 AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, 34 AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
35 AppCacheService* service) 35 AppCacheService* service)
36 : host_id_(host_id), parent_host_id_(kNoHostId), parent_process_id_(0), 36 : host_id_(host_id), parent_host_id_(kNoHostId), parent_process_id_(0),
37 pending_main_resource_cache_id_(kNoCacheId), 37 pending_main_resource_cache_id_(kNoCacheId),
38 pending_selected_cache_id_(kNoCacheId), 38 pending_selected_cache_id_(kNoCacheId),
39 frontend_(frontend), service_(service), 39 frontend_(frontend), service_(service),
40 pending_get_status_callback_(NULL), pending_start_update_callback_(NULL), 40 pending_get_status_callback_(NULL), pending_start_update_callback_(NULL),
41 pending_swap_cache_callback_(NULL), pending_callback_param_(NULL), 41 pending_swap_cache_callback_(NULL), pending_callback_param_(NULL),
42 main_resource_blocked_(false), associated_cache_info_pending_(false) { 42 main_resource_was_fallback_(false), main_resource_blocked_(false),
43 associated_cache_info_pending_(false) {
43 } 44 }
44 45
45 AppCacheHost::~AppCacheHost() { 46 AppCacheHost::~AppCacheHost() {
46 FOR_EACH_OBSERVER(Observer, observers_, OnDestructionImminent(this)); 47 FOR_EACH_OBSERVER(Observer, observers_, OnDestructionImminent(this));
47 if (associated_cache_.get()) 48 if (associated_cache_.get())
48 associated_cache_->UnassociateHost(this); 49 associated_cache_->UnassociateHost(this);
49 if (group_being_updated_.get()) 50 if (group_being_updated_.get())
50 group_being_updated_->RemoveUpdateObserver(this); 51 group_being_updated_->RemoveUpdateObserver(this);
51 service_->storage()->CancelDelegateCallbacks(this); 52 service_->storage()->CancelDelegateCallbacks(this);
52 } 53 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (appcache_id != kNoCacheId) { 138 if (appcache_id != kNoCacheId) {
138 LoadSelectedCache(appcache_id); 139 LoadSelectedCache(appcache_id);
139 return; 140 return;
140 } 141 }
141 FinishCacheSelection(NULL, NULL); 142 FinishCacheSelection(NULL, NULL);
142 } 143 }
143 144
144 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency 145 // TODO(michaeln): change method name to MarkEntryAsForeign for consistency
145 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, 146 void AppCacheHost::MarkAsForeignEntry(const GURL& document_url,
146 int64 cache_document_was_loaded_from) { 147 int64 cache_document_was_loaded_from) {
148 // The document url is not the resource url in the fallback case.
147 service_->storage()->MarkEntryAsForeign( 149 service_->storage()->MarkEntryAsForeign(
148 document_url, cache_document_was_loaded_from); 150 main_resource_was_fallback_ ? fallback_url_ : document_url,
151 cache_document_was_loaded_from);
149 SelectCache(document_url, kNoCacheId, GURL()); 152 SelectCache(document_url, kNoCacheId, GURL());
150 } 153 }
151 154
152 void AppCacheHost::GetStatusWithCallback(GetStatusCallback* callback, 155 void AppCacheHost::GetStatusWithCallback(GetStatusCallback* callback,
153 void* callback_param) { 156 void* callback_param) {
154 DCHECK(!pending_start_update_callback_ && 157 DCHECK(!pending_start_update_callback_ &&
155 !pending_swap_cache_callback_ && 158 !pending_swap_cache_callback_ &&
156 !pending_get_status_callback_); 159 !pending_get_status_callback_);
157 160
158 pending_get_status_callback_ = callback; 161 pending_get_status_callback_ = callback;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 void AppCacheHost::LoadMainResourceCache(int64 cache_id) { 448 void AppCacheHost::LoadMainResourceCache(int64 cache_id) {
446 DCHECK(cache_id != kNoCacheId); 449 DCHECK(cache_id != kNoCacheId);
447 if (pending_main_resource_cache_id_ == cache_id || 450 if (pending_main_resource_cache_id_ == cache_id ||
448 (main_resource_cache_ && main_resource_cache_->cache_id() == cache_id)) { 451 (main_resource_cache_ && main_resource_cache_->cache_id() == cache_id)) {
449 return; 452 return;
450 } 453 }
451 pending_main_resource_cache_id_ = cache_id; 454 pending_main_resource_cache_id_ = cache_id;
452 service_->storage()->LoadCache(cache_id, this); 455 service_->storage()->LoadCache(cache_id, this);
453 } 456 }
454 457
458 void AppCacheHost::NotifyMainResourceFallback(const GURL& fallback_url) {
459 main_resource_was_fallback_ = true;
460 fallback_url_ = fallback_url;
461 }
462
455 void AppCacheHost::NotifyMainResourceBlocked(const GURL& manifest_url) { 463 void AppCacheHost::NotifyMainResourceBlocked(const GURL& manifest_url) {
456 main_resource_blocked_ = true; 464 main_resource_blocked_ = true;
457 blocked_manifest_url_ = manifest_url; 465 blocked_manifest_url_ = manifest_url;
458 } 466 }
459 467
460 void AppCacheHost::AssociateCache(AppCache* cache) { 468 void AppCacheHost::AssociateCache(AppCache* cache) {
461 if (associated_cache_.get()) { 469 if (associated_cache_.get()) {
462 associated_cache_->UnassociateHost(this); 470 associated_cache_->UnassociateHost(this);
463 } 471 }
464 472
465 associated_cache_ = cache; 473 associated_cache_ = cache;
466 SetSwappableCache(cache ? cache->owning_group() : NULL); 474 SetSwappableCache(cache ? cache->owning_group() : NULL);
467 associated_cache_info_pending_ = cache && !cache->is_complete(); 475 associated_cache_info_pending_ = cache && !cache->is_complete();
468 AppCacheInfo info; 476 AppCacheInfo info;
469 if (cache) { 477 if (cache) {
470 cache->AssociateHost(this); 478 cache->AssociateHost(this);
471 FillCacheInfo(cache, GetStatus(), &info); 479 FillCacheInfo(cache, GetStatus(), &info);
472 } 480 }
473 frontend_->OnCacheSelected(host_id_, info); 481 frontend_->OnCacheSelected(host_id_, info);
474 } 482 }
475 483
476 } // namespace appcache 484 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698