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

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

Issue 7031065: AppCache + Quota integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months 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
« no previous file with comments | « webkit/appcache/appcache_storage.h ('k') | webkit/appcache/appcache_storage_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/appcache/appcache_storage.h" 5 #include "webkit/appcache/appcache_storage.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "webkit/appcache/appcache_response.h" 8 #include "webkit/appcache/appcache_response.h"
9 #include "webkit/appcache/appcache_service.h"
10 #include "webkit/quota/quota_client.h"
11 #include "webkit/quota/quota_manager.h"
9 12
10 namespace appcache { 13 namespace appcache {
11 14
12 // static 15 // static
13 const int64 AppCacheStorage::kUnitializedId = -1; 16 const int64 AppCacheStorage::kUnitializedId = -1;
14 17
15 AppCacheStorage::AppCacheStorage(AppCacheService* service) 18 AppCacheStorage::AppCacheStorage(AppCacheService* service)
16 : last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId), 19 : last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId),
17 last_response_id_(kUnitializedId), service_(service) { 20 last_response_id_(kUnitializedId), service_(service) {
18 } 21 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return; 83 return;
81 } 84 }
82 ResponseInfoLoadTask* info_load = 85 ResponseInfoLoadTask* info_load =
83 GetOrCreateResponseInfoLoadTask(manifest_url, id); 86 GetOrCreateResponseInfoLoadTask(manifest_url, id);
84 DCHECK(manifest_url == info_load->manifest_url()); 87 DCHECK(manifest_url == info_load->manifest_url());
85 DCHECK(id == info_load->response_id()); 88 DCHECK(id == info_load->response_id());
86 info_load->AddDelegate(GetOrCreateDelegateReference(delegate)); 89 info_load->AddDelegate(GetOrCreateDelegateReference(delegate));
87 info_load->StartIfNeeded(); 90 info_load->StartIfNeeded();
88 } 91 }
89 92
93 void AppCacheStorage::UpdateUsageMapAndNotify(
94 const GURL& origin, int64 new_usage) {
95 DCHECK_GE(new_usage, 0);
96 int64 old_usage = usage_map_[origin];
97 if (new_usage > 0)
98 usage_map_[origin] = new_usage;
99 else
100 usage_map_.erase(origin);
101 if (new_usage != old_usage && service()->quota_manager_proxy()) {
102 service()->quota_manager_proxy()->NotifyStorageModified(
103 quota::QuotaClient::kAppcache,
104 origin, quota::kStorageTypeTemporary,
105 new_usage - old_usage);
106 }
107 }
108
109 void AppCacheStorage::ClearUsageMapAndNotify() {
110 if (service()->quota_manager_proxy()) {
111 for (UsageMap::const_iterator iter = usage_map_.begin();
112 iter != usage_map_.end(); ++iter) {
113 service()->quota_manager_proxy()->NotifyStorageModified(
114 quota::QuotaClient::kAppcache,
115 iter->first, quota::kStorageTypeTemporary,
116 -(iter->second));
117 }
118 }
119 usage_map_.clear();
120 }
121
122 void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) {
123 if (service()->quota_manager_proxy() &&
124 usage_map_.find(origin) != usage_map_.end())
125 service()->quota_manager_proxy()->NotifyStorageAccessed(
126 quota::QuotaClient::kAppcache,
127 origin, quota::kStorageTypeTemporary);
128 }
129
90 } // namespace appcache 130 } // namespace appcache
91 131
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage.h ('k') | webkit/appcache/appcache_storage_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698