Remove some more unnecessary thread-affinity in components/sync/
This replaces most remaining ThreadTaskRunnerHandle/SingleThreadTaskRunner
by SequencedTaskRunnerHandler/SequencedTaskRunner. There are some places
that actually need thread-affinity (e.g. network stuff), or where it makes
sense (UIModelWorker which is specifically for running on the UI thread).
One remaining place I'm not sure about is WeakHandle.
Bug: 846238
Change-Id: I704406fbf2c462537971eda0102c40626503b793
Reviewed-on: https://chromium-review.googlesource.com/1151296
Reviewed-by: Mikel Astiz <mastiz@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578312}
diff --git a/components/sync/driver/async_directory_type_controller_unittest.cc b/components/sync/driver/async_directory_type_controller_unittest.cc
index 09a46145..f22493b 100644
--- a/components/sync/driver/async_directory_type_controller_unittest.cc
+++ b/components/sync/driver/async_directory_type_controller_unittest.cc
@@ -13,7 +13,7 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
+#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_timeouts.h"
@@ -99,7 +99,7 @@
SyncClient* sync_client,
AsyncDirectoryTypeControllerMock* mock,
SharedChangeProcessor* change_processor,
- scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner)
+ scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
: AsyncDirectoryTypeController(kType,
base::Closure(),
sync_client,
@@ -166,7 +166,7 @@
std::vector<PendingTask> pending_tasks_;
AsyncDirectoryTypeControllerMock* mock_;
scoped_refptr<SharedChangeProcessor> change_processor_;
- scoped_refptr<base::SingleThreadTaskRunner> backend_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
DISALLOW_COPY_AND_ASSIGN(AsyncDirectoryTypeControllerFake);
};
diff --git a/components/sync/driver/glue/sync_backend_host_impl.h b/components/sync/driver/glue/sync_backend_host_impl.h
index e451b53..65581639 100644
--- a/components/sync/driver/glue/sync_backend_host_impl.h
+++ b/components/sync/driver/glue/sync_backend_host_impl.h
@@ -201,7 +201,7 @@
SyncClient* const sync_client_;
// The task runner where all the sync engine operations happen.
- scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
// Name used for debugging (set from profile_->GetDebugName()).
const std::string name_;
diff --git a/components/sync/engine/net/http_bridge.cc b/components/sync/engine/net/http_bridge.cc
index 12268c3..299265a 100644
--- a/components/sync/engine/net/http_bridge.cc
+++ b/components/sync/engine/net/http_bridge.cc
@@ -15,7 +15,6 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "components/sync/base/cancelation_signal.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
@@ -393,11 +392,11 @@
RecordSyncResponseContentLengthHistograms(compressed_content_length,
original_content_length);
- // End of the line for url_poster_. It lives only on the IO loop.
- // We defer deletion because we're inside a callback from a component of the
- // URLFetcher, so it seems most natural / "polite" to let the stack unwind.
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
- fetch_state_.url_poster);
+ // End of the line for |fetch_state_.url_poster|. It lives only on the IO
+ // loop. We defer deletion because we're inside a callback from a component of
+ // the URLFetcher, so it seems most natural / "polite" to let the stack
+ // unwind.
+ network_task_runner_->DeleteSoon(FROM_HERE, fetch_state_.url_poster);
fetch_state_.url_poster = nullptr;
// Wake the blocked syncer thread in MakeSynchronousPost.
diff --git a/components/sync/engine/sync_backend_registrar_unittest.cc b/components/sync/engine/sync_backend_registrar_unittest.cc
index 5268ad39..b883921 100644
--- a/components/sync/engine/sync_backend_registrar_unittest.cc
+++ b/components/sync/engine/sync_backend_registrar_unittest.cc
@@ -7,7 +7,7 @@
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
+#include "base/sequenced_task_runner.h"
#include "base/threading/thread.h"
#include "components/sync/engine/passive_model_worker.h"
#include "components/sync/engine/sequenced_model_worker.h"
@@ -86,7 +86,7 @@
SyncBackendRegistrar* registrar() { return registrar_.get(); }
UserShare* user_share() { return test_user_share_.user_share(); }
- scoped_refptr<base::SingleThreadTaskRunner> db_task_runner() {
+ scoped_refptr<base::SequencedTaskRunner> db_task_runner() {
return db_thread_.task_runner();
}
diff --git a/components/sync/engine/sync_engine.h b/components/sync/engine/sync_engine.h
index 1af0ade..43f51f0 100644
--- a/components/sync/engine/sync_engine.h
+++ b/components/sync/engine/sync_engine.h
@@ -14,7 +14,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
+#include "base/sequenced_task_runner.h"
#include "base/time/time.h"
#include "components/sync/base/extensions_activity.h"
#include "components/sync/base/model_type.h"
@@ -54,7 +54,7 @@
InitParams(InitParams&& other);
~InitParams();
- scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner;
+ scoped_refptr<base::SequencedTaskRunner> sync_task_runner;
SyncEngineHost* host = nullptr;
std::unique_ptr<SyncBackendRegistrar> registrar;
std::unique_ptr<SyncEncryptionHandler::Observer> encryption_observer_proxy;
diff --git a/components/sync/model/model_type_store_test_util.cc b/components/sync/model/model_type_store_test_util.cc
index fe17a262..2e43d32f 100644
--- a/components/sync/model/model_type_store_test_util.cc
+++ b/components/sync/model/model_type_store_test_util.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "base/bind.h"
-#include "base/threading/thread_task_runner_handle.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "components/sync/base/model_type.h"
#include "components/sync/model_impl/blocking_model_type_store_impl.h"
#include "components/sync/model_impl/model_type_store_backend.h"
@@ -62,7 +62,7 @@
type,
std::make_unique<BlockingModelTypeStoreImpl>(
type, ModelTypeStoreBackend::GetOrCreateInMemoryForTest()),
- base::ThreadTaskRunnerHandle::Get());
+ base::SequencedTaskRunnerHandle::Get());
}
// static
diff --git a/components/sync/model/test_model_type_store_service.cc b/components/sync/model/test_model_type_store_service.cc
index ea506ea..f8be6fa9 100644
--- a/components/sync/model/test_model_type_store_service.cc
+++ b/components/sync/model/test_model_type_store_service.cc
@@ -4,7 +4,7 @@
#include "components/sync/model/test_model_type_store_service.h"
-#include "base/threading/thread_task_runner_handle.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "components/sync/model/model_type_store_test_util.h"
#include "components/sync/model_impl/blocking_model_type_store_impl.h"
#include "components/sync/model_impl/model_type_store_backend.h"
@@ -28,7 +28,7 @@
scoped_refptr<base::SequencedTaskRunner>
TestModelTypeStoreService::GetBackendTaskRunner() {
- return base::ThreadTaskRunnerHandle::Get();
+ return base::SequencedTaskRunnerHandle::Get();
}
std::unique_ptr<BlockingModelTypeStore>