summaryrefslogtreecommitdiffstats
path: root/components/sync_driver
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 04:02:18 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 04:02:18 +0000
commit52463b22418f030cb1f1719aba0da6cdff995f07 (patch)
tree989b58d1e484af033cc3543754861c7f0dd9058e /components/sync_driver
parent8ef88526142dfa56ce9d3e82fbea4b4536ed2774 (diff)
downloadchromium_src-52463b22418f030cb1f1719aba0da6cdff995f07.zip
chromium_src-52463b22418f030cb1f1719aba0da6cdff995f07.tar.gz
chromium_src-52463b22418f030cb1f1719aba0da6cdff995f07.tar.bz2
sync: cut a few profile deps from DataTypeControllers.
- UserShare: previously the DTC would query PSS::GetUserShare whenever it decided it needed it, implicitly abiding by the rule that GetUserShare shall not be called until backend initialization is complete (implicit because the DTC knows nothing about backend init in theory, but we had carefully ordered things to work). Instead, we now pass it deterministically as soon as the share becomes available via an explicit call to the DTC (which the PSS already tracks). - DeactivateDataType: Changes the precondition to DTC::Stop such that it expects the backend has already been informed to stop routing changes for its type. The Deactivate call can be done safely up front by the DataTypeManager (which also handles ActivateDataType). - Profile: [Non]UIDataTypeController doesn't need a profile, so push that dep down to the subclasses in browser/ that require it. - ProfileSyncComponentsFactory: the DTCs should now be able to use SyncApiComponentFactory interface exclusively. Also rename ModelAssociationResultProcessor -> ModelAssociationManagerDelegate. BUG=339726 R=haitaol@chromium.org Review URL: https://codereview.chromium.org/317453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/sync_driver')
-rw-r--r--components/sync_driver/data_type_controller.cc11
-rw-r--r--components/sync_driver/data_type_controller.h14
-rw-r--r--components/sync_driver/data_type_manager_impl.cc6
-rw-r--r--components/sync_driver/data_type_manager_impl.h5
-rw-r--r--components/sync_driver/data_type_manager_impl_unittest.cc27
-rw-r--r--components/sync_driver/model_association_manager.cc26
-rw-r--r--components/sync_driver/model_association_manager.h25
-rw-r--r--components/sync_driver/model_association_manager_unittest.cc51
8 files changed, 121 insertions, 44 deletions
diff --git a/components/sync_driver/data_type_controller.cc b/components/sync_driver/data_type_controller.cc
index aa975d2..24f463cd 100644
--- a/components/sync_driver/data_type_controller.cc
+++ b/components/sync_driver/data_type_controller.cc
@@ -5,6 +5,7 @@
#include "components/sync_driver/data_type_controller.h"
#include "sync/internal_api/public/base/model_type.h"
+#include "sync/internal_api/public/user_share.h"
#include "sync/util/data_type_histogram.h"
namespace browser_sync {
@@ -13,7 +14,7 @@ DataTypeController::DataTypeController(
scoped_refptr<base::MessageLoopProxy> ui_thread,
const base::Closure& error_callback)
: base::RefCountedDeleteOnMessageLoop<DataTypeController>(ui_thread),
- error_callback_(error_callback) {
+ user_share_(NULL), error_callback_(error_callback) {
}
DataTypeController::~DataTypeController() {
@@ -39,6 +40,14 @@ syncer::SyncError DataTypeController::CreateAndUploadError(
type);
}
+void DataTypeController::OnUserShareReady(syncer::UserShare* share) {
+ user_share_ = share;
+}
+
+syncer::UserShare* DataTypeController::user_share() const {
+ return user_share_;
+}
+
void DataTypeController::RecordUnrecoverableError(
const tracked_objects::Location& from_here,
const std::string& message) {
diff --git a/components/sync_driver/data_type_controller.h b/components/sync_driver/data_type_controller.h
index ebc6c6fb..37fefc6 100644
--- a/components/sync_driver/data_type_controller.h
+++ b/components/sync_driver/data_type_controller.h
@@ -21,6 +21,7 @@
namespace syncer {
class SyncError;
+struct UserShare;
}
namespace browser_sync {
@@ -96,6 +97,11 @@ class DataTypeController
// Synchronously stops the data type. If StartAssociating has already been
// called but is not done yet it will be aborted. Similarly if LoadModels
// has not completed it will also be aborted.
+ // NOTE: Stop() should be called after sync backend machinery has stopped
+ // routing changes to this data type. Stop() should ensure the data type
+ // logic shuts down gracefully by flushing remaining changes and calling
+ // StopSyncing on the SyncableService. This assumes no changes will ever
+ // propagate from sync again from point where Stop() is called.
virtual void Stop() = 0;
// Unique model type for this data type controller.
@@ -123,6 +129,10 @@ class DataTypeController
const std::string& message,
syncer::ModelType type) OVERRIDE;
+ // Called when the sync backend has initialized. |share| is the
+ // UserShare handle to associate model data with.
+ void OnUserShareReady(syncer::UserShare* share);
+
protected:
friend class base::RefCountedDeleteOnMessageLoop<DataTypeController>;
friend class base::DeleteHelper<DataTypeController>;
@@ -144,7 +154,11 @@ class DataTypeController
const tracked_objects::Location& from_here,
const std::string& message);
+ syncer::UserShare* user_share() const;
+
private:
+ syncer::UserShare* user_share_;
+
// The callback that will be invoked when an unrecoverable error occurs.
base::Closure error_callback_;
};
diff --git a/components/sync_driver/data_type_manager_impl.cc b/components/sync_driver/data_type_manager_impl.cc
index 6ff6585..1d4a96e 100644
--- a/components/sync_driver/data_type_manager_impl.cc
+++ b/components/sync_driver/data_type_manager_impl.cc
@@ -13,7 +13,6 @@
#include "base/compiler_specific.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
#include "components/sync_driver/data_type_controller.h"
@@ -384,6 +383,11 @@ void DataTypeManagerImpl::StartNextAssociation() {
association_types_queue_.front().types);
}
+void DataTypeManagerImpl::OnSingleDataTypeWillStop(
+ syncer::ModelType type) {
+ configurer_->DeactivateDataType(type);
+}
+
void DataTypeManagerImpl::OnSingleDataTypeAssociationDone(
syncer::ModelType type,
const syncer::DataTypeAssociationStats& association_stats) {
diff --git a/components/sync_driver/data_type_manager_impl.h b/components/sync_driver/data_type_manager_impl.h
index bdfd67c..461ae6b 100644
--- a/components/sync_driver/data_type_manager_impl.h
+++ b/components/sync_driver/data_type_manager_impl.h
@@ -37,7 +37,7 @@ class FailedDataTypesHandler;
typedef std::queue<syncer::ModelTypeSet> TypeSetPriorityList;
class DataTypeManagerImpl : public DataTypeManager,
- public ModelAssociationResultProcessor {
+ public ModelAssociationManagerDelegate {
public:
DataTypeManagerImpl(
const base::Closure& unrecoverable_error_method,
@@ -62,12 +62,13 @@ class DataTypeManagerImpl : public DataTypeManager,
virtual void Stop() OVERRIDE;
virtual State state() const OVERRIDE;
- // |ModelAssociationResultProcessor| implementation.
+ // |ModelAssociationManagerDelegate| implementation.
virtual void OnSingleDataTypeAssociationDone(
syncer::ModelType type,
const syncer::DataTypeAssociationStats& association_stats) OVERRIDE;
virtual void OnModelAssociationDone(
const DataTypeManager::ConfigureResult& result) OVERRIDE;
+ virtual void OnSingleDataTypeWillStop(syncer::ModelType type) OVERRIDE;
// Used by unit tests. TODO(sync) : This would go away if we made
// this class be able to do Dependency injection. crbug.com/129212.
diff --git a/components/sync_driver/data_type_manager_impl_unittest.cc b/components/sync_driver/data_type_manager_impl_unittest.cc
index 3d9dede..ee88568 100644
--- a/components/sync_driver/data_type_manager_impl_unittest.cc
+++ b/components/sync_driver/data_type_manager_impl_unittest.cc
@@ -74,8 +74,12 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
virtual void ActivateDataType(
syncer::ModelType type, syncer::ModelSafeGroup group,
- ChangeProcessor* change_processor) OVERRIDE {}
- virtual void DeactivateDataType(syncer::ModelType type) OVERRIDE {}
+ ChangeProcessor* change_processor) OVERRIDE {
+ activated_types_.Put(type);
+ }
+ virtual void DeactivateDataType(syncer::ModelType type) OVERRIDE {
+ activated_types_.Remove(type);
+ }
base::Callback<void(ModelTypeSet, ModelTypeSet)> last_ready_task() const {
return last_ready_task_;
@@ -85,9 +89,12 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
expected_configure_types_ = types;
}
+ const syncer::ModelTypeSet activated_types() { return activated_types_; }
+
private:
base::Callback<void(ModelTypeSet, ModelTypeSet)> last_ready_task_;
syncer::ModelTypeSet expected_configure_types_;
+ syncer::ModelTypeSet activated_types_;
};
// Mock DataTypeManagerObserver implementation.
@@ -292,9 +299,11 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOne) {
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(1U, configurer_.activated_types().Size());
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with a single controller, configure it, but stop it
@@ -315,6 +324,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileDownloadPending) {
}
configurer_.last_ready_task().Run(ModelTypeSet(BOOKMARKS), ModelTypeSet());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with a single controller, configure it, finish
@@ -341,6 +351,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileStartingModel) {
}
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with a single controller, configure it, finish
@@ -361,6 +372,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileAssociating) {
FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
@@ -368,6 +380,7 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneStopWhileAssociating) {
}
GetController(BOOKMARKS)->FinishStart(DataTypeController::OK);
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with a single controller. Then:
@@ -453,10 +466,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenBoth) {
// Step 6.
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(2U, configurer_.activated_types().Size());
// Step 7.
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with two controllers. Then:
@@ -504,10 +519,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureOneThenSwitch) {
// Step 6.
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(1U, configurer_.activated_types().Size());
// Step 7.
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with two controllers. Then:
@@ -551,10 +568,12 @@ TEST_F(SyncDataTypeManagerImplTest, ConfigureWhileOneInFlight) {
// Step 6.
GetController(PREFERENCES)->FinishStart(DataTypeController::OK);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(2U, configurer_.activated_types().Size());
// Step 7.
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with one controller. Then configure, finish
@@ -572,10 +591,12 @@ TEST_F(SyncDataTypeManagerImplTest, OneFailingController) {
FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
GetController(BOOKMARKS)->FinishStart(
DataTypeController::UNRECOVERABLE_ERROR);
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with two controllers. Then:
@@ -654,10 +675,12 @@ TEST_F(SyncDataTypeManagerImplTest, OneControllerFailsAssociation) {
FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
+ EXPECT_EQ(1U, configurer_.activated_types().Size());
// Step 6.
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
+ EXPECT_TRUE(configurer_.activated_types().Empty());
}
// Set up a DTM with two controllers. Then:
diff --git a/components/sync_driver/model_association_manager.cc b/components/sync_driver/model_association_manager.cc
index 0b89f81..a66372f 100644
--- a/components/sync_driver/model_association_manager.cc
+++ b/components/sync_driver/model_association_manager.cc
@@ -110,10 +110,10 @@ syncer::DataTypeAssociationStats BuildAssociationStatsFromMergeResults(
ModelAssociationManager::ModelAssociationManager(
const DataTypeController::TypeMap* controllers,
- ModelAssociationResultProcessor* processor)
+ ModelAssociationManagerDelegate* processor)
: state_(IDLE),
controllers_(controllers),
- result_processor_(processor),
+ delegate_(processor),
weak_ptr_factory_(this),
configure_status_(DataTypeManager::UNKNOWN) {
// Ensure all data type controllers are stopped.
@@ -150,6 +150,15 @@ void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
LoadEnabledTypes();
}
+void ModelAssociationManager::StopDatatype(DataTypeController* dtc) {
+ // First tell the sync backend that we no longer want to listen to
+ // changes for this type.
+ delegate_->OnSingleDataTypeWillStop(dtc->type());
+
+ // Then tell all data type specific logic to shut down.
+ dtc->Stop();
+}
+
void ModelAssociationManager::StopDisabledTypes() {
DVLOG(1) << "ModelAssociationManager: Stopping disabled types.";
for (DataTypeController::TypeMap::const_iterator it = controllers_->begin();
@@ -159,8 +168,7 @@ void ModelAssociationManager::StopDisabledTypes() {
(!desired_types_.Has(dtc->type()) ||
failed_data_types_info_.count(dtc->type()) > 0)) {
DVLOG(1) << "ModelTypeToString: stop " << dtc->name();
- dtc->Stop();
-
+ StopDatatype(dtc);
loaded_types_.Remove(dtc->type());
associated_types_.Remove(dtc->type());
}
@@ -261,7 +269,7 @@ void ModelAssociationManager::Stop() {
it != controllers_->end(); ++it) {
DataTypeController* dtc = (*it).second.get();
if (dtc->state() != DataTypeController::NOT_RUNNING) {
- dtc->Stop();
+ StopDatatype(dtc);
DVLOG(1) << "ModelAssociationManager: Stopped " << dtc->name();
}
}
@@ -353,7 +361,7 @@ void ModelAssociationManager::TypeStartCallback(
// enabled.
DataTypeController* dtc = controllers_->find(type)->second.get();
if (dtc->state() != DataTypeController::NOT_RUNNING)
- dtc->Stop();
+ StopDatatype(dtc);
loaded_types_.Remove(type);
} else {
// Record error in CONFIGURING or INITIALIZED_TO_CONFIGURE mode. The error
@@ -389,7 +397,7 @@ void ModelAssociationManager::TypeStartCallback(
syncer_merge_result,
association_wait_time,
association_time);
- result_processor_->OnSingleDataTypeAssociationDone(type, stats);
+ delegate_->OnSingleDataTypeAssociationDone(type, stats);
}
// Update configuration result.
@@ -440,12 +448,12 @@ void ModelAssociationManager::ModelAssociationDone() {
associating_types_,
needs_crypto_types_);
- // Reset state before notifying |result_processor_| because that might
+ // Reset state before notifying |delegate_| because that might
// trigger a new round of configuration.
ResetForNextAssociation();
state_ = IDLE;
- result_processor_->OnModelAssociationDone(result);
+ delegate_->OnModelAssociationDone(result);
}
base::OneShotTimer<ModelAssociationManager>*
diff --git a/components/sync_driver/model_association_manager.h b/components/sync_driver/model_association_manager.h
index 89ad429..8b53940 100644
--- a/components/sync_driver/model_association_manager.h
+++ b/components/sync_driver/model_association_manager.h
@@ -25,27 +25,37 @@ class DataTypeController;
// |ModelAssociationManager| association functions are async. The results of
// those operations are passed back via this interface.
-class ModelAssociationResultProcessor {
+class ModelAssociationManagerDelegate {
public:
+ // Called when model association (MergeDataAndStartSyncing) has completed
+ // for |type|, regardless of success or failure.
virtual void OnSingleDataTypeAssociationDone(
syncer::ModelType type,
const syncer::DataTypeAssociationStats& association_stats) = 0;
+
+ // Called when the ModelAssociationManager has decided it must stop |type|,
+ // likely because it is no longer a desired data type or sync is shutting
+ // down.
+ virtual void OnSingleDataTypeWillStop(syncer::ModelType type) = 0;
+
+ // Called when the ModelAssociationManager has tried to perform model
+ // association for all desired types and has nothing left to do.
virtual void OnModelAssociationDone(
const DataTypeManager::ConfigureResult& result) = 0;
- virtual ~ModelAssociationResultProcessor() {}
+ virtual ~ModelAssociationManagerDelegate() {}
};
// The class that is responsible for model association.
class ModelAssociationManager {
public:
ModelAssociationManager(const DataTypeController::TypeMap* controllers,
- ModelAssociationResultProcessor* processor);
+ ModelAssociationManagerDelegate* delegate);
virtual ~ModelAssociationManager();
// Initializes the state to do the model association in future. This
// should be called before communicating with sync server. A subsequent call
// of Initialize is only allowed if the ModelAssociationManager has invoked
- // |OnModelAssociationDone| on the |ModelAssociationResultProcessor|. After
+ // |OnModelAssociationDone| on the |ModelAssociationManagerDelegate|. After
// this call, there should be several calls to StartAssociationAsync()
// to associate subset of |desired_types|.
void Initialize(syncer::ModelTypeSet desired_types);
@@ -101,9 +111,12 @@ class ModelAssociationManager {
void AppendToFailedDatatypesAndLogError(const syncer::SyncError& error);
// Called when all requested types are associated or association times out.
- // Notify |result_processor_| of configuration results.
+ // Notify |delegate_| of configuration results.
void ModelAssociationDone();
+ // A helper to stop an individual datatype.
+ void StopDatatype(DataTypeController* dtc);
+
State state_;
// Data types that are enabled.
@@ -143,7 +156,7 @@ class ModelAssociationManager {
const DataTypeController::TypeMap* controllers_;
// The processor in charge of handling model association results.
- ModelAssociationResultProcessor* result_processor_;
+ ModelAssociationManagerDelegate* delegate_;
// Timer to track and limit how long a datatype takes to model associate.
base::OneShotTimer<ModelAssociationManager> timer_;
diff --git a/components/sync_driver/model_association_manager_unittest.cc b/components/sync_driver/model_association_manager_unittest.cc
index a77f787..214b1b8 100644
--- a/components/sync_driver/model_association_manager_unittest.cc
+++ b/components/sync_driver/model_association_manager_unittest.cc
@@ -11,14 +11,15 @@
using ::testing::_;
namespace browser_sync {
-class MockModelAssociationResultProcessor :
- public ModelAssociationResultProcessor {
+class MockModelAssociationManagerDelegate :
+ public ModelAssociationManagerDelegate {
public:
- MockModelAssociationResultProcessor() {}
- ~MockModelAssociationResultProcessor() {}
+ MockModelAssociationManagerDelegate() {}
+ ~MockModelAssociationManagerDelegate() {}
MOCK_METHOD2(OnSingleDataTypeAssociationDone,
- void(syncer::ModelType type,
- const syncer::DataTypeAssociationStats& association_stats));
+ void(syncer::ModelType type,
+ const syncer::DataTypeAssociationStats& association_stats));
+ MOCK_METHOD1(OnSingleDataTypeWillStop, void(syncer::ModelType));
MOCK_METHOD1(OnModelAssociationDone, void(
const DataTypeManager::ConfigureResult& result));
};
@@ -62,7 +63,7 @@ class SyncModelAssociationManagerTest : public testing::Test {
protected:
base::MessageLoopForUI ui_loop_;
- MockModelAssociationResultProcessor result_processor_;
+ MockModelAssociationManagerDelegate delegate_;
DataTypeController::TypeMap controllers_;
};
@@ -74,7 +75,7 @@ TEST_F(SyncModelAssociationManagerTest, SimpleModelStart) {
controllers_[syncer::APPS] =
new FakeDataTypeController(syncer::APPS);
ModelAssociationManager model_association_manager(&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types(syncer::BOOKMARKS, syncer::APPS);
DataTypeManager::ConfigureResult expected_result(
DataTypeManager::OK,
@@ -82,7 +83,7 @@ TEST_F(SyncModelAssociationManagerTest, SimpleModelStart) {
std::map<syncer::ModelType, syncer::SyncError>(),
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
EXPECT_EQ(GetController(controllers_, syncer::BOOKMARKS)->state(),
@@ -116,7 +117,7 @@ TEST_F(SyncModelAssociationManagerTest, StopModelBeforeFinish) {
new FakeDataTypeController(syncer::BOOKMARKS);
ModelAssociationManager model_association_manager(
&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
@@ -135,8 +136,10 @@ TEST_F(SyncModelAssociationManagerTest, StopModelBeforeFinish) {
syncer::ModelTypeSet(syncer::BOOKMARKS),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
+ EXPECT_CALL(delegate_,
+ OnSingleDataTypeWillStop(syncer::BOOKMARKS));
model_association_manager.Initialize(types);
model_association_manager.StartAssociationAsync(types);
@@ -154,7 +157,7 @@ TEST_F(SyncModelAssociationManagerTest, StopAfterFinish) {
new FakeDataTypeController(syncer::BOOKMARKS);
ModelAssociationManager model_association_manager(
&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
DataTypeManager::ConfigureResult expected_result(
@@ -163,8 +166,10 @@ TEST_F(SyncModelAssociationManagerTest, StopAfterFinish) {
std::map<syncer::ModelType, syncer::SyncError>(),
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
+ EXPECT_CALL(delegate_,
+ OnSingleDataTypeWillStop(syncer::BOOKMARKS));
model_association_manager.Initialize(types);
model_association_manager.StartAssociationAsync(types);
@@ -185,7 +190,7 @@ TEST_F(SyncModelAssociationManagerTest, TypeFailModelAssociation) {
new FakeDataTypeController(syncer::BOOKMARKS);
ModelAssociationManager model_association_manager(
&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
std::map<syncer::ModelType, syncer::SyncError> errors;
@@ -200,7 +205,7 @@ TEST_F(SyncModelAssociationManagerTest, TypeFailModelAssociation) {
errors,
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
model_association_manager.Initialize(types);
@@ -220,7 +225,7 @@ TEST_F(SyncModelAssociationManagerTest, TypeReturnUnrecoverableError) {
new FakeDataTypeController(syncer::BOOKMARKS);
ModelAssociationManager model_association_manager(
&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
std::map<syncer::ModelType, syncer::SyncError> errors;
@@ -235,7 +240,7 @@ TEST_F(SyncModelAssociationManagerTest, TypeReturnUnrecoverableError) {
errors,
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
model_association_manager.Initialize(types);
@@ -255,7 +260,7 @@ TEST_F(SyncModelAssociationManagerTest, SlowTypeAsFailedType) {
new FakeDataTypeController(syncer::APPS);
GetController(controllers_, syncer::BOOKMARKS)->SetDelayModelLoad();
ModelAssociationManager model_association_manager(&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
types.Put(syncer::APPS);
@@ -276,7 +281,7 @@ TEST_F(SyncModelAssociationManagerTest, SlowTypeAsFailedType) {
expected_types_unfinished,
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result_partially_done));
model_association_manager.Initialize(types);
@@ -296,7 +301,7 @@ TEST_F(SyncModelAssociationManagerTest, StartMultipleTimes) {
controllers_[syncer::APPS] =
new FakeDataTypeController(syncer::APPS);
ModelAssociationManager model_association_manager(&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
types.Put(syncer::APPS);
@@ -313,7 +318,7 @@ TEST_F(SyncModelAssociationManagerTest, StartMultipleTimes) {
std::map<syncer::ModelType, syncer::SyncError>(),
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
Times(2).
WillOnce(VerifyResult(result_1st)).
WillOnce(VerifyResult(result_2nd));
@@ -357,7 +362,7 @@ TEST_F(SyncModelAssociationManagerTest, ModelLoadFailBeforeAssociationStart) {
"", syncer::BOOKMARKS));
ModelAssociationManager model_association_manager(
&controllers_,
- &result_processor_);
+ &delegate_);
syncer::ModelTypeSet types;
types.Put(syncer::BOOKMARKS);
std::map<syncer::ModelType, syncer::SyncError> errors;
@@ -372,7 +377,7 @@ TEST_F(SyncModelAssociationManagerTest, ModelLoadFailBeforeAssociationStart) {
errors,
syncer::ModelTypeSet(),
syncer::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
+ EXPECT_CALL(delegate_, OnModelAssociationDone(_)).
WillOnce(VerifyResult(expected_result));
model_association_manager.Initialize(types);