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

Unified Diff: chrome/browser/chromeos/drive/sync_client_unittest.cc

Issue 1124813003: [chrome/browser/chromeos/drive] Avoid use of MessageLoopProxy by use of TTRH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
Index: chrome/browser/chromeos/drive/sync_client_unittest.cc
diff --git a/chrome/browser/chromeos/drive/sync_client_unittest.cc b/chrome/browser/chromeos/drive/sync_client_unittest.cc
index d30e34c942488b43b0d6a246e4847690a7d20ab8..89d677745dfe9a96587d8c652cba3e003a37e322 100644
--- a/chrome/browser/chromeos/drive/sync_client_unittest.cc
+++ b/chrome/browser/chromeos/drive/sync_client_unittest.cc
@@ -10,7 +10,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
#include "base/test/test_timeouts.h"
+#include "base/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/drive/change_list_loader.h"
#include "chrome/browser/chromeos/drive/drive.pb.h"
#include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
@@ -57,10 +59,9 @@ class SyncClientTestDriveService : public ::drive::FakeDriveService {
const google_apis::ProgressCallback& progress_callback) override {
++download_file_count_;
if (resource_id == resource_id_to_be_cancelled_) {
- base::MessageLoopProxy::current()->PostTask(
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(download_action_callback,
- google_apis::DRIVE_CANCELLED,
+ base::Bind(download_action_callback, google_apis::DRIVE_CANCELLED,
base::FilePath()));
return google_apis::CancelCallback();
}
@@ -113,44 +114,36 @@ class SyncClientTest : public testing::Test {
drive_service_.reset(new SyncClientTestDriveService);
- scheduler_.reset(new JobScheduler(pref_service_.get(),
- logger_.get(),
+ scheduler_.reset(new JobScheduler(pref_service_.get(), logger_.get(),
drive_service_.get(),
- base::MessageLoopProxy::current().get()));
+ base::ThreadTaskRunnerHandle::Get()));
metadata_storage_.reset(new ResourceMetadataStorage(
- temp_dir_.path(), base::MessageLoopProxy::current().get()));
+ temp_dir_.path(), base::ThreadTaskRunnerHandle::Get()));
ASSERT_TRUE(metadata_storage_->Initialize());
- cache_.reset(new FileCache(metadata_storage_.get(),
- temp_dir_.path(),
- base::MessageLoopProxy::current().get(),
+ cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.path(),
+ base::ThreadTaskRunnerHandle::Get(),
NULL /* free_disk_space_getter */));
ASSERT_TRUE(cache_->Initialize());
- metadata_.reset(new internal::ResourceMetadata(
- metadata_storage_.get(), cache_.get(),
- base::MessageLoopProxy::current()));
+ metadata_.reset(
+ new internal::ResourceMetadata(metadata_storage_.get(), cache_.get(),
+ base::ThreadTaskRunnerHandle::Get()));
ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize());
about_resource_loader_.reset(new AboutResourceLoader(scheduler_.get()));
loader_controller_.reset(new LoaderController);
change_list_loader_.reset(new ChangeListLoader(
- logger_.get(),
- base::MessageLoopProxy::current().get(),
- metadata_.get(),
- scheduler_.get(),
- about_resource_loader_.get(),
+ logger_.get(), base::ThreadTaskRunnerHandle::Get(), metadata_.get(),
+ scheduler_.get(), about_resource_loader_.get(),
loader_controller_.get()));
ASSERT_NO_FATAL_FAILURE(SetUpTestData());
- sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(),
- &delegate_,
- scheduler_.get(),
- metadata_.get(),
- cache_.get(),
- loader_controller_.get(),
- temp_dir_.path()));
+ sync_client_.reset(
+ new SyncClient(base::ThreadTaskRunnerHandle::Get(), &delegate_,
+ scheduler_.get(), metadata_.get(), cache_.get(),
+ loader_controller_.get(), temp_dir_.path()));
// Disable delaying so that DoSyncLoop() starts immediately.
sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0));
@@ -217,7 +210,7 @@ class SyncClientTest : public testing::Test {
// Prepare a removed file.
file_system::RemoveOperation remove_operation(
- base::MessageLoopProxy::current().get(), &delegate_, metadata_.get(),
+ base::ThreadTaskRunnerHandle::Get(), &delegate_, metadata_.get(),
cache_.get());
remove_operation.Remove(
util::GetDriveMyDriveRootPath().AppendASCII("removed"),
@@ -228,7 +221,7 @@ class SyncClientTest : public testing::Test {
// Prepare a moved file.
file_system::MoveOperation move_operation(
- base::MessageLoopProxy::current().get(), &delegate_, metadata_.get());
+ base::ThreadTaskRunnerHandle::Get(), &delegate_, metadata_.get());
move_operation.Move(
util::GetDriveMyDriveRootPath().AppendASCII("moved"),
util::GetDriveMyDriveRootPath().AppendASCII("moved_new_title"),
@@ -387,7 +380,7 @@ TEST_F(SyncClientTest, RetryOnDisconnection) {
// FILE_ERROR_NO_CONNECTION is handled by SyncClient correctly.
// Without this delay, JobScheduler will keep the jobs unrun and SyncClient
// will receive no error.
- base::MessageLoopProxy::current()->PostDelayedTask(
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&test_util::FakeNetworkChangeNotifier::SetConnectionType,
base::Unretained(fake_network_change_notifier_.get()),

Powered by Google App Engine
This is Rietveld 408576698