diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 11:53:51 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 11:53:51 +0000 |
commit | e5006b96ad664c9650c3631b4e666147a9c87a91 (patch) | |
tree | 29f5d2a4e28ff48da1843e63edfaa7fd0fb5cea8 /webkit/fileapi/file_system_quota_util.cc | |
parent | fb9c4a7f8b369a8f810ac92334ff6f16cea138a6 (diff) | |
download | chromium_src-e5006b96ad664c9650c3631b4e666147a9c87a91.zip chromium_src-e5006b96ad664c9650c3631b4e666147a9c87a91.tar.gz chromium_src-e5006b96ad664c9650c3631b4e666147a9c87a91.tar.bz2 |
Switch usage cache code to use FileSystemQuotaUtil in FileWriterDelegate
patch based on: http://codereview.chromium.org/6973005/
BUG=74841
TEST=FileWriterDelegate.*
Review URL: http://codereview.chromium.org/7012037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_quota_util.cc')
-rw-r--r-- | webkit/fileapi/file_system_quota_util.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_quota_util.cc b/webkit/fileapi/file_system_quota_util.cc new file mode 100644 index 0000000..3d0fab4 --- /dev/null +++ b/webkit/fileapi/file_system_quota_util.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/fileapi/file_system_quota_util.h" + +#include "base/compiler_specific.h" +#include "base/message_loop_proxy.h" + +namespace fileapi { + +void FileSystemQuotaUtil::Proxy::UpdateOriginUsage( + quota::QuotaManagerProxy* proxy, const GURL& origin_url, + fileapi::FileSystemType type, int64 delta) { + if (!file_thread_->BelongsToCurrentThread()) { + file_thread_->PostTask(FROM_HERE, NewRunnableMethod( + this, &Proxy::UpdateOriginUsage, proxy, origin_url, type, delta)); + return; + } + if (quota_util_) + quota_util_->UpdateOriginUsageOnFileThread(proxy, origin_url, type, delta); +} + +void FileSystemQuotaUtil::Proxy::StartUpdateOrigin( + const GURL& origin_url, fileapi::FileSystemType type) { + if (!file_thread_->BelongsToCurrentThread()) { + file_thread_->PostTask(FROM_HERE, NewRunnableMethod( + this, &Proxy::StartUpdateOrigin, origin_url, type)); + return; + } + if (quota_util_) + quota_util_->StartUpdateOriginOnFileThread(origin_url, type); +} + +void FileSystemQuotaUtil::Proxy::EndUpdateOrigin( + const GURL& origin_url, fileapi::FileSystemType type) { + if (!file_thread_->BelongsToCurrentThread()) { + file_thread_->PostTask(FROM_HERE, NewRunnableMethod( + this, &Proxy::EndUpdateOrigin, origin_url, type)); + return; + } + if (quota_util_) + quota_util_->EndUpdateOriginOnFileThread(origin_url, type); +} + +FileSystemQuotaUtil::Proxy::Proxy( + FileSystemQuotaUtil* quota_util, + base::MessageLoopProxy* file_thread) + : quota_util_(quota_util), + file_thread_(file_thread) { + DCHECK(quota_util); +} + +FileSystemQuotaUtil::Proxy::~Proxy() { +} + +FileSystemQuotaUtil::FileSystemQuotaUtil(base::MessageLoopProxy* file_thread) + : proxy_(new Proxy(ALLOW_THIS_IN_INITIALIZER_LIST(this), file_thread)) { +} + +FileSystemQuotaUtil::~FileSystemQuotaUtil() { + proxy_->quota_util_ = NULL; +} + +} // namespace fileapi |