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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_quota_client.cc

Issue 7470008: Improve IndexedDB's quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style problems Created 9 years, 5 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 "content/browser/in_process_webkit/indexed_db_quota_client.h" 5 #include "content/browser/in_process_webkit/indexed_db_quota_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 13 matching lines...) Expand all
24 IndexedDBQuotaClient* client, 24 IndexedDBQuotaClient* client,
25 base::MessageLoopProxy* webkit_thread_message_loop) 25 base::MessageLoopProxy* webkit_thread_message_loop)
26 : QuotaThreadTask(client, webkit_thread_message_loop), 26 : QuotaThreadTask(client, webkit_thread_message_loop),
27 client_(client), indexed_db_context_(client->indexed_db_context_) { 27 client_(client), indexed_db_context_(client->indexed_db_context_) {
28 } 28 }
29 29
30 IndexedDBQuotaClient* client_; 30 IndexedDBQuotaClient* client_;
31 scoped_refptr<IndexedDBContext> indexed_db_context_; 31 scoped_refptr<IndexedDBContext> indexed_db_context_;
32 }; 32 };
33 33
34 class IndexedDBQuotaClient::DeleteOriginTask : public HelperTask {
35 public:
36 DeleteOriginTask(IndexedDBQuotaClient* client,
37 base::MessageLoopProxy* webkit_thread_message_loop,
38 const GURL& origin_url,
39 DeletionCallback* callback)
40 : HelperTask(client, webkit_thread_message_loop),
41 origin_url_(origin_url), callback_(callback) {
42 }
43 private:
44 virtual void RunOnTargetThread() OVERRIDE {
45 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url_);
46 indexed_db_context_->EvictOrigin(origin_id);
47 }
48 virtual void Completed() OVERRIDE {
49 callback_->Run(quota::kQuotaStatusOk);
50 }
51 GURL origin_url_;
52 scoped_ptr<DeletionCallback> callback_;
michaeln 2011/07/27 01:31:35 It would be good to ensure that this callback obje
53 };
54
34 class IndexedDBQuotaClient::GetOriginUsageTask : public HelperTask { 55 class IndexedDBQuotaClient::GetOriginUsageTask : public HelperTask {
35 public: 56 public:
36 GetOriginUsageTask( 57 GetOriginUsageTask(
37 IndexedDBQuotaClient* client, 58 IndexedDBQuotaClient* client,
38 base::MessageLoopProxy* webkit_thread_message_loop, 59 base::MessageLoopProxy* webkit_thread_message_loop,
39 const GURL& origin_url) 60 const GURL& origin_url)
40 : HelperTask(client, webkit_thread_message_loop), 61 : HelperTask(client, webkit_thread_message_loop),
41 origin_url_(origin_url), usage_(0) { 62 origin_url_(origin_url), usage_(0) {
42 } 63 }
43 64
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (origins_for_host_callbacks_.Add(host, callback.release())) { 216 if (origins_for_host_callbacks_.Add(host, callback.release())) {
196 scoped_refptr<GetOriginsForHostTask> task( 217 scoped_refptr<GetOriginsForHostTask> task(
197 new GetOriginsForHostTask(this, webkit_thread_message_loop_, host)); 218 new GetOriginsForHostTask(this, webkit_thread_message_loop_, host));
198 task->Start(); 219 task->Start();
199 } 220 }
200 } 221 }
201 222
202 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, 223 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
203 quota::StorageType type, 224 quota::StorageType type,
204 DeletionCallback* callback) { 225 DeletionCallback* callback) {
205 // TODO(tzik): implement me 226 // DeleteOriginData is only called on origins that are not in use, so we can
206 callback->Run(quota::kQuotaErrorNotSupported); 227 // safely delete them here.
dgrogan 2011/07/26 02:02:16 Kinuko, can you confirm that this is true?
kinuko 2011/07/26 06:35:28 It's half true-- it won't be called while it is in
dgrogan 2011/07/26 17:46:15 That would be great for IDB.
michaeln 2011/07/27 01:31:35 I think we want to support deleting resources whil
kinuko 2011/07/27 10:09:20 Currently the filesystem impl doesn't fully suppor
dgrogan 2011/07/27 22:56:01 Sorry, I only meant it would be great for IDB beca
207 delete callback; 228 if (type != quota::kStorageTypeTemporary) {
229 callback->Run(quota::kQuotaErrorNotSupported);
230 return;
231 }
232 scoped_refptr<DeleteOriginTask> task(
233 new DeleteOriginTask(this,
234 webkit_thread_message_loop_,
235 origin,
236 callback));
237 task->Start();
208 } 238 }
209 239
210 void IndexedDBQuotaClient::DidGetOriginUsage( 240 void IndexedDBQuotaClient::DidGetOriginUsage(
211 const GURL& origin_url, int64 usage) { 241 const GURL& origin_url, int64 usage) {
212 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url)); 242 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url));
213 usage_for_origin_callbacks_.Run(origin_url, usage); 243 usage_for_origin_callbacks_.Run(origin_url, usage);
214 } 244 }
215 245
216 void IndexedDBQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins) { 246 void IndexedDBQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins) {
217 DCHECK(origins_for_type_callbacks_.HasCallbacks()); 247 DCHECK(origins_for_type_callbacks_.HasCallbacks());
218 origins_for_type_callbacks_.Run(origins); 248 origins_for_type_callbacks_.Run(origins);
219 } 249 }
220 250
221 void IndexedDBQuotaClient::DidGetOriginsForHost( 251 void IndexedDBQuotaClient::DidGetOriginsForHost(
222 const std::string& host, const std::set<GURL>& origins) { 252 const std::string& host, const std::set<GURL>& origins) {
223 DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); 253 DCHECK(origins_for_host_callbacks_.HasCallbacks(host));
224 origins_for_host_callbacks_.Run(host, origins); 254 origins_for_host_callbacks_.Run(host, origins);
225 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698