| 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 11 matching lines...) Expand all Loading... |
| 22 class ProfileSyncComponentsFactory; | 22 class ProfileSyncComponentsFactory; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class TimeDelta; | 25 class TimeDelta; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace syncer { | 28 namespace syncer { |
| 29 class SyncError; | 29 class SyncError; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace sync_driver { |
| 33 class AssociatorInterface; |
| 34 class ChangeProcessor; |
| 35 } |
| 36 |
| 32 namespace browser_sync { | 37 namespace browser_sync { |
| 33 | 38 |
| 34 class AssociatorInterface; | |
| 35 class ChangeProcessor; | |
| 36 | |
| 37 // Implementation for datatypes that do not reside on the frontend thread | 39 // Implementation for datatypes that do not reside on the frontend thread |
| 38 // (UI thread). This is the same thread we perform initialization | 40 // (UI thread). This is the same thread we perform initialization |
| 39 // on, so we don't have to worry about thread safety. The main start/stop | 41 // on, so we don't have to worry about thread safety. The main start/stop |
| 40 // functionality is implemented by default. Derived classes must implement: | 42 // functionality is implemented by default. Derived classes must implement: |
| 41 // type() | 43 // type() |
| 42 // model_safe_group() | 44 // model_safe_group() |
| 43 // PostTaskOnBackendThread() | 45 // PostTaskOnBackendThread() |
| 44 // CreateSyncComponents() | 46 // CreateSyncComponents() |
| 45 class NonFrontendDataTypeController : public DataTypeController { | 47 class NonFrontendDataTypeController : public sync_driver::DataTypeController { |
| 46 public: | 48 public: |
| 47 // For creating non-frontend processor/associator and associating on backend. | 49 // For creating non-frontend processor/associator and associating on backend. |
| 48 class BackendComponentsContainer; | 50 class BackendComponentsContainer; |
| 49 | 51 |
| 50 NonFrontendDataTypeController( | 52 NonFrontendDataTypeController( |
| 51 scoped_refptr<base::MessageLoopProxy> ui_thread, | 53 scoped_refptr<base::MessageLoopProxy> ui_thread, |
| 52 const base::Closure& error_callback, | 54 const base::Closure& error_callback, |
| 53 ProfileSyncComponentsFactory* profile_sync_factory, | 55 ProfileSyncComponentsFactory* profile_sync_factory, |
| 54 Profile* profile, | 56 Profile* profile, |
| 55 ProfileSyncService* sync_service); | 57 ProfileSyncService* sync_service); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 74 struct AssociationResult { | 76 struct AssociationResult { |
| 75 explicit AssociationResult(syncer::ModelType type); | 77 explicit AssociationResult(syncer::ModelType type); |
| 76 ~AssociationResult(); | 78 ~AssociationResult(); |
| 77 bool needs_crypto; | 79 bool needs_crypto; |
| 78 bool unrecoverable_error; | 80 bool unrecoverable_error; |
| 79 bool sync_has_nodes; | 81 bool sync_has_nodes; |
| 80 syncer::SyncError error; | 82 syncer::SyncError error; |
| 81 syncer::SyncMergeResult local_merge_result; | 83 syncer::SyncMergeResult local_merge_result; |
| 82 syncer::SyncMergeResult syncer_merge_result; | 84 syncer::SyncMergeResult syncer_merge_result; |
| 83 base::TimeDelta association_time; | 85 base::TimeDelta association_time; |
| 84 ChangeProcessor* change_processor; | 86 sync_driver::ChangeProcessor* change_processor; |
| 85 AssociatorInterface* model_associator; | 87 sync_driver::AssociatorInterface* model_associator; |
| 86 }; | 88 }; |
| 87 void AssociationCallback(AssociationResult result); | 89 void AssociationCallback(AssociationResult result); |
| 88 | 90 |
| 89 protected: | 91 protected: |
| 90 // For testing only. | 92 // For testing only. |
| 91 NonFrontendDataTypeController(); | 93 NonFrontendDataTypeController(); |
| 92 | 94 |
| 93 virtual ~NonFrontendDataTypeController(); | 95 virtual ~NonFrontendDataTypeController(); |
| 94 | 96 |
| 95 // DataTypeController interface. | 97 // DataTypeController interface. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 // override it appropriately. | 122 // override it appropriately. |
| 121 virtual bool IsOnBackendThread(); | 123 virtual bool IsOnBackendThread(); |
| 122 | 124 |
| 123 // Datatype specific creation of sync components. | 125 // Datatype specific creation of sync components. |
| 124 // Note: this is performed on the datatype's thread. | 126 // Note: this is performed on the datatype's thread. |
| 125 virtual ProfileSyncComponentsFactory::SyncComponents | 127 virtual ProfileSyncComponentsFactory::SyncComponents |
| 126 CreateSyncComponents() = 0; | 128 CreateSyncComponents() = 0; |
| 127 | 129 |
| 128 // Called on UI thread during shutdown to effectively disable processing | 130 // Called on UI thread during shutdown to effectively disable processing |
| 129 // any changes. | 131 // any changes. |
| 130 virtual void DisconnectProcessor(ChangeProcessor* processor) = 0; | 132 virtual void DisconnectProcessor(sync_driver::ChangeProcessor* processor) = 0; |
| 131 | 133 |
| 132 // Start up complete, update the state and invoke the callback. | 134 // Start up complete, update the state and invoke the callback. |
| 133 // Note: this is performed on the datatype's thread. | 135 // Note: this is performed on the datatype's thread. |
| 134 virtual void StartDone( | 136 virtual void StartDone( |
| 135 DataTypeController::StartResult start_result, | 137 DataTypeController::StartResult start_result, |
| 136 const syncer::SyncMergeResult& local_merge_result, | 138 const syncer::SyncMergeResult& local_merge_result, |
| 137 const syncer::SyncMergeResult& syncer_merge_result); | 139 const syncer::SyncMergeResult& syncer_merge_result); |
| 138 | 140 |
| 139 // UI thread implementation of StartDone. | 141 // UI thread implementation of StartDone. |
| 140 virtual void StartDoneImpl( | 142 virtual void StartDoneImpl( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 160 const tracked_objects::Location& from_here, | 162 const tracked_objects::Location& from_here, |
| 161 const std::string& message); | 163 const std::string& message); |
| 162 | 164 |
| 163 // Accessors and mutators used by derived classes. | 165 // Accessors and mutators used by derived classes. |
| 164 ProfileSyncComponentsFactory* profile_sync_factory() const; | 166 ProfileSyncComponentsFactory* profile_sync_factory() const; |
| 165 Profile* profile() const; | 167 Profile* profile() const; |
| 166 ProfileSyncService* profile_sync_service() const; | 168 ProfileSyncService* profile_sync_service() const; |
| 167 void set_start_callback(const StartCallback& callback); | 169 void set_start_callback(const StartCallback& callback); |
| 168 void set_state(State state); | 170 void set_state(State state); |
| 169 | 171 |
| 170 virtual AssociatorInterface* associator() const; | 172 virtual sync_driver::AssociatorInterface* associator() const; |
| 171 virtual ChangeProcessor* GetChangeProcessor() const OVERRIDE; | 173 virtual sync_driver::ChangeProcessor* GetChangeProcessor() const OVERRIDE; |
| 172 | 174 |
| 173 State state_; | 175 State state_; |
| 174 StartCallback start_callback_; | 176 StartCallback start_callback_; |
| 175 ModelLoadCallback model_load_callback_; | 177 ModelLoadCallback model_load_callback_; |
| 176 | 178 |
| 177 private: | 179 private: |
| 178 friend class BackendComponentsContainer; | 180 friend class BackendComponentsContainer; |
| 179 ProfileSyncComponentsFactory* const profile_sync_factory_; | 181 ProfileSyncComponentsFactory* const profile_sync_factory_; |
| 180 Profile* const profile_; | 182 Profile* const profile_; |
| 181 ProfileSyncService* const profile_sync_service_; | 183 ProfileSyncService* const profile_sync_service_; |
| 182 | 184 |
| 183 // Created on UI thread and passed to backend to create processor/associator | 185 // Created on UI thread and passed to backend to create processor/associator |
| 184 // and associate model. Released on backend. | 186 // and associate model. Released on backend. |
| 185 scoped_ptr<BackendComponentsContainer> components_container_; | 187 scoped_ptr<BackendComponentsContainer> components_container_; |
| 186 | 188 |
| 187 AssociatorInterface* model_associator_; | 189 sync_driver::AssociatorInterface* model_associator_; |
| 188 ChangeProcessor* change_processor_; | 190 sync_driver::ChangeProcessor* change_processor_; |
| 189 | 191 |
| 190 base::WeakPtrFactory<NonFrontendDataTypeController> weak_ptr_factory_; | 192 base::WeakPtrFactory<NonFrontendDataTypeController> weak_ptr_factory_; |
| 191 | 193 |
| 192 DISALLOW_COPY_AND_ASSIGN(NonFrontendDataTypeController); | 194 DISALLOW_COPY_AND_ASSIGN(NonFrontendDataTypeController); |
| 193 }; | 195 }; |
| 194 | 196 |
| 195 } // namespace browser_sync | 197 } // namespace browser_sync |
| 196 | 198 |
| 197 #endif // CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 199 #endif // CHROME_BROWSER_SYNC_GLUE_NON_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |