| 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 26 matching lines...) Expand all Loading... |
| 37 DCHECK(cache->owning_group()); | 37 DCHECK(cache->owning_group()); |
| 38 info->is_complete = true; | 38 info->is_complete = true; |
| 39 info->group_id = cache->owning_group()->group_id(); | 39 info->group_id = cache->owning_group()->group_id(); |
| 40 info->last_update_time = cache->update_time(); | 40 info->last_update_time = cache->update_time(); |
| 41 info->creation_time = cache->owning_group()->creation_time(); | 41 info->creation_time = cache->owning_group()->creation_time(); |
| 42 info->size = cache->cache_size(); | 42 info->size = cache->cache_size(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // Anonymous namespace | 45 } // Anonymous namespace |
| 46 | 46 |
| 47 AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, | 47 AppCacheHost::AppCacheHost(int host_id, |
| 48 AppCacheFrontend* frontend, |
| 48 AppCacheServiceImpl* service) | 49 AppCacheServiceImpl* service) |
| 49 : host_id_(host_id), | 50 : host_id_(host_id), |
| 50 spawning_host_id_(kAppCacheNoHostId), spawning_process_id_(0), | 51 spawning_host_id_(kAppCacheNoHostId), |
| 51 parent_host_id_(kAppCacheNoHostId), parent_process_id_(0), | 52 spawning_process_id_(0), |
| 53 parent_host_id_(kAppCacheNoHostId), |
| 54 parent_process_id_(0), |
| 52 pending_main_resource_cache_id_(kAppCacheNoCacheId), | 55 pending_main_resource_cache_id_(kAppCacheNoCacheId), |
| 53 pending_selected_cache_id_(kAppCacheNoCacheId), | 56 pending_selected_cache_id_(kAppCacheNoCacheId), |
| 54 was_select_cache_called_(false), | 57 was_select_cache_called_(false), |
| 55 is_cache_selection_enabled_(true), | 58 is_cache_selection_enabled_(true), |
| 56 frontend_(frontend), service_(service), | 59 frontend_(frontend), |
| 60 service_(service), |
| 57 storage_(service->storage()), | 61 storage_(service->storage()), |
| 58 pending_callback_param_(NULL), | 62 pending_callback_param_(NULL), |
| 59 main_resource_was_namespace_entry_(false), | 63 main_resource_was_namespace_entry_(false), |
| 60 main_resource_blocked_(false), | 64 main_resource_blocked_(false), |
| 61 associated_cache_info_pending_(false) { | 65 associated_cache_info_pending_(false), |
| 66 weak_factory_(this) { |
| 62 service_->AddObserver(this); | 67 service_->AddObserver(this); |
| 63 } | 68 } |
| 64 | 69 |
| 65 AppCacheHost::~AppCacheHost() { | 70 AppCacheHost::~AppCacheHost() { |
| 66 service_->RemoveObserver(this); | 71 service_->RemoveObserver(this); |
| 67 for (auto& observer : observers_) | 72 for (auto& observer : observers_) |
| 68 observer.OnDestructionImminent(this); | 73 observer.OnDestructionImminent(this); |
| 69 if (associated_cache_.get()) | 74 if (associated_cache_.get()) |
| 70 associated_cache_->UnassociateHost(this); | 75 associated_cache_->UnassociateHost(this); |
| 71 if (group_being_updated_.get()) | 76 if (group_being_updated_.get()) |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 DCHECK(!group_being_updated_.get()); | 541 DCHECK(!group_being_updated_.get()); |
| 537 host_id_ = kAppCacheNoHostId; | 542 host_id_ = kAppCacheNoHostId; |
| 538 frontend_ = NULL; | 543 frontend_ = NULL; |
| 539 } | 544 } |
| 540 | 545 |
| 541 void AppCacheHost::CompleteTransfer(int host_id, AppCacheFrontend* frontend) { | 546 void AppCacheHost::CompleteTransfer(int host_id, AppCacheFrontend* frontend) { |
| 542 host_id_ = host_id; | 547 host_id_ = host_id; |
| 543 frontend_ = frontend; | 548 frontend_ = frontend; |
| 544 } | 549 } |
| 545 | 550 |
| 551 base::WeakPtr<AppCacheHost> AppCacheHost::GetWeakPtr() { |
| 552 return weak_factory_.GetWeakPtr(); |
| 553 } |
| 554 |
| 546 void AppCacheHost::AssociateNoCache(const GURL& manifest_url) { | 555 void AppCacheHost::AssociateNoCache(const GURL& manifest_url) { |
| 547 // manifest url can be empty. | 556 // manifest url can be empty. |
| 548 AssociateCacheHelper(NULL, manifest_url); | 557 AssociateCacheHelper(NULL, manifest_url); |
| 549 } | 558 } |
| 550 | 559 |
| 551 void AppCacheHost::AssociateIncompleteCache(AppCache* cache, | 560 void AppCacheHost::AssociateIncompleteCache(AppCache* cache, |
| 552 const GURL& manifest_url) { | 561 const GURL& manifest_url) { |
| 553 DCHECK(cache && !cache->is_complete()); | 562 DCHECK(cache && !cache->is_complete()); |
| 554 DCHECK(!manifest_url.is_empty()); | 563 DCHECK(!manifest_url.is_empty()); |
| 555 AssociateCacheHelper(cache, manifest_url); | 564 AssociateCacheHelper(cache, manifest_url); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 571 associated_cache_info_pending_ = cache && !cache->is_complete(); | 580 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 572 AppCacheInfo info; | 581 AppCacheInfo info; |
| 573 if (cache) | 582 if (cache) |
| 574 cache->AssociateHost(this); | 583 cache->AssociateHost(this); |
| 575 | 584 |
| 576 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 585 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
| 577 frontend_->OnCacheSelected(host_id_, info); | 586 frontend_->OnCacheSelected(host_id_, info); |
| 578 } | 587 } |
| 579 | 588 |
| 580 } // namespace content | 589 } // namespace content |
| OLD | NEW |