summaryrefslogtreecommitdiffstats
path: root/content/browser/cache_storage
diff options
context:
space:
mode:
authorskyostil <skyostil@chromium.org>2015-06-05 12:53:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-05 19:53:37 +0000
commit95082a6a47108c4e20a77cc224172a293065ab05 (patch)
treec34e72f82cf4742097c92a500fabd9af0f251cef /content/browser/cache_storage
parent4e95f763c7f52664c94373b7d9fcc0ed96c7f019 (diff)
downloadchromium_src-95082a6a47108c4e20a77cc224172a293065ab05.zip
chromium_src-95082a6a47108c4e20a77cc224172a293065ab05.tar.gz
chromium_src-95082a6a47108c4e20a77cc224172a293065ab05.tar.bz2
content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
This patch was mostly autogenerated with https://codereview.chromium.org/1010073002/. BUG=465354 TBR=nick@chromium.org Committed: https://crrev.com/422456f9d53f0bf936a64f21a1463fd0abd3df84 Cr-Commit-Position: refs/heads/master@{#333081} Review URL: https://codereview.chromium.org/1159623009 Cr-Commit-Position: refs/heads/master@{#333112}
Diffstat (limited to 'content/browser/cache_storage')
-rw-r--r--content/browser/cache_storage/cache_storage.cc23
-rw-r--r--content/browser/cache_storage/cache_storage_cache.cc3
-rw-r--r--content/browser/cache_storage/cache_storage_cache_unittest.cc13
-rw-r--r--content/browser/cache_storage/cache_storage_manager_unittest.cc8
-rw-r--r--content/browser/cache_storage/cache_storage_scheduler.cc6
5 files changed, 28 insertions, 25 deletions
diff --git a/content/browser/cache_storage/cache_storage.cc b/content/browser/cache_storage/cache_storage.cc
index a6a32b9..24cc38b 100644
--- a/content/browser/cache_storage/cache_storage.cc
+++ b/content/browser/cache_storage/cache_storage.cc
@@ -9,12 +9,15 @@
#include "base/barrier_closure.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
+#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "base/sha1.h"
+#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
+#include "base/thread_task_runner_handle.h"
#include "content/browser/cache_storage/cache_storage.pb.h"
#include "content/browser/cache_storage/cache_storage_cache.h"
#include "content/browser/cache_storage/cache_storage_scheduler.h"
@@ -225,15 +228,15 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader {
cache_task_runner_->PostTask(
FROM_HERE,
base::Bind(&SimpleCacheLoader::CleanUpDeleteCacheDirInPool, cache_path,
- callback, base::MessageLoopProxy::current()));
+ callback, base::ThreadTaskRunnerHandle::Get()));
}
static void CleanUpDeleteCacheDirInPool(
const base::FilePath& cache_path,
const BoolCallback& callback,
- const scoped_refptr<base::MessageLoopProxy>& original_loop) {
+ const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) {
bool rv = base::DeleteFile(cache_path, true);
- original_loop->PostTask(FROM_HERE, base::Bind(callback, rv));
+ original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv));
}
void WriteIndex(const StringVector& cache_names,
@@ -262,7 +265,7 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader {
cache_task_runner_->PostTask(
FROM_HERE, base::Bind(&SimpleCacheLoader::WriteIndexWriteToFileInPool,
tmp_path, index_path, serialized, callback,
- base::MessageLoopProxy::current()));
+ base::ThreadTaskRunnerHandle::Get()));
}
static void WriteIndexWriteToFileInPool(
@@ -270,16 +273,16 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader {
const base::FilePath& index_path,
const std::string& data,
const BoolCallback& callback,
- const scoped_refptr<base::MessageLoopProxy>& original_loop) {
+ const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) {
int bytes_written = base::WriteFile(tmp_path, data.c_str(), data.size());
if (bytes_written != implicit_cast<int>(data.size())) {
base::DeleteFile(tmp_path, /* recursive */ false);
- original_loop->PostTask(FROM_HERE, base::Bind(callback, false));
+ original_task_runner->PostTask(FROM_HERE, base::Bind(callback, false));
}
// Atomically rename the temporary index file to become the real one.
bool rv = base::ReplaceFile(tmp_path, index_path, NULL);
- original_loop->PostTask(FROM_HERE, base::Bind(callback, rv));
+ original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv));
}
void LoadIndex(scoped_ptr<std::vector<std::string>> names,
@@ -295,18 +298,18 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader {
cache_task_runner_->PostTask(
FROM_HERE, base::Bind(&SimpleCacheLoader::LoadIndexReadFileInPool,
index_path, base::Passed(names.Pass()), callback,
- base::MessageLoopProxy::current()));
+ base::ThreadTaskRunnerHandle::Get()));
}
static void LoadIndexReadFileInPool(
const base::FilePath& index_path,
scoped_ptr<std::vector<std::string>> names,
const StringVectorCallback& callback,
- const scoped_refptr<base::MessageLoopProxy>& original_loop) {
+ const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) {
std::string body;
base::ReadFileToString(index_path, &body);
- original_loop->PostTask(
+ original_task_runner->PostTask(
FROM_HERE, base::Bind(&SimpleCacheLoader::LoadIndexDidReadFile,
base::Passed(names.Pass()), callback, body));
}
diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc
index 279dfc3..ab57e30 100644
--- a/content/browser/cache_storage/cache_storage_cache.cc
+++ b/content/browser/cache_storage/cache_storage_cache.cc
@@ -9,7 +9,6 @@
#include "base/barrier_closure.h"
#include "base/files/file_path.h"
#include "base/guid.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "content/browser/cache_storage/cache_storage.pb.h"
@@ -1180,7 +1179,7 @@ void CacheStorageCache::CreateBackend(const ErrorCallback& callback) {
weak_ptr_factory_.GetWeakPtr(), callback,
base::Passed(backend_ptr.Pass()));
- // TODO(jkarlin): Use the cache MessageLoopProxy that ServiceWorkerCacheCore
+ // TODO(jkarlin): Use the cache task runner that ServiceWorkerCacheCore
// has for disk caches.
int rv = disk_cache::CreateCacheBackend(
cache_type, net::CACHE_BACKEND_SIMPLE, path_, kMaxCacheBytes,
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc
index 57350d2..2f11ab7 100644
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -6,9 +6,9 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/strings/string_split.h"
+#include "base/thread_task_runner_handle.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/fileapi/mock_url_request_delegate.h"
#include "content/browser/quota/mock_quota_manager_proxy.h"
@@ -38,10 +38,10 @@ const char kTestData[] = "Hello World";
// the memory.
storage::BlobProtocolHandler* CreateMockBlobProtocolHandler(
storage::BlobStorageContext* blob_storage_context) {
- // The FileSystemContext and MessageLoopProxy are not actually used but a
- // MessageLoopProxy is needed to avoid a DCHECK in BlobURLRequestJob ctor.
+ // The FileSystemContext and thread task runner are not actually used but a
+ // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor.
return new storage::BlobProtocolHandler(
- blob_storage_context, NULL, base::MessageLoopProxy::current().get());
+ blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get());
}
// A disk_cache::Backend wrapper that can delay operations.
@@ -186,7 +186,7 @@ class CacheStorageCacheTest : public testing::Test {
blob_storage_context_ = blob_storage_context->context();
quota_manager_proxy_ = new MockQuotaManagerProxy(
- nullptr, base::MessageLoopProxy::current().get());
+ nullptr, base::ThreadTaskRunnerHandle::Get().get());
url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl);
url_request_job_factory_->SetProtocolHandler(
@@ -261,8 +261,7 @@ class CacheStorageCacheTest : public testing::Test {
base::Bind(&CacheStorageCacheTest::ErrorTypeCallback,
base::Unretained(this), base::Unretained(loop.get())));
// TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle()
- // once the cache uses a passed in MessageLoopProxy instead of the CACHE
- // thread.
+ // once the cache uses a passed in task runner instead of the CACHE thread.
loop->Run();
return callback_error_;
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc
index 4fb7e7f..61963b1 100644
--- a/content/browser/cache_storage/cache_storage_manager_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -7,9 +7,9 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
+#include "base/thread_task_runner_handle.h"
#include "content/browser/cache_storage/cache_storage_quota_client.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/quota/mock_quota_manager_proxy.h"
@@ -39,18 +39,18 @@ class CacheStorageManagerTest : public testing::Test {
base::RunLoop().RunUntilIdle();
quota_manager_proxy_ = new MockQuotaManagerProxy(
- nullptr, base::MessageLoopProxy::current().get());
+ nullptr, base::ThreadTaskRunnerHandle::Get().get());
net::URLRequestContext* url_request_context =
browser_context_.GetRequestContext()->GetURLRequestContext();
if (MemoryOnly()) {
cache_manager_ = CacheStorageManager::Create(
- base::FilePath(), base::MessageLoopProxy::current(),
+ base::FilePath(), base::ThreadTaskRunnerHandle::Get(),
quota_manager_proxy_);
} else {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
cache_manager_ = CacheStorageManager::Create(
- temp_dir_.path(), base::MessageLoopProxy::current(),
+ temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
quota_manager_proxy_);
}
diff --git a/content/browser/cache_storage/cache_storage_scheduler.cc b/content/browser/cache_storage/cache_storage_scheduler.cc
index 33447b9..86db5f2 100644
--- a/content/browser/cache_storage/cache_storage_scheduler.cc
+++ b/content/browser/cache_storage/cache_storage_scheduler.cc
@@ -9,7 +9,8 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
+#include "base/thread_task_runner_handle.h"
namespace content {
@@ -40,7 +41,8 @@ void CacheStorageScheduler::RunOperationIfIdle() {
// TODO(jkarlin): Run multiple operations in parallel where allowed.
base::Closure closure = pending_operations_.front();
pending_operations_.pop_front();
- base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(closure));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ base::Bind(closure));
}
}