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

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

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_UI_DATA_TYPE_CONTROLLER_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_UI_DATA_TYPE_CONTROLLER_H_
6 #define COMPONENTS_SYNC_DRIVER_UI_DATA_TYPE_CONTROLLER_H_ 6 #define COMPONENTS_SYNC_DRIVER_UI_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 "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "components/sync/driver/directory_data_type_controller.h" 15 #include "components/sync/driver/directory_data_type_controller.h"
16 #include "components/sync/driver/shared_change_processor.h" 16 #include "components/sync/driver/shared_change_processor.h"
17 17
18 namespace base { 18 namespace base {
19 class TimeDelta; 19 class TimeDelta;
20 } // namespace base 20 }
21 21
22 namespace syncer { 22 namespace syncer {
23
24 class SyncableService; 23 class SyncableService;
25 class SyncClient; 24 class SyncClient;
26 class SyncError; 25 class SyncError;
26 }
27
28 namespace sync_driver {
27 29
28 // Implementation for datatypes that reside on the (UI thread). This is the same 30 // Implementation for datatypes that reside on the (UI thread). This is the same
29 // thread we perform initialization on, so we don't have to worry about thread 31 // thread we perform initialization on, so we don't have to worry about thread
30 // safety. The main start/stop funtionality is implemented by default. 32 // safety. The main start/stop funtionality is implemented by default.
31 // Note: RefCountedThreadSafe by way of DataTypeController. 33 // Note: RefCountedThreadSafe by way of DataTypeController.
32 class UIDataTypeController : public DirectoryDataTypeController { 34 class UIDataTypeController : public DirectoryDataTypeController {
33 public: 35 public:
34 // |dump_stack| is called when an unrecoverable error occurs. 36 // |dump_stack| is called when an unrecoverable error occurs.
35 UIDataTypeController(ModelType type, 37 UIDataTypeController(syncer::ModelType type,
36 const base::Closure& dump_stack, 38 const base::Closure& dump_stack,
37 SyncClient* sync_client); 39 SyncClient* sync_client);
38 ~UIDataTypeController() override; 40 ~UIDataTypeController() override;
39 41
40 // DataTypeController interface. 42 // DataTypeController interface.
41 void LoadModels(const ModelLoadCallback& model_load_callback) override; 43 void LoadModels(const ModelLoadCallback& model_load_callback) override;
42 void StartAssociating(const StartCallback& start_callback) override; 44 void StartAssociating(const StartCallback& start_callback) override;
43 void Stop() override; 45 void Stop() override;
44 ModelSafeGroup model_safe_group() const override; 46 syncer::ModelSafeGroup model_safe_group() const override;
45 ChangeProcessor* GetChangeProcessor() const override; 47 ChangeProcessor* GetChangeProcessor() const override;
46 std::string name() const override; 48 std::string name() const override;
47 State state() const override; 49 State state() const override;
48 50
49 // Used by tests to override the factory used to create 51 // Used by tests to override the factory used to create
50 // GenericChangeProcessors. 52 // GenericChangeProcessors.
51 void SetGenericChangeProcessorFactoryForTest( 53 void SetGenericChangeProcessorFactoryForTest(
52 std::unique_ptr<GenericChangeProcessorFactory> factory); 54 std::unique_ptr<GenericChangeProcessorFactory> factory);
53 55
54 protected: 56 protected:
55 // For testing only. 57 // For testing only.
56 UIDataTypeController(); 58 UIDataTypeController();
57 59
58 // Start any dependent services that need to be running before we can 60 // Start any dependent services that need to be running before we can
59 // associate models. The default implementation is a no-op. 61 // associate models. The default implementation is a no-op.
60 // Return value: 62 // Return value:
61 // True - if models are ready and association can proceed. 63 // True - if models are ready and association can proceed.
62 // False - if models are not ready. OnModelLoaded() should be called when 64 // False - if models are not ready. OnModelLoaded() should be called when
63 // the models are ready. 65 // the models are ready.
64 virtual bool StartModels(); 66 virtual bool StartModels();
65 67
66 // Perform any DataType controller specific state cleanup before stopping 68 // Perform any DataType controller specific state cleanup before stopping
67 // the datatype controller. The default implementation is a no-op. 69 // the datatype controller. The default implementation is a no-op.
68 virtual void StopModels(); 70 virtual void StopModels();
69 71
70 // Helper method for cleaning up state and invoking the start callback. 72 // Helper method for cleaning up state and invoking the start callback.
71 virtual void StartDone(ConfigureResult result, 73 virtual void StartDone(ConfigureResult result,
72 const SyncMergeResult& local_merge_result, 74 const syncer::SyncMergeResult& local_merge_result,
73 const SyncMergeResult& syncer_merge_result); 75 const syncer::SyncMergeResult& syncer_merge_result);
74 76
75 // Record association time. 77 // Record association time.
76 virtual void RecordAssociationTime(base::TimeDelta time); 78 virtual void RecordAssociationTime(base::TimeDelta time);
77 // Record causes of start failure. 79 // Record causes of start failure.
78 virtual void RecordStartFailure(ConfigureResult result); 80 virtual void RecordStartFailure(ConfigureResult result);
79 81
80 // If the DTC is waiting for models to load, once the models are 82 // If the DTC is waiting for models to load, once the models are
81 // loaded the datatype service will call this function on DTC to let 83 // loaded the datatype service will call this function on DTC to let
82 // us know that it is safe to start associating. 84 // us know that it is safe to start associating.
83 void OnModelLoaded(); 85 void OnModelLoaded();
84 86
85 std::unique_ptr<DataTypeErrorHandler> CreateErrorHandler() override; 87 std::unique_ptr<syncer::DataTypeErrorHandler> CreateErrorHandler() override;
86 88
87 State state_; 89 State state_;
88 90
89 StartCallback start_callback_; 91 StartCallback start_callback_;
90 ModelLoadCallback model_load_callback_; 92 ModelLoadCallback model_load_callback_;
91 93
92 // Sync's interface to the datatype. All sync changes for |type_| are pushed 94 // Sync's interface to the datatype. All sync changes for |type_| are pushed
93 // through it to the datatype as well as vice versa. 95 // through it to the datatype as well as vice versa.
94 // 96 //
95 // Lifetime: it gets created when Start()) is called, and a reference to it 97 // Lifetime: it gets created when Start()) is called, and a reference to it
96 // is passed to |local_service_| during Associate(). We release our reference 98 // is passed to |local_service_| during Associate(). We release our reference
97 // when Stop() or StartFailed() is called, and |local_service_| releases its 99 // when Stop() or StartFailed() is called, and |local_service_| releases its
98 // reference when local_service_->StopSyncing() is called or when it is 100 // reference when local_service_->StopSyncing() is called or when it is
99 // destroyed. 101 // destroyed.
100 // 102 //
101 // Note: we use refcounting here primarily so that we can keep a uniform 103 // Note: we use refcounting here primarily so that we can keep a uniform
102 // SyncableService API, whether the datatype lives on the UI thread or not 104 // SyncableService API, whether the datatype lives on the UI thread or not
103 // (a SyncableService takes ownership of its SyncChangeProcessor when 105 // (a syncer::SyncableService takes ownership of its SyncChangeProcessor when
104 // MergeDataAndStartSyncing is called). This will help us eventually merge the 106 // MergeDataAndStartSyncing is called). This will help us eventually merge the
105 // two datatype controller implementations (for ui and non-ui thread 107 // two datatype controller implementations (for ui and non-ui thread
106 // datatypes). 108 // datatypes).
107 scoped_refptr<SharedChangeProcessor> shared_change_processor_; 109 scoped_refptr<SharedChangeProcessor> shared_change_processor_;
108 110
109 std::unique_ptr<GenericChangeProcessorFactory> processor_factory_; 111 std::unique_ptr<GenericChangeProcessorFactory> processor_factory_;
110 112
111 // A weak pointer to the actual local syncable service, which performs all the 113 // A weak pointer to the actual local syncable service, which performs all the
112 // real work. We do not own the object. 114 // real work. We do not own the object.
113 base::WeakPtr<SyncableService> local_service_; 115 base::WeakPtr<syncer::SyncableService> local_service_;
114 116
115 private: 117 private:
116 // Associate the sync model with the service's model, then start syncing. 118 // Associate the sync model with the service's model, then start syncing.
117 virtual void Associate(); 119 virtual void Associate();
118 120
119 virtual void AbortModelLoad(); 121 virtual void AbortModelLoad();
120 122
121 void OnUnrecoverableError(const SyncError& error); 123 void OnUnrecoverableError(const syncer::SyncError& error);
122 124
123 DISALLOW_COPY_AND_ASSIGN(UIDataTypeController); 125 DISALLOW_COPY_AND_ASSIGN(UIDataTypeController);
124 }; 126 };
125 127
126 } // namespace syncer 128 } // namespace sync_driver
127 129
128 #endif // COMPONENTS_SYNC_DRIVER_UI_DATA_TYPE_CONTROLLER_H_ 130 #endif // COMPONENTS_SYNC_DRIVER_UI_DATA_TYPE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/sync/driver/system_encryptor_unittest.cc ('k') | components/sync/driver/ui_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698