| Index: webkit/appcache/appcache_storage_impl.cc
|
| ===================================================================
|
| --- webkit/appcache/appcache_storage_impl.cc (revision 100467)
|
| +++ webkit/appcache/appcache_storage_impl.cc (working copy)
|
| @@ -23,7 +23,6 @@
|
| #include "webkit/appcache/appcache_quota_client.h"
|
| #include "webkit/appcache/appcache_response.h"
|
| #include "webkit/appcache/appcache_service.h"
|
| -#include "webkit/appcache/appcache_thread.h"
|
| #include "webkit/quota/quota_client.h"
|
| #include "webkit/quota/quota_manager.h"
|
| #include "webkit/quota/special_storage_policy.h"
|
| @@ -125,7 +124,10 @@
|
| : public base::RefCountedThreadSafe<DatabaseTask> {
|
| public:
|
| explicit DatabaseTask(AppCacheStorageImpl* storage)
|
| - : storage_(storage), database_(storage->database_) {}
|
| + : storage_(storage), database_(storage->database_),
|
| + io_thread_(base::MessageLoopProxy::current()) {
|
| + DCHECK(io_thread_);
|
| + }
|
|
|
| virtual ~DatabaseTask() {}
|
|
|
| @@ -162,12 +164,14 @@
|
| void CallRun();
|
| void CallRunCompleted();
|
| void CallDisableStorage();
|
| +
|
| + scoped_refptr<base::MessageLoopProxy> io_thread_;
|
| };
|
|
|
| void AppCacheStorageImpl::DatabaseTask::Schedule() {
|
| DCHECK(storage_);
|
| - DCHECK(AppCacheThread::CurrentlyOn(AppCacheThread::io()));
|
| - if (AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE,
|
| + DCHECK(io_thread_->BelongsToCurrentThread());
|
| + if (storage_->db_thread_->PostTask(FROM_HERE,
|
| NewRunnableMethod(this, &DatabaseTask::CallRun))) {
|
| storage_->scheduled_database_tasks_.push_back(this);
|
| } else {
|
| @@ -176,27 +180,27 @@
|
| }
|
|
|
| void AppCacheStorageImpl::DatabaseTask::CancelCompletion() {
|
| - DCHECK(AppCacheThread::CurrentlyOn(AppCacheThread::io()));
|
| + DCHECK(io_thread_->BelongsToCurrentThread());
|
| delegates_.clear();
|
| storage_ = NULL;
|
| }
|
|
|
| void AppCacheStorageImpl::DatabaseTask::CallRun() {
|
| - DCHECK(AppCacheThread::CurrentlyOn(AppCacheThread::db()));
|
| + DCHECK(!io_thread_->BelongsToCurrentThread());
|
| if (!database_->is_disabled()) {
|
| Run();
|
| if (database_->is_disabled()) {
|
| - AppCacheThread::PostTask(AppCacheThread::io(), FROM_HERE,
|
| + io_thread_->PostTask(FROM_HERE,
|
| NewRunnableMethod(this, &DatabaseTask::CallDisableStorage));
|
| }
|
| }
|
| - AppCacheThread::PostTask(AppCacheThread::io(), FROM_HERE,
|
| + io_thread_->PostTask(FROM_HERE,
|
| NewRunnableMethod(this, &DatabaseTask::CallRunCompleted));
|
| }
|
|
|
| void AppCacheStorageImpl::DatabaseTask::CallRunCompleted() {
|
| if (storage_) {
|
| - DCHECK(AppCacheThread::CurrentlyOn(AppCacheThread::io()));
|
| + DCHECK(io_thread_->BelongsToCurrentThread());
|
| DCHECK(storage_->scheduled_database_tasks_.front() == this);
|
| storage_->scheduled_database_tasks_.pop_front();
|
| RunCompleted();
|
| @@ -206,7 +210,7 @@
|
|
|
| void AppCacheStorageImpl::DatabaseTask::CallDisableStorage() {
|
| if (storage_) {
|
| - DCHECK(AppCacheThread::CurrentlyOn(AppCacheThread::io()));
|
| + DCHECK(io_thread_->BelongsToCurrentThread());
|
| storage_->Disable();
|
| }
|
| }
|
| @@ -1158,8 +1162,7 @@
|
| std::mem_fun(&DatabaseTask::CancelCompletion));
|
|
|
| if (database_) {
|
| - AppCacheThread::PostTask(
|
| - AppCacheThread::db(),
|
| + db_thread_->PostTask(
|
| FROM_HERE,
|
| NewRunnableFunction(
|
| CleanUpOnDatabaseThread,
|
| @@ -1170,9 +1173,11 @@
|
| }
|
|
|
| void AppCacheStorageImpl::Initialize(const FilePath& cache_directory,
|
| + base::MessageLoopProxy* db_thread,
|
| base::MessageLoopProxy* cache_thread) {
|
| + DCHECK(db_thread);
|
| +
|
| cache_directory_ = cache_directory;
|
| - cache_thread_ = cache_thread;
|
| is_incognito_ = cache_directory_.empty();
|
|
|
| FilePath db_file_path;
|
| @@ -1180,6 +1185,9 @@
|
| db_file_path = cache_directory_.Append(kAppCacheDatabaseName);
|
| database_ = new AppCacheDatabase(db_file_path);
|
|
|
| + db_thread_ = db_thread;
|
| + cache_thread_ = cache_thread;
|
| +
|
| scoped_refptr<InitTask> task(new InitTask(this));
|
| task->Schedule();
|
| }
|
| @@ -1635,7 +1643,7 @@
|
| Disable();
|
| if (!is_incognito_) {
|
| VLOG(1) << "Deleting existing appcache data and starting over.";
|
| - AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE,
|
| + db_thread_->PostTask(FROM_HERE,
|
| NewRunnableFunction(DeleteDirectory, cache_directory_));
|
| }
|
| }
|
|
|