Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: components/sync/driver/frontend_data_type_controller.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__ 5 #ifndef COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__
6 #define COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__ 6 #define COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/sync/api/data_type_error_handler.h" 13 #include "components/sync/api/data_type_error_handler.h"
14 #include "components/sync/driver/directory_data_type_controller.h" 14 #include "components/sync/driver/directory_data_type_controller.h"
15 15
16 namespace base { 16 namespace base {
17 class TimeDelta; 17 class TimeDelta;
18 } 18 } // namespace base
19 19
20 namespace syncer { 20 namespace syncer {
21 class SyncError;
22 }
23 21
24 namespace sync_driver {
25 class AssociatorInterface; 22 class AssociatorInterface;
26 class ChangeProcessor; 23 class ChangeProcessor;
27 class SyncClient; 24 class SyncClient;
28 } 25 class SyncError;
29
30 namespace browser_sync {
31 26
32 // Implementation for datatypes that reside on the frontend thread 27 // Implementation for datatypes that reside on the frontend thread
33 // (UI thread). This is the same thread we perform initialization on, so we 28 // (UI thread). This is the same thread we perform initialization on, so we
34 // don't have to worry about thread safety. The main start/stop funtionality is 29 // don't have to worry about thread safety. The main start/stop funtionality is
35 // implemented by default. 30 // implemented by default.
36 // Derived classes must implement (at least): 31 // Derived classes must implement (at least):
37 // syncer::ModelType type() const 32 // ModelType type() const
38 // void CreateSyncComponents(); 33 // void CreateSyncComponents();
39 // NOTE: This class is deprecated! New sync datatypes should be using the 34 // NOTE: This class is deprecated! New sync datatypes should be using the
40 // syncer::SyncableService API and the UIDataTypeController instead. 35 // SyncableService API and the UIDataTypeController instead.
41 // TODO(zea): Delete this once all types are on the new API. 36 // TODO(zea): Delete this once all types are on the new API.
42 class FrontendDataTypeController 37 class FrontendDataTypeController : public DirectoryDataTypeController {
43 : public sync_driver::DirectoryDataTypeController {
44 public: 38 public:
45 // |dump_stack| is called when an unrecoverable error occurs. 39 // |dump_stack| is called when an unrecoverable error occurs.
46 FrontendDataTypeController(syncer::ModelType type, 40 FrontendDataTypeController(ModelType type,
47 const base::Closure& dump_stack, 41 const base::Closure& dump_stack,
48 sync_driver::SyncClient* sync_client); 42 SyncClient* sync_client);
49 ~FrontendDataTypeController() override; 43 ~FrontendDataTypeController() override;
50 44
51 // DataTypeController interface. 45 // DataTypeController interface.
52 void LoadModels(const ModelLoadCallback& model_load_callback) override; 46 void LoadModels(const ModelLoadCallback& model_load_callback) override;
53 void StartAssociating(const StartCallback& start_callback) override; 47 void StartAssociating(const StartCallback& start_callback) override;
54 void Stop() override; 48 void Stop() override;
55 syncer::ModelSafeGroup model_safe_group() const override; 49 ModelSafeGroup model_safe_group() const override;
56 std::string name() const override; 50 std::string name() const override;
57 State state() const override; 51 State state() const override;
58 52
59 protected: 53 protected:
60 friend class FrontendDataTypeControllerMock; 54 friend class FrontendDataTypeControllerMock;
61 55
62 // For testing only. 56 // For testing only.
63 FrontendDataTypeController(); 57 FrontendDataTypeController();
64 58
65 // Kick off any dependent services that need to be running before we can 59 // Kick off any dependent services that need to be running before we can
66 // associate models. The default implementation is a no-op. 60 // associate models. The default implementation is a no-op.
67 // Return value: 61 // Return value:
68 // True - if models are ready and association can proceed. 62 // True - if models are ready and association can proceed.
69 // False - if models are not ready. Associate() should be called when the 63 // False - if models are not ready. Associate() should be called when the
70 // models are ready. Refer to Start(_) implementation. 64 // models are ready. Refer to Start(_) implementation.
71 virtual bool StartModels(); 65 virtual bool StartModels();
72 66
73 // Datatype specific creation of sync components. 67 // Datatype specific creation of sync components.
74 virtual void CreateSyncComponents() = 0; 68 virtual void CreateSyncComponents() = 0;
75 69
76 // Perform any DataType controller specific state cleanup before stopping 70 // Perform any DataType controller specific state cleanup before stopping
77 // the datatype controller. The default implementation is a no-op. 71 // the datatype controller. The default implementation is a no-op.
78 virtual void CleanUpState(); 72 virtual void CleanUpState();
79 73
80 // Helper method for cleaning up state and running the start callback. 74 // Helper method for cleaning up state and running the start callback.
81 virtual void StartDone(ConfigureResult start_result, 75 virtual void StartDone(ConfigureResult start_result,
82 const syncer::SyncMergeResult& local_merge_result, 76 const SyncMergeResult& local_merge_result,
83 const syncer::SyncMergeResult& syncer_merge_result); 77 const SyncMergeResult& syncer_merge_result);
84 78
85 // Record association time. 79 // Record association time.
86 virtual void RecordAssociationTime(base::TimeDelta time); 80 virtual void RecordAssociationTime(base::TimeDelta time);
87 // Record causes of start failure. 81 // Record causes of start failure.
88 virtual void RecordStartFailure(ConfigureResult result); 82 virtual void RecordStartFailure(ConfigureResult result);
89 83
90 virtual sync_driver::AssociatorInterface* model_associator() const; 84 virtual AssociatorInterface* model_associator() const;
91 virtual void set_model_associator( 85 virtual void set_model_associator(AssociatorInterface* associator);
92 sync_driver::AssociatorInterface* associator); 86 ChangeProcessor* GetChangeProcessor() const override;
93 sync_driver::ChangeProcessor* GetChangeProcessor() const override; 87 virtual void set_change_processor(ChangeProcessor* processor);
94 virtual void set_change_processor(sync_driver::ChangeProcessor* processor);
95 88
96 // If the DTC is waiting for models to load, once the models are 89 // If the DTC is waiting for models to load, once the models are
97 // loaded the datatype service will call this function on DTC to let 90 // loaded the datatype service will call this function on DTC to let
98 // us know that it is safe to start associating. 91 // us know that it is safe to start associating.
99 void OnModelLoaded(); 92 void OnModelLoaded();
100 93
101 std::unique_ptr<syncer::DataTypeErrorHandler> CreateErrorHandler() override; 94 std::unique_ptr<DataTypeErrorHandler> CreateErrorHandler() override;
102 95
103 State state_; 96 State state_;
104 97
105 StartCallback start_callback_; 98 StartCallback start_callback_;
106 ModelLoadCallback model_load_callback_; 99 ModelLoadCallback model_load_callback_;
107 100
108 // TODO(sync): transition all datatypes to SyncableService and deprecate 101 // TODO(sync): transition all datatypes to SyncableService and deprecate
109 // AssociatorInterface. 102 // AssociatorInterface.
110 std::unique_ptr<sync_driver::AssociatorInterface> model_associator_; 103 std::unique_ptr<AssociatorInterface> model_associator_;
111 std::unique_ptr<sync_driver::ChangeProcessor> change_processor_; 104 std::unique_ptr<ChangeProcessor> change_processor_;
112 105
113 private: 106 private:
114 // Build sync components and associate models. 107 // Build sync components and associate models.
115 virtual void Associate(); 108 virtual void Associate();
116 109
117 void AbortModelLoad(); 110 void AbortModelLoad();
118 111
119 // Clean up our state and state variables. Called in response 112 // Clean up our state and state variables. Called in response
120 // to a failure or abort or stop. 113 // to a failure or abort or stop.
121 void CleanUp(); 114 void CleanUp();
122 115
123 // Handle an unrecoverable error. 116 // Handle an unrecoverable error.
124 void OnUnrecoverableError(const syncer::SyncError& error); 117 void OnUnrecoverableError(const SyncError& error);
125 118
126 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController); 119 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController);
127 }; 120 };
128 121
129 } // namespace browser_sync 122 } // namespace syncer
130 123
131 #endif // COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__ 124 #endif // COMPONENTS_SYNC_DRIVER_FRONTEND_DATA_TYPE_CONTROLLER_H__
OLDNEW
« no previous file with comments | « components/sync/driver/fake_sync_service.cc ('k') | components/sync/driver/frontend_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698