summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/glue/fake_data_type_controller.cc7
-rw-r--r--chrome/browser/sync/glue/model_association_manager.cc22
-rw-r--r--chrome/browser/sync/glue/model_association_manager.h2
-rw-r--r--chrome/browser/sync/glue/model_association_manager_unittest.cc71
4 files changed, 10 insertions, 92 deletions
diff --git a/chrome/browser/sync/glue/fake_data_type_controller.cc b/chrome/browser/sync/glue/fake_data_type_controller.cc
index da41997..20f64a2 100644
--- a/chrome/browser/sync/glue/fake_data_type_controller.cc
+++ b/chrome/browser/sync/glue/fake_data_type_controller.cc
@@ -74,13 +74,6 @@ void FakeDataTypeController::FinishStart(StartResult result) {
// * -> NOT_RUNNING
void FakeDataTypeController::Stop() {
state_ = NOT_RUNNING;
- 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
- // unnecessary pieces.
- SimulateModelLoadFinishing();
- }
-
// The DTM still expects |last_start_callback_| to be called back.
if (!last_start_callback_.is_null()) {
SyncError error(FROM_HERE, "Fake error", type_);
diff --git a/chrome/browser/sync/glue/model_association_manager.cc b/chrome/browser/sync/glue/model_association_manager.cc
index 5708af3f..40e6f34 100644
--- a/chrome/browser/sync/glue/model_association_manager.cc
+++ b/chrome/browser/sync/glue/model_association_manager.cc
@@ -101,14 +101,12 @@ ModelAssociationManager::~ModelAssociationManager() {
void ModelAssociationManager::Initialize(
syncable::ModelTypeSet desired_types) {
- // TODO(tim): Bug 134550. CHECKing to ensure no reentrancy on dev channel.
- // Remove this.
- CHECK_EQ(state_, IDLE);
+ DCHECK_EQ(state_, IDLE);
needs_start_.clear();
needs_stop_.clear();
failed_datatypes_info_.clear();
desired_types_ = desired_types;
- state_ = INITIALIZED_TO_CONFIGURE;
+ state_ = INITIAILIZED_TO_CONFIGURE;
DVLOG(1) << "ModelAssociationManager: Initializing";
@@ -156,14 +154,14 @@ void ModelAssociationManager::Initialize(
}
void ModelAssociationManager::StartAssociationAsync() {
- DCHECK_EQ(state_, INITIALIZED_TO_CONFIGURE);
+ DCHECK_EQ(state_, INITIAILIZED_TO_CONFIGURE);
state_ = CONFIGURING;
DVLOG(1) << "ModelAssociationManager: Going to start model association";
LoadModelForNextType();
}
void ModelAssociationManager::ResetForReconfiguration() {
- DCHECK_EQ(state_, INITIALIZED_TO_CONFIGURE);
+ DCHECK_EQ(state_, INITIAILIZED_TO_CONFIGURE);
state_ = IDLE;
DVLOG(1) << "ModelAssociationManager: Reseting for reconfiguration";
needs_start_.clear();
@@ -172,7 +170,7 @@ void ModelAssociationManager::ResetForReconfiguration() {
}
void ModelAssociationManager::StopDisabledTypes() {
- DCHECK_EQ(state_, INITIALIZED_TO_CONFIGURE);
+ DCHECK_EQ(state_, INITIAILIZED_TO_CONFIGURE);
DVLOG(1) << "ModelAssociationManager: Stopping disabled types.";
// Stop requested data types.
for (size_t i = 0; i < needs_stop_.size(); ++i) {
@@ -213,7 +211,7 @@ void ModelAssociationManager::Stop() {
// Now continue stopping any types that have already started.
DCHECK(state_ == IDLE ||
- state_ == INITIALIZED_TO_CONFIGURE);
+ state_ == INITIAILIZED_TO_CONFIGURE);
for (DataTypeController::TypeMap::const_iterator it = controllers_->begin();
it != controllers_->end(); ++it) {
DataTypeController* dtc = (*it).second;
@@ -418,18 +416,13 @@ void ModelAssociationManager::ModelLoadCallback(
}
NOTREACHED();
return;
- } else if (state_ == IDLE) {
+ } else {
DVLOG(1) << "ModelAssociationManager: Models loaded after configure cycle"
<< "Informing DTM";
// This datatype finished loading after the deadline imposed by the
// originating configuration cycle. Inform the DataTypeManager that the
// type has loaded, so that association may begin.
result_processor_->OnTypesLoaded();
- } else {
- // If we're not IDLE or CONFIGURING, we're being invoked as part of an abort
- // process (possibly a reconfiguration, or disabling of a broken data type).
- DVLOG(1) << "ModelAssociationManager: ModelLoadCallback occurred while "
- << "not IDLE or CONFIGURING. Doing nothing.";
}
}
@@ -509,3 +502,4 @@ base::OneShotTimer<ModelAssociationManager>*
}
} // namespace browser_sync
+
diff --git a/chrome/browser/sync/glue/model_association_manager.h b/chrome/browser/sync/glue/model_association_manager.h
index 5858bae..07b7933 100644
--- a/chrome/browser/sync/glue/model_association_manager.h
+++ b/chrome/browser/sync/glue/model_association_manager.h
@@ -80,7 +80,7 @@ class ModelAssociationManager {
private:
enum State {
// This is the state after |Initialize| is called.
- INITIALIZED_TO_CONFIGURE,
+ INITIAILIZED_TO_CONFIGURE,
// Starting a new configuration.
CONFIGURING,
// A stop command was issued.
diff --git a/chrome/browser/sync/glue/model_association_manager_unittest.cc b/chrome/browser/sync/glue/model_association_manager_unittest.cc
index 76ab25c..25e9fa3 100644
--- a/chrome/browser/sync/glue/model_association_manager_unittest.cc
+++ b/chrome/browser/sync/glue/model_association_manager_unittest.cc
@@ -211,76 +211,6 @@ TEST_F(ModelAssociationManagerTest, TypeReturnUnrecoverableError) {
DataTypeController::UNRECOVERABLE_ERROR);
}
-TEST_F(ModelAssociationManagerTest, InitializeAbortsLoad) {
- controllers_[syncable::BOOKMARKS] =
- new FakeDataTypeController(syncable::BOOKMARKS);
- controllers_[syncable::THEMES] =
- new FakeDataTypeController(syncable::THEMES);
-
- GetController(controllers_, syncable::BOOKMARKS)->SetDelayModelLoad();
- ModelAssociationManager model_association_manager(&controllers_,
- &result_processor_);
- syncable::ModelTypeSet types(syncable::BOOKMARKS, syncable::THEMES);
-
- syncable::ModelTypeSet expected_types_waiting_to_load;
- expected_types_waiting_to_load.Put(syncable::BOOKMARKS);
- DataTypeManager::ConfigureResult expected_result_partially_done(
- DataTypeManager::PARTIAL_SUCCESS,
- types,
- std::list<csync::SyncError>(),
- expected_types_waiting_to_load);
-
- model_association_manager.Initialize(types);
- model_association_manager.StopDisabledTypes();
-
- model_association_manager.StartAssociationAsync();
-
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
- WillOnce(VerifyResult(expected_result_partially_done));
-
- base::OneShotTimer<ModelAssociationManager>* timer =
- model_association_manager.GetTimerForTesting();
-
- base::Closure task = timer->user_task();
- timer->Stop();
- task.Run(); // Bookmark load times out here.
-
- // Apps finishes associating here.
- GetController(controllers_, syncable::THEMES)->FinishStart(
- DataTypeController::OK);
-
- // At this point, BOOKMARKS is still waiting to load (as evidenced by
- // expected_result_partially_done). If we schedule another Initialize (which
- // could happen in practice due to reconfiguration), this should abort
- // BOOKMARKS. Aborting will call ModelLoadCallback, but the
- // ModelAssociationManager should be smart enough to know that this is not due
- // to the type having completed loading.
- EXPECT_CALL(result_processor_, OnTypesLoaded()).Times(0);
-
- EXPECT_EQ(GetController(controllers_, syncable::BOOKMARKS)->state(),
- DataTypeController::MODEL_STARTING);
-
- model_association_manager.Initialize(types);
- EXPECT_EQ(GetController(controllers_, syncable::BOOKMARKS)->state(),
- DataTypeController::NOT_RUNNING);
-
- DataTypeManager::ConfigureResult expected_result_done(
- DataTypeManager::OK,
- types,
- std::list<csync::SyncError>(),
- syncable::ModelTypeSet());
- EXPECT_CALL(result_processor_, OnModelAssociationDone(_)).
- WillOnce(VerifyResult(expected_result_done));
-
- model_association_manager.StopDisabledTypes();
- model_association_manager.StartAssociationAsync();
-
- GetController(controllers_,
- syncable::BOOKMARKS)->SimulateModelLoadFinishing();
- GetController(controllers_, syncable::BOOKMARKS)->FinishStart(
- DataTypeController::OK);
-}
-
// Start 2 types. One of which timeout loading. Ensure that type is
// fully configured eventually.
TEST_F(ModelAssociationManagerTest, ModelStartWithSlowLoadingType) {
@@ -351,3 +281,4 @@ TEST_F(ModelAssociationManagerTest, ModelStartWithSlowLoadingType) {
} // namespace browser_sync
+