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_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
6 #define CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "components/sync_driver/data_type_controller.h" | 13 #include "components/sync_driver/data_type_controller.h" |
14 #include "components/sync_driver/data_type_error_handler.h" | 14 #include "components/sync_driver/data_type_error_handler.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 class ProfileSyncService; | 17 class ProfileSyncService; |
18 class ProfileSyncComponentsFactory; | 18 class ProfileSyncComponentsFactory; |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class TimeDelta; | 21 class TimeDelta; |
22 } | 22 } |
23 | 23 |
24 namespace syncer { | 24 namespace syncer { |
25 class SyncError; | 25 class SyncError; |
26 } | 26 } |
27 | 27 |
| 28 namespace sync_driver { |
| 29 class AssociatorInterface; |
| 30 class ChangeProcessor; |
| 31 } |
| 32 |
28 namespace browser_sync { | 33 namespace browser_sync { |
29 | 34 |
30 class AssociatorInterface; | |
31 class ChangeProcessor; | |
32 | |
33 // Implementation for datatypes that reside on the frontend thread | 35 // Implementation for datatypes that reside on the frontend thread |
34 // (UI thread). This is the same thread we perform initialization on, so we | 36 // (UI thread). This is the same thread we perform initialization on, so we |
35 // don't have to worry about thread safety. The main start/stop funtionality is | 37 // don't have to worry about thread safety. The main start/stop funtionality is |
36 // implemented by default. | 38 // implemented by default. |
37 // Derived classes must implement (at least): | 39 // Derived classes must implement (at least): |
38 // syncer::ModelType type() const | 40 // syncer::ModelType type() const |
39 // void CreateSyncComponents(); | 41 // void CreateSyncComponents(); |
40 // NOTE: This class is deprecated! New sync datatypes should be using the | 42 // NOTE: This class is deprecated! New sync datatypes should be using the |
41 // syncer::SyncableService API and the UIDataTypeController instead. | 43 // syncer::SyncableService API and the UIDataTypeController instead. |
42 // TODO(zea): Delete this once all types are on the new API. | 44 // TODO(zea): Delete this once all types are on the new API. |
43 class FrontendDataTypeController : public DataTypeController { | 45 class FrontendDataTypeController : public sync_driver::DataTypeController { |
44 public: | 46 public: |
45 FrontendDataTypeController( | 47 FrontendDataTypeController( |
46 scoped_refptr<base::MessageLoopProxy> ui_thread, | 48 scoped_refptr<base::MessageLoopProxy> ui_thread, |
47 const base::Closure& error_callback, | 49 const base::Closure& error_callback, |
48 ProfileSyncComponentsFactory* profile_sync_factory, | 50 ProfileSyncComponentsFactory* profile_sync_factory, |
49 Profile* profile, | 51 Profile* profile, |
50 ProfileSyncService* sync_service); | 52 ProfileSyncService* sync_service); |
51 | 53 |
52 // DataTypeController interface. | 54 // DataTypeController interface. |
53 virtual void LoadModels( | 55 virtual void LoadModels( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 virtual void StartDone( | 95 virtual void StartDone( |
94 StartResult start_result, | 96 StartResult start_result, |
95 const syncer::SyncMergeResult& local_merge_result, | 97 const syncer::SyncMergeResult& local_merge_result, |
96 const syncer::SyncMergeResult& syncer_merge_result); | 98 const syncer::SyncMergeResult& syncer_merge_result); |
97 | 99 |
98 // Record association time. | 100 // Record association time. |
99 virtual void RecordAssociationTime(base::TimeDelta time); | 101 virtual void RecordAssociationTime(base::TimeDelta time); |
100 // Record causes of start failure. | 102 // Record causes of start failure. |
101 virtual void RecordStartFailure(StartResult result); | 103 virtual void RecordStartFailure(StartResult result); |
102 | 104 |
103 virtual AssociatorInterface* model_associator() const; | 105 virtual sync_driver::AssociatorInterface* model_associator() const; |
104 virtual void set_model_associator(AssociatorInterface* associator); | 106 virtual void set_model_associator( |
105 virtual ChangeProcessor* GetChangeProcessor() const OVERRIDE; | 107 sync_driver::AssociatorInterface* associator); |
106 virtual void set_change_processor(ChangeProcessor* processor); | 108 virtual sync_driver::ChangeProcessor* GetChangeProcessor() const OVERRIDE; |
| 109 virtual void set_change_processor(sync_driver::ChangeProcessor* processor); |
107 | 110 |
108 // Handles the reporting of unrecoverable error. It records stuff in | 111 // Handles the reporting of unrecoverable error. It records stuff in |
109 // UMA and reports to breakpad. | 112 // UMA and reports to breakpad. |
110 // Virtual for testing purpose. | 113 // Virtual for testing purpose. |
111 virtual void RecordUnrecoverableError( | 114 virtual void RecordUnrecoverableError( |
112 const tracked_objects::Location& from_here, | 115 const tracked_objects::Location& from_here, |
113 const std::string& message); | 116 const std::string& message); |
114 | 117 |
115 ProfileSyncComponentsFactory* const profile_sync_factory_; | 118 ProfileSyncComponentsFactory* const profile_sync_factory_; |
116 Profile* const profile_; | 119 Profile* const profile_; |
117 ProfileSyncService* const sync_service_; | 120 ProfileSyncService* const sync_service_; |
118 | 121 |
119 State state_; | 122 State state_; |
120 | 123 |
121 StartCallback start_callback_; | 124 StartCallback start_callback_; |
122 ModelLoadCallback model_load_callback_; | 125 ModelLoadCallback model_load_callback_; |
123 | 126 |
124 // TODO(sync): transition all datatypes to SyncableService and deprecate | 127 // TODO(sync): transition all datatypes to SyncableService and deprecate |
125 // AssociatorInterface. | 128 // AssociatorInterface. |
126 scoped_ptr<AssociatorInterface> model_associator_; | 129 scoped_ptr<sync_driver::AssociatorInterface> model_associator_; |
127 scoped_ptr<ChangeProcessor> change_processor_; | 130 scoped_ptr<sync_driver::ChangeProcessor> change_processor_; |
128 | 131 |
129 private: | 132 private: |
130 // Build sync components and associate models. | 133 // Build sync components and associate models. |
131 // Return value: | 134 // Return value: |
132 // True - if association was successful. FinishStart should have been | 135 // True - if association was successful. FinishStart should have been |
133 // invoked. | 136 // invoked. |
134 // False - if association failed. StartFailed should have been invoked. | 137 // False - if association failed. StartFailed should have been invoked. |
135 virtual bool Associate(); | 138 virtual bool Associate(); |
136 | 139 |
137 void AbortModelLoad(); | 140 void AbortModelLoad(); |
138 | 141 |
139 // Clean up our state and state variables. Called in response | 142 // Clean up our state and state variables. Called in response |
140 // to a failure or abort or stop. | 143 // to a failure or abort or stop. |
141 void CleanUp(); | 144 void CleanUp(); |
142 | 145 |
143 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController); | 146 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController); |
144 }; | 147 }; |
145 | 148 |
146 } // namespace browser_sync | 149 } // namespace browser_sync |
147 | 150 |
148 #endif // CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 151 #endif // CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
OLD | NEW |