summaryrefslogtreecommitdiffstats
path: root/content/browser/in_process_webkit/indexed_db_quota_client.cc
diff options
context:
space:
mode:
authordgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 23:53:15 +0000
committerdgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 23:53:15 +0000
commit682394a2956e2797aaf844959f8fa5d623b71ff4 (patch)
treec8f963e060f58bbd5a8b6cc1ca63f7c33eeb51ed /content/browser/in_process_webkit/indexed_db_quota_client.cc
parenta4f10d1ed4c8921a2a47354f78753032d0b6a999 (diff)
downloadchromium_src-682394a2956e2797aaf844959f8fa5d623b71ff4.zip
chromium_src-682394a2956e2797aaf844959f8fa5d623b71ff4.tar.gz
chromium_src-682394a2956e2797aaf844959f8fa5d623b71ff4.tar.bz2
Improve IndexedDB's quota support
* Check available quota before storing anything * Inform quota manager of storage updates * Evict an origin when quota manager requests BUG=83652 TEST=llvm/Debug/unit_tests --gtest_filter=IndexedDBQuotaClientTest.* && llvm/Debug/browser_tests --gtest_filter=IndexedDBBrowser* Review URL: http://codereview.chromium.org/7470008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/in_process_webkit/indexed_db_quota_client.cc')
-rw-r--r--content/browser/in_process_webkit/indexed_db_quota_client.cc43
1 files changed, 36 insertions, 7 deletions
diff --git a/content/browser/in_process_webkit/indexed_db_quota_client.cc b/content/browser/in_process_webkit/indexed_db_quota_client.cc
index 11cf6ce..606188b 100644
--- a/content/browser/in_process_webkit/indexed_db_quota_client.cc
+++ b/content/browser/in_process_webkit/indexed_db_quota_client.cc
@@ -31,6 +31,30 @@ class IndexedDBQuotaClient::HelperTask : public quota::QuotaThreadTask {
scoped_refptr<IndexedDBContext> indexed_db_context_;
};
+class IndexedDBQuotaClient::DeleteOriginTask : public HelperTask {
+ public:
+ DeleteOriginTask(IndexedDBQuotaClient* client,
+ base::MessageLoopProxy* webkit_thread_message_loop,
+ const GURL& origin_url,
+ DeletionCallback* callback)
+ : HelperTask(client, webkit_thread_message_loop),
+ origin_url_(origin_url), callback_(callback) {
+ }
+ private:
+ virtual void RunOnTargetThread() OVERRIDE {
+ indexed_db_context_->DeleteIndexedDBForOrigin(origin_url_);
+ }
+ virtual void Aborted() OVERRIDE {
+ callback_.reset();
+ }
+ virtual void Completed() OVERRIDE {
+ callback_->Run(quota::kQuotaStatusOk);
+ callback_.reset();
+ }
+ GURL origin_url_;
+ scoped_ptr<DeletionCallback> callback_;
+};
+
class IndexedDBQuotaClient::GetOriginUsageTask : public HelperTask {
public:
GetOriginUsageTask(
@@ -43,12 +67,10 @@ class IndexedDBQuotaClient::GetOriginUsageTask : public HelperTask {
private:
virtual void RunOnTargetThread() OVERRIDE {
- string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url_);
- FilePath file_path = indexed_db_context_->GetIndexedDBFilePath(origin_id);
- usage_ = 0;
- usage_ = file_util::ComputeDirectorySize(file_path);
+ usage_ = indexed_db_context_->GetOriginDiskUsage(origin_url_);
}
virtual void Completed() OVERRIDE {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
client_->DidGetOriginUsage(origin_url_, usage_);
}
GURL origin_url_;
@@ -211,9 +233,16 @@ void IndexedDBQuotaClient::GetOriginsForHost(
void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
quota::StorageType type,
DeletionCallback* callback) {
- // TODO(tzik): implement me
- callback->Run(quota::kQuotaErrorNotSupported);
- delete callback;
+ if (type != quota::kStorageTypeTemporary) {
+ callback->Run(quota::kQuotaErrorNotSupported);
+ return;
+ }
+ scoped_refptr<DeleteOriginTask> task(
+ new DeleteOriginTask(this,
+ webkit_thread_message_loop_,
+ origin,
+ callback));
+ task->Start();
}
void IndexedDBQuotaClient::DidGetOriginUsage(