Chromium Code Reviews| Index: chrome/browser/sync/glue/model_association_manager.h |
| diff --git a/chrome/browser/sync/glue/model_association_manager.h b/chrome/browser/sync/glue/model_association_manager.h |
| index 76c527f2e1e759287236b0ce193c88b563188ad7..af7ffc50932e1bbe97698be0c72319fbd7212016 100644 |
| --- a/chrome/browser/sync/glue/model_association_manager.h |
| +++ b/chrome/browser/sync/glue/model_association_manager.h |
| @@ -9,14 +9,15 @@ |
| #include <list> |
| #include "base/memory/weak_ptr.h" |
| +#include "base/timer.h" |
| #include "chrome/browser/sync/glue/data_type_manager.h" |
| // |ModelAssociationManager| does the heavy lifting for doing the actual model |
| // association. It instructs DataTypeControllers to load models, start |
| // associating and stopping. Since the operations are async it uses an |
| -// interface to inform DTM the results of the operations. |
| -// This class is owned by DTM. |
| +// interface to inform DataTypeManager the results of the operations. |
| +// This class is owned by DataTypeManager. |
| namespace browser_sync { |
| class DataTypeController; |
| @@ -28,6 +29,11 @@ class ModelAssociationResultProcessor { |
| virtual void OnModelAssociationDone( |
| const DataTypeManager::ConfigureResult& result) = 0; |
| virtual ~ModelAssociationResultProcessor() {} |
| + |
| + // when types (that did not complete loading, during the previous |
|
tim (not reviewing)
2012/05/22 16:50:05
nit - Comments start with capital letters.
Seeing
lipalani1
2012/05/22 20:20:46
Done.
|
| + // run of the configure) get loaded this callback is called to let the |
| + // DataTypeManager know and request a reconfigure. |
| + virtual void OnTypesLoaded() = 0; |
| }; |
| // The class that is responsible for model association. |
| @@ -39,8 +45,8 @@ class 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 current configure cycle is completed, |
| - // aborted or stopped. |
| + // of Initialize is only allowed if the ModelAssociationManager has invoked |
| + // |OnModelAssociationDone| on the |ModelAssociationResultProcessor|. |
| void Initialize(syncable::ModelTypeSet desired_types); |
| // Can be called at any time. Synchronously stops all datatypes. |
| @@ -54,7 +60,7 @@ class ModelAssociationManager { |
| // It is valid to call this only when we are initialized to configure |
| // but we have not started the configuration.(i.e., |Initialize| has |
| // been called but |StartAssociationAsync| has not yet been called.) |
| - // If we have started configuration then the DTM will wait until |
| + // If we have started configuration then the DataTypeManager will wait until |
| // the current configuration is done before processing the reconfigure |
| // request. We goto IDLE state and clear all our internal state. It is |
| // safe to do this as we have not started association on any DTCs. |
| @@ -64,6 +70,10 @@ class ModelAssociationManager { |
| // Stops any disabled types. |
| void StopDisabledTypes(); |
| + // This is used for TESTING PURPOSE ONLY. The test case can inspect |
| + // and modify the timer. |
| + base::OneShotTimer<ModelAssociationManager>* GetTimerForTesting(); |
| + |
| private: |
| enum State { |
| // This is the state after |Initialize| is called. |
| @@ -97,6 +107,15 @@ class ModelAssociationManager { |
| // loaded. |
| void StartAssociatingNextType(); |
| + // We have waited long enough and the model has not loaded yet. |
| + void ModelLoadTimedOut(); |
| + |
| + void HandleFailedTypes(DataTypeController::StartResult result, |
|
tim (not reviewing)
2012/05/22 16:50:05
Comment.
lipalani1
2012/05/22 20:20:46
Done.
|
| + const SyncError& error); |
| + |
| + syncable::ModelTypeSet GetTypesWaitingToLoad(); |
| + |
| + |
| State state_; |
| syncable::ModelTypeSet desired_types_; |
| std::list<SyncError> failed_datatypes_info_; |
| @@ -140,6 +159,7 @@ class ModelAssociationManager { |
| const DataTypeController::TypeMap* controllers_; |
| ModelAssociationResultProcessor* result_processor_; |
| base::WeakPtrFactory<ModelAssociationManager> weak_ptr_factory_; |
| + base::OneShotTimer<ModelAssociationManager> timer_; |
| DISALLOW_COPY_AND_ASSIGN(ModelAssociationManager); |
| }; |
| } // namespace browser_sync |