summaryrefslogtreecommitdiffstats
path: root/webkit/quota
diff options
context:
space:
mode:
authorcalvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 05:41:48 +0000
committercalvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 05:41:48 +0000
commitdba4cf471b6cdb8f6830f9088db6ef64b4ecc8e7 (patch)
treeb26d2185cf291c8a3ea45e3530dfbf0bedf1612c /webkit/quota
parent25a58ce0a6d6b6f08da9da374074463662175285 (diff)
downloadchromium_src-dba4cf471b6cdb8f6830f9088db6ef64b4ecc8e7.zip
chromium_src-dba4cf471b6cdb8f6830f9088db6ef64b4ecc8e7.tar.gz
chromium_src-dba4cf471b6cdb8f6830f9088db6ef64b4ecc8e7.tar.bz2
Converted DeleteOriginDataTask and GetModifiedSinceTask to use PostTaskAndReply(). These are the last two references to QuotaThreadTask in webkit/fileapi.
BUG=139270 Review URL: https://chromiumcodereview.appspot.com/11045018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota')
-rw-r--r--webkit/quota/mock_quota_manager.cc101
-rw-r--r--webkit/quota/mock_quota_manager.h10
2 files changed, 39 insertions, 72 deletions
diff --git a/webkit/quota/mock_quota_manager.cc b/webkit/quota/mock_quota_manager.cc
index 34bd3b0..4904f453 100644
--- a/webkit/quota/mock_quota_manager.cc
+++ b/webkit/quota/mock_quota_manager.cc
@@ -10,73 +10,12 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "googleurl/src/gurl.h"
namespace quota {
-class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask {
- public:
- GetModifiedSinceTask(MockQuotaManager* manager,
- const std::set<GURL>& origins,
- StorageType type,
- const GetOriginsCallback& callback)
- : QuotaThreadTask(manager, manager->io_thread_.get()),
- origins_(origins),
- type_(type),
- callback_(callback) {
- }
-
- protected:
- virtual ~GetModifiedSinceTask() {}
-
- // QuotaThreadTask:
- virtual void RunOnTargetThread() OVERRIDE {}
-
- virtual void Completed() OVERRIDE {
- callback_.Run(origins_, type_);
- }
-
- virtual void Aborted() OVERRIDE {
- callback_.Run(std::set<GURL>(), type_);
- }
-
- private:
- std::set<GURL> origins_;
- StorageType type_;
- GetOriginsCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask);
-};
-
-class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask {
- public:
- DeleteOriginDataTask(MockQuotaManager* manager,
- const StatusCallback& callback)
- : QuotaThreadTask(manager, manager->io_thread_),
- callback_(callback) {
- }
-
- protected:
- virtual ~DeleteOriginDataTask() {}
-
- // QuotaThreadTask:
- virtual void RunOnTargetThread() OVERRIDE {}
-
- virtual void Completed() OVERRIDE {
- callback_.Run(quota::kQuotaStatusOk);
- }
-
- virtual void Aborted() OVERRIDE {
- callback_.Run(quota::kQuotaErrorAbort);
- }
-
- private:
- StatusCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(DeleteOriginDataTask);
-};
-
MockQuotaManager::OriginInfo::OriginInfo(
const GURL& origin,
StorageType type,
@@ -102,7 +41,8 @@ MockQuotaManager::MockQuotaManager(
base::SequencedTaskRunner* db_thread,
SpecialStoragePolicy* special_storage_policy)
: QuotaManager(is_incognito, profile_path, io_thread, db_thread,
- special_storage_policy) {
+ special_storage_policy),
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
void MockQuotaManager::GetUsageAndQuota(
@@ -146,15 +86,21 @@ void MockQuotaManager::GetOriginsModifiedSince(
StorageType type,
base::Time modified_since,
const GetOriginsCallback& callback) {
- std::set<GURL> origins_to_return;
+ std::set<GURL>* origins_to_return = new std::set<GURL>();
for (std::vector<OriginInfo>::const_iterator current = origins_.begin();
current != origins_.end();
++current) {
if (current->type == type && current->modified >= modified_since)
- origins_to_return.insert(current->origin);
+ origins_to_return->insert(current->origin);
}
- make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type,
- callback))->Start();
+
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockQuotaManager::DidGetModifiedSince,
+ weak_factory_.GetWeakPtr(),
+ callback,
+ base::Owned(origins_to_return),
+ type));
}
void MockQuotaManager::DeleteOriginData(
@@ -173,7 +119,13 @@ void MockQuotaManager::DeleteOriginData(
break;
}
}
- make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start();
+
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MockQuotaManager::DidDeleteOriginData,
+ weak_factory_.GetWeakPtr(),
+ callback,
+ kQuotaStatusOk));
}
MockQuotaManager::~MockQuotaManager() {}
@@ -183,6 +135,19 @@ void MockQuotaManager::UpdateUsage(
usage_and_quota_map_[std::make_pair(origin, type)].usage += delta;
}
+void MockQuotaManager::DidGetModifiedSince(
+ const GetOriginsCallback& callback,
+ std::set<GURL>* origins,
+ StorageType storage_type) {
+ callback.Run(*origins, storage_type);
+}
+
+void MockQuotaManager::DidDeleteOriginData(
+ const StatusCallback& callback,
+ QuotaStatusCode status) {
+ callback.Run(status);
+}
+
// MockQuotaManagerProxy -----------------------------------------------------
MockQuotaManagerProxy::MockQuotaManagerProxy(
diff --git a/webkit/quota/mock_quota_manager.h b/webkit/quota/mock_quota_manager.h
index b52ac2f..013fef9 100644
--- a/webkit/quota/mock_quota_manager.h
+++ b/webkit/quota/mock_quota_manager.h
@@ -121,15 +121,17 @@ class MockQuotaManager : public QuotaManager {
typedef std::pair<GURL, StorageType> OriginAndType;
typedef std::map<OriginAndType, StorageInfo> UsageAndQuotaMap;
- class GetModifiedSinceTask;
- class DeleteOriginDataTask;
-
// This must be called via MockQuotaManagerProxy.
void UpdateUsage(const GURL& origin, StorageType type, int64 delta);
+ void DidGetModifiedSince(const GetOriginsCallback& callback,
+ std::set<GURL>* origins,
+ StorageType storage_type);
+ void DidDeleteOriginData(const StatusCallback& callback,
+ QuotaStatusCode status);
// The list of stored origins that have been added via AddOrigin.
std::vector<OriginInfo> origins_;
-
+ base::WeakPtrFactory<MockQuotaManager> weak_factory_;
UsageAndQuotaMap usage_and_quota_map_;
DISALLOW_COPY_AND_ASSIGN(MockQuotaManager);