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

Unified Diff: components/sync/driver/fake_data_type_controller.cc

Issue 2289143003: [Sync] Convert DTCs to be not RefCounted and NonThreadSafe. (Closed)
Patch Set: Rebase. Created 4 years, 3 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: components/sync/driver/fake_data_type_controller.cc
diff --git a/components/sync/driver/fake_data_type_controller.cc b/components/sync/driver/fake_data_type_controller.cc
index cfb60dfe3670f348d6fd3759752dab04493371a8..45e8fbee8aa49f7850524452ff064e69ebf2fc4e 100644
--- a/components/sync/driver/fake_data_type_controller.cc
+++ b/components/sync/driver/fake_data_type_controller.cc
@@ -4,7 +4,10 @@
#include "components/sync/driver/fake_data_type_controller.h"
+#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "components/sync/api/data_type_error_handler_impl.h"
#include "components/sync/api/sync_merge_result.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,12 +17,9 @@ using syncer::ModelType;
namespace sync_driver {
FakeDataTypeController::FakeDataTypeController(ModelType type)
- : DirectoryDataTypeController(base::ThreadTaskRunnerHandle::Get(),
- base::Closure(),
- nullptr),
+ : DirectoryDataTypeController(type, base::Closure(), nullptr),
state_(NOT_RUNNING),
model_load_delayed_(false),
- type_(type),
ready_for_start_(true),
should_load_model_before_configure_(false),
register_with_backend_call_count_(0) {}
@@ -33,6 +33,7 @@ bool FakeDataTypeController::ShouldLoadModelBeforeConfigure() const {
// NOT_RUNNING ->MODEL_LOADED |MODEL_STARTING.
void FakeDataTypeController::LoadModels(
const ModelLoadCallback& model_load_callback) {
+ DCHECK(CalledOnValidThread());
model_load_callback_ = model_load_callback;
if (state_ != NOT_RUNNING) {
ADD_FAILURE();
@@ -58,6 +59,7 @@ void FakeDataTypeController::RegisterWithBackend(
// MODEL_LOADED -> MODEL_STARTING.
void FakeDataTypeController::StartAssociating(
const StartCallback& start_callback) {
+ DCHECK(CalledOnValidThread());
last_start_callback_ = start_callback;
state_ = ASSOCIATING;
}
@@ -65,6 +67,7 @@ void FakeDataTypeController::StartAssociating(
// MODEL_STARTING | ASSOCIATING -> RUNNING | DISABLED | NOT_RUNNING
// (depending on |result|)
void FakeDataTypeController::FinishStart(ConfigureResult result) {
+ DCHECK(CalledOnValidThread());
// We should have a callback from Start().
if (last_start_callback_.is_null()) {
ADD_FAILURE();
@@ -98,6 +101,7 @@ void FakeDataTypeController::FinishStart(ConfigureResult result) {
// * -> NOT_RUNNING
void FakeDataTypeController::Stop() {
+ DCHECK(CalledOnValidThread());
if (!model_load_callback_.is_null()) {
// Real data type controllers run the callback and specify "ABORTED" as an
// error. We should probably find a way to use the real code and mock out
@@ -107,12 +111,8 @@ void FakeDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
-ModelType FakeDataTypeController::type() const {
- return type_;
-}
-
std::string FakeDataTypeController::name() const {
- return ModelTypeToString(type_);
+ return ModelTypeToString(type());
}
syncer::ModelSafeGroup FakeDataTypeController::model_safe_group() const {
@@ -127,12 +127,6 @@ DataTypeController::State FakeDataTypeController::state() const {
return state_;
}
-void FakeDataTypeController::OnSingleDataTypeUnrecoverableError(
- const syncer::SyncError& error) {
- if (!model_load_callback_.is_null())
- model_load_callback_.Run(type(), error);
-}
-
bool FakeDataTypeController::ReadyForStart() const {
return ready_for_start_;
}
@@ -161,4 +155,12 @@ void FakeDataTypeController::SetShouldLoadModelBeforeConfigure(bool value) {
should_load_model_before_configure_ = value;
}
+std::unique_ptr<syncer::DataTypeErrorHandler>
+FakeDataTypeController::CreateErrorHandler() {
+ DCHECK(CalledOnValidThread());
+ return base::MakeUnique<syncer::DataTypeErrorHandlerImpl>(
+ base::ThreadTaskRunnerHandle::Get(), base::Closure(),
+ base::Bind(model_load_callback_, type()));
+}
+
} // namespace sync_driver
« no previous file with comments | « components/sync/driver/fake_data_type_controller.h ('k') | components/sync/driver/fake_generic_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698