| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 NonFrontendDataTypeController( | 52 NonFrontendDataTypeController( |
| 53 scoped_refptr<base::MessageLoopProxy> ui_thread, | 53 scoped_refptr<base::MessageLoopProxy> ui_thread, |
| 54 const base::Closure& error_callback, | 54 const base::Closure& error_callback, |
| 55 ProfileSyncComponentsFactory* profile_sync_factory, | 55 ProfileSyncComponentsFactory* profile_sync_factory, |
| 56 Profile* profile, | 56 Profile* profile, |
| 57 ProfileSyncService* sync_service); | 57 ProfileSyncService* sync_service); |
| 58 | 58 |
| 59 // DataTypeController interface. | 59 // DataTypeController interface. |
| 60 virtual void LoadModels( | 60 virtual void LoadModels( |
| 61 const ModelLoadCallback& model_load_callback) OVERRIDE; | 61 const ModelLoadCallback& model_load_callback) override; |
| 62 virtual void StartAssociating(const StartCallback& start_callback) OVERRIDE; | 62 virtual void StartAssociating(const StartCallback& start_callback) override; |
| 63 virtual void Stop() OVERRIDE; | 63 virtual void Stop() override; |
| 64 virtual syncer::ModelType type() const = 0; | 64 virtual syncer::ModelType type() const = 0; |
| 65 virtual syncer::ModelSafeGroup model_safe_group() const = 0; | 65 virtual syncer::ModelSafeGroup model_safe_group() const = 0; |
| 66 virtual std::string name() const OVERRIDE; | 66 virtual std::string name() const override; |
| 67 virtual State state() const OVERRIDE; | 67 virtual State state() const override; |
| 68 | 68 |
| 69 // DataTypeErrorHandler interface. | 69 // DataTypeErrorHandler interface. |
| 70 // Note: this is performed on the datatype's thread. | 70 // Note: this is performed on the datatype's thread. |
| 71 virtual void OnSingleDataTypeUnrecoverableError( | 71 virtual void OnSingleDataTypeUnrecoverableError( |
| 72 const syncer::SyncError& error) OVERRIDE; | 72 const syncer::SyncError& error) override; |
| 73 | 73 |
| 74 // Callback to receive background association results. | 74 // Callback to receive background association results. |
| 75 struct AssociationResult { | 75 struct AssociationResult { |
| 76 explicit AssociationResult(syncer::ModelType type); | 76 explicit AssociationResult(syncer::ModelType type); |
| 77 ~AssociationResult(); | 77 ~AssociationResult(); |
| 78 bool needs_crypto; | 78 bool needs_crypto; |
| 79 bool unrecoverable_error; | 79 bool unrecoverable_error; |
| 80 bool sync_has_nodes; | 80 bool sync_has_nodes; |
| 81 syncer::SyncError error; | 81 syncer::SyncError error; |
| 82 syncer::SyncMergeResult local_merge_result; | 82 syncer::SyncMergeResult local_merge_result; |
| 83 syncer::SyncMergeResult syncer_merge_result; | 83 syncer::SyncMergeResult syncer_merge_result; |
| 84 base::TimeDelta association_time; | 84 base::TimeDelta association_time; |
| 85 sync_driver::ChangeProcessor* change_processor; | 85 sync_driver::ChangeProcessor* change_processor; |
| 86 sync_driver::AssociatorInterface* model_associator; | 86 sync_driver::AssociatorInterface* model_associator; |
| 87 }; | 87 }; |
| 88 void AssociationCallback(AssociationResult result); | 88 void AssociationCallback(AssociationResult result); |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 // For testing only. | 91 // For testing only. |
| 92 NonFrontendDataTypeController(); | 92 NonFrontendDataTypeController(); |
| 93 | 93 |
| 94 virtual ~NonFrontendDataTypeController(); | 94 virtual ~NonFrontendDataTypeController(); |
| 95 | 95 |
| 96 // DataTypeController interface. | 96 // DataTypeController interface. |
| 97 virtual void OnModelLoaded() OVERRIDE; | 97 virtual void OnModelLoaded() override; |
| 98 | 98 |
| 99 // Start any dependent services that need to be running before we can | 99 // Start any dependent services that need to be running before we can |
| 100 // associate models. The default implementation is a no-op. | 100 // associate models. The default implementation is a no-op. |
| 101 // Return value: | 101 // Return value: |
| 102 // True - if models are ready and association can proceed. | 102 // True - if models are ready and association can proceed. |
| 103 // False - if models are not ready. StartAssociationAsync should be called | 103 // False - if models are not ready. StartAssociationAsync should be called |
| 104 // when the models are ready. | 104 // when the models are ready. |
| 105 // Note: this is performed on the frontend (UI) thread. | 105 // Note: this is performed on the frontend (UI) thread. |
| 106 virtual bool StartModels(); | 106 virtual bool StartModels(); |
| 107 | 107 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const std::string& message); | 161 const std::string& message); |
| 162 | 162 |
| 163 // Accessors and mutators used by derived classes. | 163 // Accessors and mutators used by derived classes. |
| 164 ProfileSyncComponentsFactory* profile_sync_factory() const; | 164 ProfileSyncComponentsFactory* profile_sync_factory() const; |
| 165 Profile* profile() const; | 165 Profile* profile() const; |
| 166 ProfileSyncService* profile_sync_service() const; | 166 ProfileSyncService* profile_sync_service() const; |
| 167 void set_start_callback(const StartCallback& callback); | 167 void set_start_callback(const StartCallback& callback); |
| 168 void set_state(State state); | 168 void set_state(State state); |
| 169 | 169 |
| 170 virtual sync_driver::AssociatorInterface* associator() const; | 170 virtual sync_driver::AssociatorInterface* associator() const; |
| 171 virtual sync_driver::ChangeProcessor* GetChangeProcessor() const OVERRIDE; | 171 virtual sync_driver::ChangeProcessor* GetChangeProcessor() const override; |
| 172 | 172 |
| 173 State state_; | 173 State state_; |
| 174 StartCallback start_callback_; | 174 StartCallback start_callback_; |
| 175 ModelLoadCallback model_load_callback_; | 175 ModelLoadCallback model_load_callback_; |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 friend class BackendComponentsContainer; | 178 friend class BackendComponentsContainer; |
| 179 ProfileSyncComponentsFactory* const profile_sync_factory_; | 179 ProfileSyncComponentsFactory* const profile_sync_factory_; |
| 180 Profile* const profile_; | 180 Profile* const profile_; |
| 181 ProfileSyncService* const profile_sync_service_; | 181 ProfileSyncService* const profile_sync_service_; |
| 182 | 182 |
| 183 // Created on UI thread and passed to backend to create processor/associator | 183 // Created on UI thread and passed to backend to create processor/associator |
| 184 // and associate model. Released on backend. | 184 // and associate model. Released on backend. |
| 185 scoped_ptr<BackendComponentsContainer> components_container_; | 185 scoped_ptr<BackendComponentsContainer> components_container_; |
| 186 | 186 |
| 187 sync_driver::AssociatorInterface* model_associator_; | 187 sync_driver::AssociatorInterface* model_associator_; |
| 188 sync_driver::ChangeProcessor* change_processor_; | 188 sync_driver::ChangeProcessor* change_processor_; |
| 189 | 189 |
| 190 base::WeakPtrFactory<NonFrontendDataTypeController> weak_ptr_factory_; | 190 base::WeakPtrFactory<NonFrontendDataTypeController> weak_ptr_factory_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(NonFrontendDataTypeController); | 192 DISALLOW_COPY_AND_ASSIGN(NonFrontendDataTypeController); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 } // namespace browser_sync | 195 } // namespace browser_sync |
| 196 | 196 |
| 197 #endif // CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 197 #endif // CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |