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

Side by Side Diff: webkit/database/database_quota_client.cc

Issue 7533013: Quota: Add quota::StorageType to the GetOriginsCallback definition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
OLDNEW
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 "webkit/database/database_quota_client.h" 5 #include "webkit/database/database_quota_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 } 83 }
84 84
85 std::set<GURL> origins_; 85 std::set<GURL> origins_;
86 }; 86 };
87 87
88 class DatabaseQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { 88 class DatabaseQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase {
89 public: 89 public:
90 GetAllOriginsTask( 90 GetAllOriginsTask(
91 DatabaseQuotaClient* client, 91 DatabaseQuotaClient* client,
92 base::MessageLoopProxy* db_tracker_thread) 92 base::MessageLoopProxy* db_tracker_thread,
93 : GetOriginsTaskBase(client, db_tracker_thread) { 93 quota::StorageType type)
94 : GetOriginsTaskBase(client, db_tracker_thread),
95 type_(type) {
94 } 96 }
95 97
96 protected: 98 protected:
97 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE { 99 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE {
98 return true; 100 return true;
99 } 101 }
100 virtual void Completed() OVERRIDE { 102 virtual void Completed() OVERRIDE {
101 client_->DidGetAllOrigins(origins_); 103 client_->DidGetAllOrigins(origins_, type_);
102 } 104 }
105
106 private:
107 quota::StorageType type_;
103 }; 108 };
104 109
105 class DatabaseQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase { 110 class DatabaseQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase {
106 public: 111 public:
107 GetOriginsForHostTask( 112 GetOriginsForHostTask(
108 DatabaseQuotaClient* client, 113 DatabaseQuotaClient* client,
109 base::MessageLoopProxy* db_tracker_thread, 114 base::MessageLoopProxy* db_tracker_thread,
110 const std::string& host) 115 const std::string& host,
116 quota::StorageType type)
111 : GetOriginsTaskBase(client, db_tracker_thread), 117 : GetOriginsTaskBase(client, db_tracker_thread),
112 host_(host) { 118 host_(host),
119 type_(type) {
113 } 120 }
114 121
115 private: 122 private:
116 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE { 123 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE {
117 return host_ == net::GetHostOrSpecFromURL(origin); 124 return host_ == net::GetHostOrSpecFromURL(origin);
118 } 125 }
119 virtual void Completed() OVERRIDE { 126 virtual void Completed() OVERRIDE {
120 client_->DidGetOriginsForHost(host_, origins_); 127 client_->DidGetOriginsForHost(host_, origins_, type_);
121 } 128 }
122 std::string host_; 129 std::string host_;
130 quota::StorageType type_;
123 }; 131 };
124 132
125 class DatabaseQuotaClient::DeleteOriginTask : public HelperTask { 133 class DatabaseQuotaClient::DeleteOriginTask : public HelperTask {
126 public: 134 public:
127 DeleteOriginTask( 135 DeleteOriginTask(
128 DatabaseQuotaClient* client, 136 DatabaseQuotaClient* client,
129 base::MessageLoopProxy* db_tracker_thread, 137 base::MessageLoopProxy* db_tracker_thread,
130 const GURL& origin_url, 138 const GURL& origin_url,
131 DeletionCallback* caller_callback) 139 DeletionCallback* caller_callback)
132 : HelperTask(client, db_tracker_thread), 140 : HelperTask(client, db_tracker_thread),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 223
216 void DatabaseQuotaClient::GetOriginsForType( 224 void DatabaseQuotaClient::GetOriginsForType(
217 quota::StorageType type, 225 quota::StorageType type,
218 GetOriginsCallback* callback_ptr) { 226 GetOriginsCallback* callback_ptr) {
219 DCHECK(callback_ptr); 227 DCHECK(callback_ptr);
220 DCHECK(db_tracker_.get()); 228 DCHECK(db_tracker_.get());
221 scoped_ptr<GetOriginsCallback> callback(callback_ptr); 229 scoped_ptr<GetOriginsCallback> callback(callback_ptr);
222 230
223 // All databases are in the temp namespace for now. 231 // All databases are in the temp namespace for now.
224 if (type != quota::kStorageTypeTemporary) { 232 if (type != quota::kStorageTypeTemporary) {
225 callback->Run(std::set<GURL>()); 233 callback->Run(std::set<GURL>(), type);
226 return; 234 return;
227 } 235 }
228 236
229 if (origins_for_type_callbacks_.Add(callback.release())) { 237 if (origins_for_type_callbacks_.Add(callback.release())) {
230 scoped_refptr<GetAllOriginsTask> task( 238 scoped_refptr<GetAllOriginsTask> task(
231 new GetAllOriginsTask(this, db_tracker_thread_)); 239 new GetAllOriginsTask(this, db_tracker_thread_, type));
232 task->Start(); 240 task->Start();
233 } 241 }
234 } 242 }
235 243
236 void DatabaseQuotaClient::GetOriginsForHost( 244 void DatabaseQuotaClient::GetOriginsForHost(
237 quota::StorageType type, 245 quota::StorageType type,
238 const std::string& host, 246 const std::string& host,
239 GetOriginsCallback* callback_ptr) { 247 GetOriginsCallback* callback_ptr) {
240 DCHECK(callback_ptr); 248 DCHECK(callback_ptr);
241 DCHECK(db_tracker_.get()); 249 DCHECK(db_tracker_.get());
242 scoped_ptr<GetOriginsCallback> callback(callback_ptr); 250 scoped_ptr<GetOriginsCallback> callback(callback_ptr);
243 251
244 // All databases are in the temp namespace for now. 252 // All databases are in the temp namespace for now.
245 if (type != quota::kStorageTypeTemporary) { 253 if (type != quota::kStorageTypeTemporary) {
246 callback->Run(std::set<GURL>()); 254 callback->Run(std::set<GURL>(), type);
247 return; 255 return;
248 } 256 }
249 257
250 if (origins_for_host_callbacks_.Add(host, callback.release())) { 258 if (origins_for_host_callbacks_.Add(host, callback.release())) {
251 scoped_refptr<GetOriginsForHostTask> task( 259 scoped_refptr<GetOriginsForHostTask> task(
252 new GetOriginsForHostTask(this, db_tracker_thread_, host)); 260 new GetOriginsForHostTask(this, db_tracker_thread_, host, type));
253 task->Start(); 261 task->Start();
254 } 262 }
255 } 263 }
256 264
257 void DatabaseQuotaClient::DeleteOriginData(const GURL& origin, 265 void DatabaseQuotaClient::DeleteOriginData(const GURL& origin,
258 quota::StorageType type, 266 quota::StorageType type,
259 DeletionCallback* callback_ptr) { 267 DeletionCallback* callback_ptr) {
260 DCHECK(callback_ptr); 268 DCHECK(callback_ptr);
261 DCHECK(db_tracker_.get()); 269 DCHECK(db_tracker_.get());
262 scoped_ptr<DeletionCallback> callback(callback_ptr); 270 scoped_ptr<DeletionCallback> callback(callback_ptr);
263 271
264 // All databases are in the temp namespace for now, so nothing to delete. 272 // All databases are in the temp namespace for now, so nothing to delete.
265 if (type != quota::kStorageTypeTemporary) { 273 if (type != quota::kStorageTypeTemporary) {
266 callback->Run(quota::kQuotaStatusOk); 274 callback->Run(quota::kQuotaStatusOk);
267 return; 275 return;
268 } 276 }
269 277
270 scoped_refptr<DeleteOriginTask> task( 278 scoped_refptr<DeleteOriginTask> task(
271 new DeleteOriginTask(this, db_tracker_thread_, 279 new DeleteOriginTask(this, db_tracker_thread_,
272 origin, callback.release())); 280 origin, callback.release()));
273 task->Start(); 281 task->Start();
274 } 282 }
275 283
276 void DatabaseQuotaClient::DidGetOriginUsage( 284 void DatabaseQuotaClient::DidGetOriginUsage(
277 const GURL& origin_url, int64 usage) { 285 const GURL& origin_url, int64 usage) {
278 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url)); 286 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url));
279 usage_for_origin_callbacks_.Run(origin_url, usage); 287 usage_for_origin_callbacks_.Run(origin_url, usage);
280 } 288 }
281 289
282 void DatabaseQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins) { 290 void DatabaseQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins,
291 quota::StorageType type) {
283 DCHECK(origins_for_type_callbacks_.HasCallbacks()); 292 DCHECK(origins_for_type_callbacks_.HasCallbacks());
284 origins_for_type_callbacks_.Run(origins); 293 origins_for_type_callbacks_.Run(origins, type);
285 } 294 }
286 295
287 void DatabaseQuotaClient::DidGetOriginsForHost( 296 void DatabaseQuotaClient::DidGetOriginsForHost(
288 const std::string& host, const std::set<GURL>& origins) { 297 const std::string& host, const std::set<GURL>& origins,
298 quota::StorageType type) {
289 DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); 299 DCHECK(origins_for_host_callbacks_.HasCallbacks(host));
290 origins_for_host_callbacks_.Run(host, origins); 300 origins_for_host_callbacks_.Run(host, origins, type);
291 } 301 }
292 302
293 } // namespace webkit_database 303 } // namespace webkit_database
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698