summaryrefslogtreecommitdiffstats
path: root/webkit/quota
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 04:10:10 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 04:10:10 +0000
commitbcbd98de32206864af45a2c6a41bf76d8fcb7cf4 (patch)
tree4910e337917f638e0dc40eff160a0e573aefe54e /webkit/quota
parent58d9fe56a31875c85168c8b7264099900ea397b5 (diff)
downloadchromium_src-bcbd98de32206864af45a2c6a41bf76d8fcb7cf4.zip
chromium_src-bcbd98de32206864af45a2c6a41bf76d8fcb7cf4.tar.gz
chromium_src-bcbd98de32206864af45a2c6a41bf76d8fcb7cf4.tar.bz2
Change webkit/{fileapi,quota} code to use TaskRunner.
BUG=123559 TEST=existing tests Review URL: https://chromiumcodereview.appspot.com/10197007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota')
-rw-r--r--webkit/quota/mock_quota_manager.cc11
-rw-r--r--webkit/quota/mock_quota_manager.h4
-rw-r--r--webkit/quota/quota_manager.cc9
-rw-r--r--webkit/quota/quota_manager.h20
-rw-r--r--webkit/quota/quota_task.cc22
-rw-r--r--webkit/quota/quota_task.h23
-rw-r--r--webkit/quota/usage_tracker.cc6
7 files changed, 50 insertions, 45 deletions
diff --git a/webkit/quota/mock_quota_manager.cc b/webkit/quota/mock_quota_manager.cc
index 595c43a..535fb65 100644
--- a/webkit/quota/mock_quota_manager.cc
+++ b/webkit/quota/mock_quota_manager.cc
@@ -10,11 +10,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/single_thread_task_runner.h"
#include "googleurl/src/gurl.h"
-#include "webkit/quota/quota_client.h"
-#include "webkit/quota/quota_manager.h"
-#include "webkit/quota/quota_task.h"
-#include "webkit/quota/quota_types.h"
namespace quota {
@@ -24,7 +21,7 @@ class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask {
const std::set<GURL>& origins,
StorageType type,
const GetOriginsCallback& callback)
- : QuotaThreadTask(manager, manager->io_thread_),
+ : QuotaThreadTask(manager, manager->io_thread_.get()),
origins_(origins),
type_(type),
callback_(callback) {
@@ -96,8 +93,8 @@ MockQuotaManager::OriginInfo::~OriginInfo() {}
MockQuotaManager::MockQuotaManager(
bool is_incognito,
const FilePath& profile_path,
- base::MessageLoopProxy* io_thread,
- base::MessageLoopProxy* db_thread,
+ base::SingleThreadTaskRunner* io_thread,
+ base::SequencedTaskRunner* db_thread,
SpecialStoragePolicy* special_storage_policy)
: QuotaManager(is_incognito, profile_path, io_thread, db_thread,
special_storage_policy) {
diff --git a/webkit/quota/mock_quota_manager.h b/webkit/quota/mock_quota_manager.h
index dac1eff..92b9273 100644
--- a/webkit/quota/mock_quota_manager.h
+++ b/webkit/quota/mock_quota_manager.h
@@ -43,8 +43,8 @@ class MockQuotaManager : public QuotaManager {
MockQuotaManager(bool is_incognito,
const FilePath& profile_path,
- base::MessageLoopProxy* io_thread,
- base::MessageLoopProxy* db_thread,
+ base::SingleThreadTaskRunner* io_thread,
+ base::SequencedTaskRunner* db_thread,
SpecialStoragePolicy* special_storage_policy);
// Adds an origin to the canned list that will be searched through via
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index 031aa9d..7d4669f 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -12,7 +12,8 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
-#include "base/message_loop_proxy.h"
+#include "base/sequenced_task_runner.h"
+#include "base/single_thread_task_runner.h"
#include "base/metrics/histogram.h"
#include "base/string_number_conversions.h"
#include "base/sys_info.h"
@@ -1181,8 +1182,8 @@ class QuotaManager::DumpOriginInfoTableTask
QuotaManager::QuotaManager(bool is_incognito,
const FilePath& profile_path,
- base::MessageLoopProxy* io_thread,
- base::MessageLoopProxy* db_thread,
+ base::SingleThreadTaskRunner* io_thread,
+ base::SequencedTaskRunner* db_thread,
SpecialStoragePolicy* special_storage_policy)
: is_incognito_(is_incognito),
profile_path_(profile_path),
@@ -1823,7 +1824,7 @@ QuotaManager* QuotaManagerProxy::quota_manager() const {
}
QuotaManagerProxy::QuotaManagerProxy(
- QuotaManager* manager, base::MessageLoopProxy* io_thread)
+ QuotaManager* manager, base::SingleThreadTaskRunner* io_thread)
: manager_(manager), io_thread_(io_thread) {
}
diff --git a/webkit/quota/quota_manager.h b/webkit/quota/quota_manager.h
index b86cbfd..1566177 100644
--- a/webkit/quota/quota_manager.h
+++ b/webkit/quota/quota_manager.h
@@ -18,12 +18,12 @@
#include "base/callback.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner_helpers.h"
-#include "webkit/quota/quota_database.h"
#include "webkit/quota/quota_client.h"
+#include "webkit/quota/quota_database.h"
#include "webkit/quota/quota_task.h"
#include "webkit/quota/quota_types.h"
#include "webkit/quota/special_storage_policy.h"
@@ -31,7 +31,8 @@
class FilePath;
namespace base {
-class MessageLoopProxy;
+class SequencedTaskRunner;
+class SingleThreadTaskRunner;
}
namespace quota_internals {
@@ -106,8 +107,8 @@ class QuotaManager : public QuotaTaskObserver,
QuotaManager(bool is_incognito,
const FilePath& profile_path,
- base::MessageLoopProxy* io_thread,
- base::MessageLoopProxy* db_thread,
+ base::SingleThreadTaskRunner* io_thread,
+ base::SequencedTaskRunner* db_thread,
SpecialStoragePolicy* special_storage_policy);
// Returns a proxy object that can be used on any thread.
@@ -352,8 +353,8 @@ class QuotaManager : public QuotaTaskObserver,
scoped_refptr<QuotaManagerProxy> proxy_;
bool db_disabled_;
bool eviction_disabled_;
- scoped_refptr<base::MessageLoopProxy> io_thread_;
- scoped_refptr<base::MessageLoopProxy> db_thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
+ scoped_refptr<base::SequencedTaskRunner> db_thread_;
mutable scoped_ptr<QuotaDatabase> database_;
GetLRUOriginCallback lru_origin_callback_;
@@ -418,11 +419,12 @@ class QuotaManagerProxy
friend class QuotaManager;
friend class base::RefCountedThreadSafe<QuotaManagerProxy>;
- QuotaManagerProxy(QuotaManager* manager, base::MessageLoopProxy* io_thread);
+ QuotaManagerProxy(QuotaManager* manager,
+ base::SingleThreadTaskRunner* io_thread);
virtual ~QuotaManagerProxy();
QuotaManager* manager_; // only accessed on the io thread
- scoped_refptr<base::MessageLoopProxy> io_thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
};
diff --git a/webkit/quota/quota_task.cc b/webkit/quota/quota_task.cc
index 28d275f..27542d7 100644
--- a/webkit/quota/quota_task.cc
+++ b/webkit/quota/quota_task.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -8,10 +8,12 @@
#include <functional>
#include "base/bind.h"
+#include "base/location.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
-using base::MessageLoopProxy;
+using base::TaskRunner;
namespace quota {
@@ -28,11 +30,11 @@ void QuotaTask::Start() {
QuotaTask::QuotaTask(QuotaTaskObserver* observer)
: observer_(observer),
- original_message_loop_(MessageLoopProxy::current()) {
+ original_task_runner_(base::MessageLoopProxy::current()) {
}
void QuotaTask::CallCompleted() {
- DCHECK(original_message_loop_->BelongsToCurrentThread());
+ DCHECK(original_task_runner_->BelongsToCurrentThread());
if (observer_) {
observer_->UnregisterTask(this);
Completed();
@@ -40,7 +42,7 @@ void QuotaTask::CallCompleted() {
}
void QuotaTask::Abort() {
- DCHECK(original_message_loop_->BelongsToCurrentThread());
+ DCHECK(original_task_runner_->BelongsToCurrentThread());
observer_ = NULL;
Aborted();
}
@@ -53,24 +55,24 @@ void QuotaTask::DeleteSoon() {
QuotaThreadTask::QuotaThreadTask(
QuotaTaskObserver* observer,
- scoped_refptr<MessageLoopProxy> target_message_loop)
+ TaskRunner* target_task_runner)
: QuotaTask(observer),
- target_message_loop_(target_message_loop) {
+ target_task_runner_(target_task_runner) {
}
QuotaThreadTask::~QuotaThreadTask() {
}
void QuotaThreadTask::Run() {
- target_message_loop_->PostTask(
+ target_task_runner_->PostTask(
FROM_HERE,
base::Bind(&QuotaThreadTask::CallRunOnTargetThread, this));
}
void QuotaThreadTask::CallRunOnTargetThread() {
- DCHECK(target_message_loop_->BelongsToCurrentThread());
+ DCHECK(target_task_runner_->RunsTasksOnCurrentThread());
if (RunOnTargetThreadAsync())
- original_message_loop()->PostTask(
+ original_task_runner()->PostTask(
FROM_HERE,
base::Bind(&QuotaThreadTask::CallCompleted, this));
}
diff --git a/webkit/quota/quota_task.h b/webkit/quota/quota_task.h
index dbd5ca04..ae9b2f1 100644
--- a/webkit/quota/quota_task.h
+++ b/webkit/quota/quota_task.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -11,17 +11,19 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop_proxy.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
+class TaskRunner;
}
namespace quota {
class QuotaTaskObserver;
+class QuotaThreadTask;
// A base class for quota tasks.
+// TODO(kinuko): Revise this using base::Callback.
class QuotaTask {
public:
virtual ~QuotaTask();
@@ -45,15 +47,16 @@ class QuotaTask {
void DeleteSoon();
QuotaTaskObserver* observer() const { return observer_; }
- scoped_refptr<base::MessageLoopProxy> original_message_loop() const {
- return original_message_loop_;
+ base::SingleThreadTaskRunner* original_task_runner() const {
+ return original_task_runner_;
}
private:
friend class QuotaTaskObserver;
+ friend class QuotaThreadTask;
void Abort();
QuotaTaskObserver* observer_;
- scoped_refptr<base::MessageLoopProxy> original_message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_;
};
// For tasks that post tasks to the other thread.
@@ -61,7 +64,7 @@ class QuotaThreadTask : public QuotaTask,
public base::RefCountedThreadSafe<QuotaThreadTask> {
public:
QuotaThreadTask(QuotaTaskObserver* observer,
- scoped_refptr<base::MessageLoopProxy> target_message_loop);
+ base::TaskRunner* target_task_runner);
protected:
virtual ~QuotaThreadTask();
@@ -80,8 +83,8 @@ class QuotaThreadTask : public QuotaTask,
virtual bool RunOnTargetThreadAsync();
virtual void Run() OVERRIDE;
- scoped_refptr<base::MessageLoopProxy> target_message_loop() const {
- return target_message_loop_;
+ base::TaskRunner* target_task_runner() const {
+ return target_task_runner_;
}
private:
@@ -89,7 +92,7 @@ class QuotaThreadTask : public QuotaTask,
friend class QuotaTaskObserver;
void CallRunOnTargetThread();
- scoped_refptr<base::MessageLoopProxy> target_message_loop_;
+ scoped_refptr<base::TaskRunner> target_task_runner_;
};
class QuotaTaskObserver {
diff --git a/webkit/quota/usage_tracker.cc b/webkit/quota/usage_tracker.cc
index 0eb2411..0b22e70 100644
--- a/webkit/quota/usage_tracker.cc
+++ b/webkit/quota/usage_tracker.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -43,7 +43,7 @@ class ClientUsageTracker::GatherUsageTaskBase : public QuotaTask {
// Get total usage for the given |origins|.
void GetUsageForOrigins(const std::set<GURL>& origins, StorageType type) {
- DCHECK(original_message_loop()->BelongsToCurrentThread());
+ DCHECK(original_task_runner()->BelongsToCurrentThread());
// We do not get usage for origins for which we have valid usage cache.
std::vector<GURL> origins_to_gather;
std::set<GURL> cached_origins;
@@ -91,7 +91,7 @@ class ClientUsageTracker::GatherUsageTaskBase : public QuotaTask {
private:
void DidGetUsage(int64 usage) {
- DCHECK(original_message_loop()->BelongsToCurrentThread());
+ DCHECK(original_task_runner()->BelongsToCurrentThread());
DCHECK(!pending_origins_.empty());
DCHECK(client_tracker_);