OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_storage.h" | 5 #include "content/browser/appcache/appcache_storage.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/browser/appcache/appcache_response.h" | 10 #include "content/browser/appcache/appcache_response.h" |
11 #include "content/browser/appcache/appcache_service_impl.h" | 11 #include "content/browser/appcache/appcache_service_impl.h" |
12 #include "storage/browser/quota/quota_client.h" | 12 #include "storage/browser/quota/quota_client.h" |
13 #include "storage/browser/quota/quota_manager_proxy.h" | 13 #include "storage/browser/quota/quota_manager_proxy.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 // static | 17 // static |
18 const int64_t AppCacheStorage::kUnitializedId = -1; | 18 const int64_t AppCacheStorage::kUnitializedId = -1; |
19 | 19 |
20 AppCacheStorage::AppCacheStorage(AppCacheServiceImpl* service) | 20 AppCacheStorage::AppCacheStorage(AppCacheServiceImpl* service) |
21 : last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId), | 21 : last_cache_id_(kUnitializedId), |
22 last_response_id_(kUnitializedId), service_(service) { | 22 last_group_id_(kUnitializedId), |
23 } | 23 last_response_id_(kUnitializedId), |
| 24 service_(service), |
| 25 weak_factory_(this) {} |
24 | 26 |
25 AppCacheStorage::~AppCacheStorage() { | 27 AppCacheStorage::~AppCacheStorage() { |
26 DCHECK(delegate_references_.empty()); | 28 DCHECK(delegate_references_.empty()); |
27 } | 29 } |
28 | 30 |
29 AppCacheStorage::DelegateReference::DelegateReference( | 31 AppCacheStorage::DelegateReference::DelegateReference( |
30 Delegate* delegate, AppCacheStorage* storage) | 32 Delegate* delegate, AppCacheStorage* storage) |
31 : delegate(delegate), storage(storage) { | 33 : delegate(delegate), storage(storage) { |
32 storage->delegate_references_.insert( | 34 storage->delegate_references_.insert( |
33 DelegateReferenceMap::value_type(delegate, this)); | 35 DelegateReferenceMap::value_type(delegate, this)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return; | 89 return; |
88 } | 90 } |
89 ResponseInfoLoadTask* info_load = | 91 ResponseInfoLoadTask* info_load = |
90 GetOrCreateResponseInfoLoadTask(manifest_url, id); | 92 GetOrCreateResponseInfoLoadTask(manifest_url, id); |
91 DCHECK(manifest_url == info_load->manifest_url()); | 93 DCHECK(manifest_url == info_load->manifest_url()); |
92 DCHECK(id == info_load->response_id()); | 94 DCHECK(id == info_load->response_id()); |
93 info_load->AddDelegate(GetOrCreateDelegateReference(delegate)); | 95 info_load->AddDelegate(GetOrCreateDelegateReference(delegate)); |
94 info_load->StartIfNeeded(); | 96 info_load->StartIfNeeded(); |
95 } | 97 } |
96 | 98 |
| 99 base::WeakPtr<AppCacheStorage> AppCacheStorage::GetWeakPtr() { |
| 100 return weak_factory_.GetWeakPtr(); |
| 101 } |
| 102 |
97 void AppCacheStorage::UpdateUsageMapAndNotify(const GURL& origin, | 103 void AppCacheStorage::UpdateUsageMapAndNotify(const GURL& origin, |
98 int64_t new_usage) { | 104 int64_t new_usage) { |
99 DCHECK_GE(new_usage, 0); | 105 DCHECK_GE(new_usage, 0); |
100 int64_t old_usage = usage_map_[origin]; | 106 int64_t old_usage = usage_map_[origin]; |
101 if (new_usage > 0) | 107 if (new_usage > 0) |
102 usage_map_[origin] = new_usage; | 108 usage_map_[origin] = new_usage; |
103 else | 109 else |
104 usage_map_.erase(origin); | 110 usage_map_.erase(origin); |
105 if (new_usage != old_usage && service()->quota_manager_proxy()) { | 111 if (new_usage != old_usage && service()->quota_manager_proxy()) { |
106 service()->quota_manager_proxy()->NotifyStorageModified( | 112 service()->quota_manager_proxy()->NotifyStorageModified( |
(...skipping 22 matching lines...) Expand all Loading... |
129 if (service()->quota_manager_proxy() && | 135 if (service()->quota_manager_proxy() && |
130 usage_map_.find(origin) != usage_map_.end()) | 136 usage_map_.find(origin) != usage_map_.end()) |
131 service()->quota_manager_proxy()->NotifyStorageAccessed( | 137 service()->quota_manager_proxy()->NotifyStorageAccessed( |
132 storage::QuotaClient::kAppcache, | 138 storage::QuotaClient::kAppcache, |
133 origin, | 139 origin, |
134 storage::kStorageTypeTemporary); | 140 storage::kStorageTypeTemporary); |
135 } | 141 } |
136 | 142 |
137 } // namespace content | 143 } // namespace content |
138 | 144 |
OLD | NEW |