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

Unified Diff: webkit/browser/quota/quota_manager.cc

Issue 136573007: Quota: Factor out (Mock)QuotaManagerProxy into its own file for readability (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/browser/quota/quota_manager.h ('k') | webkit/browser/quota/quota_manager_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/quota/quota_manager.cc
diff --git a/webkit/browser/quota/quota_manager.cc b/webkit/browser/quota/quota_manager.cc
index 0663935a214a90756c9bc761b55034e3a873894e..bc94ff7fcae78df74bfedfb09b12e1cb4d5a76f6 100644
--- a/webkit/browser/quota/quota_manager.cc
+++ b/webkit/browser/quota/quota_manager.cc
@@ -24,6 +24,7 @@
#include "base/time/time.h"
#include "net/base/net_util.h"
#include "webkit/browser/quota/quota_database.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/quota/quota_temporary_storage_evictor.h"
#include "webkit/browser/quota/usage_tracker.h"
#include "webkit/common/quota/quota_types.h"
@@ -43,21 +44,6 @@ const int kMinutesInMilliSeconds = 60 * 1000;
const int64 kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33%
-void DidGetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const QuotaManagerProxy::GetUsageAndQuotaCallback& callback,
- QuotaStatusCode status, int64 usage, int64 quota) {
- if (!original_task_runner->RunsTasksOnCurrentThread()) {
- original_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&DidGetUsageAndQuota,
- make_scoped_refptr(original_task_runner),
- callback, status, usage, quota));
- return;
- }
- callback.Run(status, usage, quota);
-}
-
} // namespace
// Arbitrary for now, but must be reasonably small so that
@@ -1605,130 +1591,4 @@ void QuotaManager::PostTaskAndReplyWithResultForDBThread(
reply);
}
-// QuotaManagerProxy ----------------------------------------------------------
-
-void QuotaManagerProxy::RegisterClient(QuotaClient* client) {
- if (!io_thread_->BelongsToCurrentThread() &&
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::RegisterClient, this, client))) {
- return;
- }
-
- if (manager_)
- manager_->RegisterClient(client);
- else
- client->OnQuotaManagerDestroyed();
-}
-
-void QuotaManagerProxy::NotifyStorageAccessed(
- QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyStorageAccessed, this, client_id,
- origin, type));
- return;
- }
-
- if (manager_)
- manager_->NotifyStorageAccessed(client_id, origin, type);
-}
-
-void QuotaManagerProxy::NotifyStorageModified(
- QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- int64 delta) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyStorageModified, this, client_id,
- origin, type, delta));
- return;
- }
-
- if (manager_)
- manager_->NotifyStorageModified(client_id, origin, type, delta);
-}
-
-void QuotaManagerProxy::NotifyOriginInUse(
- const GURL& origin) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyOriginInUse, this, origin));
- return;
- }
-
- if (manager_)
- manager_->NotifyOriginInUse(origin);
-}
-
-void QuotaManagerProxy::NotifyOriginNoLongerInUse(
- const GURL& origin) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyOriginNoLongerInUse, this,
- origin));
- return;
- }
- if (manager_)
- manager_->NotifyOriginNoLongerInUse(origin);
-}
-
-void QuotaManagerProxy::SetUsageCacheEnabled(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- bool enabled) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::SetUsageCacheEnabled, this,
- client_id, origin, type, enabled));
- return;
- }
- if (manager_)
- manager_->SetUsageCacheEnabled(client_id, origin, type, enabled);
-}
-
-void QuotaManagerProxy::GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- StorageType type,
- const GetUsageAndQuotaCallback& callback) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::GetUsageAndQuota, this,
- make_scoped_refptr(original_task_runner),
- origin, type, callback));
- return;
- }
- if (!manager_) {
- DidGetUsageAndQuota(original_task_runner, callback, kQuotaErrorAbort, 0, 0);
- return;
- }
- manager_->GetUsageAndQuota(
- origin, type,
- base::Bind(&DidGetUsageAndQuota,
- make_scoped_refptr(original_task_runner), callback));
-}
-
-QuotaManager* QuotaManagerProxy::quota_manager() const {
- DCHECK(!io_thread_.get() || io_thread_->BelongsToCurrentThread());
- return manager_;
-}
-
-QuotaManagerProxy::QuotaManagerProxy(
- QuotaManager* manager, base::SingleThreadTaskRunner* io_thread)
- : manager_(manager), io_thread_(io_thread) {
-}
-
-QuotaManagerProxy::~QuotaManagerProxy() {
-}
-
} // namespace quota
« no previous file with comments | « webkit/browser/quota/quota_manager.h ('k') | webkit/browser/quota/quota_manager_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698