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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 parent_host_id_(kAppCacheNoHostId), parent_process_id_(0), | 51 parent_host_id_(kAppCacheNoHostId), parent_process_id_(0), |
52 pending_main_resource_cache_id_(kAppCacheNoCacheId), | 52 pending_main_resource_cache_id_(kAppCacheNoCacheId), |
53 pending_selected_cache_id_(kAppCacheNoCacheId), | 53 pending_selected_cache_id_(kAppCacheNoCacheId), |
54 was_select_cache_called_(false), | 54 was_select_cache_called_(false), |
55 is_cache_selection_enabled_(true), | 55 is_cache_selection_enabled_(true), |
56 frontend_(frontend), service_(service), | 56 frontend_(frontend), service_(service), |
57 storage_(service->storage()), | 57 storage_(service->storage()), |
58 pending_callback_param_(NULL), | 58 pending_callback_param_(NULL), |
59 main_resource_was_namespace_entry_(false), | 59 main_resource_was_namespace_entry_(false), |
60 main_resource_blocked_(false), | 60 main_resource_blocked_(false), |
61 associated_cache_info_pending_(false) { | 61 associated_cache_info_pending_(false), |
| 62 weak_factory_(this) { |
62 service_->AddObserver(this); | 63 service_->AddObserver(this); |
63 } | 64 } |
64 | 65 |
65 AppCacheHost::~AppCacheHost() { | 66 AppCacheHost::~AppCacheHost() { |
66 service_->RemoveObserver(this); | 67 service_->RemoveObserver(this); |
67 for (auto& observer : observers_) | 68 for (auto& observer : observers_) |
68 observer.OnDestructionImminent(this); | 69 observer.OnDestructionImminent(this); |
69 if (associated_cache_.get()) | 70 if (associated_cache_.get()) |
70 associated_cache_->UnassociateHost(this); | 71 associated_cache_->UnassociateHost(this); |
71 if (group_being_updated_.get()) | 72 if (group_being_updated_.get()) |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 DCHECK(!group_being_updated_.get()); | 537 DCHECK(!group_being_updated_.get()); |
537 host_id_ = kAppCacheNoHostId; | 538 host_id_ = kAppCacheNoHostId; |
538 frontend_ = NULL; | 539 frontend_ = NULL; |
539 } | 540 } |
540 | 541 |
541 void AppCacheHost::CompleteTransfer(int host_id, AppCacheFrontend* frontend) { | 542 void AppCacheHost::CompleteTransfer(int host_id, AppCacheFrontend* frontend) { |
542 host_id_ = host_id; | 543 host_id_ = host_id; |
543 frontend_ = frontend; | 544 frontend_ = frontend; |
544 } | 545 } |
545 | 546 |
| 547 base::WeakPtr<AppCacheHost> AppCacheHost::GetWeakPtr() { |
| 548 return weak_factory_.GetWeakPtr(); |
| 549 } |
| 550 |
546 void AppCacheHost::AssociateNoCache(const GURL& manifest_url) { | 551 void AppCacheHost::AssociateNoCache(const GURL& manifest_url) { |
547 // manifest url can be empty. | 552 // manifest url can be empty. |
548 AssociateCacheHelper(NULL, manifest_url); | 553 AssociateCacheHelper(NULL, manifest_url); |
549 } | 554 } |
550 | 555 |
551 void AppCacheHost::AssociateIncompleteCache(AppCache* cache, | 556 void AppCacheHost::AssociateIncompleteCache(AppCache* cache, |
552 const GURL& manifest_url) { | 557 const GURL& manifest_url) { |
553 DCHECK(cache && !cache->is_complete()); | 558 DCHECK(cache && !cache->is_complete()); |
554 DCHECK(!manifest_url.is_empty()); | 559 DCHECK(!manifest_url.is_empty()); |
555 AssociateCacheHelper(cache, manifest_url); | 560 AssociateCacheHelper(cache, manifest_url); |
(...skipping 15 matching lines...) Expand all Loading... |
571 associated_cache_info_pending_ = cache && !cache->is_complete(); | 576 associated_cache_info_pending_ = cache && !cache->is_complete(); |
572 AppCacheInfo info; | 577 AppCacheInfo info; |
573 if (cache) | 578 if (cache) |
574 cache->AssociateHost(this); | 579 cache->AssociateHost(this); |
575 | 580 |
576 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 581 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
577 frontend_->OnCacheSelected(host_id_, info); | 582 frontend_->OnCacheSelected(host_id_, info); |
578 } | 583 } |
579 | 584 |
580 } // namespace content | 585 } // namespace content |
OLD | NEW |