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

Side by Side Diff: components/sync/driver/glue/sync_backend_host.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_GLUE_SYNC_BACKEND_HOST_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "components/sync/base/model_type.h" 15 #include "components/sync/base/model_type.h"
16 #include "components/sync/base/weak_handle.h" 16 #include "components/sync/base/weak_handle.h"
17 #include "components/sync/core/configure_reason.h" 17 #include "components/sync/core/configure_reason.h"
18 #include "components/sync/core/shutdown_reason.h" 18 #include "components/sync/core/shutdown_reason.h"
19 #include "components/sync/core/sync_manager.h" 19 #include "components/sync/core/sync_manager.h"
20 #include "components/sync/core/sync_manager_factory.h" 20 #include "components/sync/core/sync_manager_factory.h"
21 #include "components/sync/driver/backend_data_type_configurer.h" 21 #include "components/sync/driver/backend_data_type_configurer.h"
22 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 22 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
23 23
24 class GURL; 24 class GURL;
25 25
26 namespace base { 26 namespace base {
27 class MessageLoop; 27 class MessageLoop;
28 } // namespace base 28 }
29 29
30 namespace syncer { 30 namespace syncer {
31
32 class CancelationSignal; 31 class CancelationSignal;
33 class ChangeProcessor;
34 class HttpPostProviderFactory; 32 class HttpPostProviderFactory;
35 class SyncFrontend;
36 class SyncManagerFactory; 33 class SyncManagerFactory;
37 class UnrecoverableErrorHandler; 34 class UnrecoverableErrorHandler;
35 }
36
37 namespace sync_driver {
38 class ChangeProcessor;
39 class SyncFrontend;
40 }
41
42 namespace browser_sync {
38 43
39 // An API to "host" the top level SyncAPI element. 44 // An API to "host" the top level SyncAPI element.
40 // 45 //
41 // This class handles dispatch of potentially blocking calls to appropriate 46 // This class handles dispatch of potentially blocking calls to appropriate
42 // threads and ensures that the SyncFrontend is only accessed on the UI loop. 47 // threads and ensures that the SyncFrontend is only accessed on the UI loop.
43 class SyncBackendHost : public BackendDataTypeConfigurer { 48 class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer {
44 public: 49 public:
45 typedef SyncStatus Status; 50 typedef syncer::SyncStatus Status;
46 typedef base::Callback<std::unique_ptr<HttpPostProviderFactory>( 51 typedef base::Callback<std::unique_ptr<syncer::HttpPostProviderFactory>(
47 CancelationSignal*)> 52 syncer::CancelationSignal*)>
48 HttpPostProviderFactoryGetter; 53 HttpPostProviderFactoryGetter;
49 54
50 // Stubs used by implementing classes. 55 // Stubs used by implementing classes.
51 SyncBackendHost(); 56 SyncBackendHost();
52 ~SyncBackendHost() override; 57 ~SyncBackendHost() override;
53 58
54 // Called on the frontend's thread to kick off asynchronous initialization. 59 // Called on the frontend's thread to kick off asynchronous initialization.
55 // Optionally deletes the "Sync Data" folder during init in order to make 60 // Optionally deletes the "Sync Data" folder during init in order to make
56 // sure we're starting fresh. 61 // sure we're starting fresh.
57 // 62 //
58 // |saved_nigori_state| is optional nigori state to restore from a previous 63 // |saved_nigori_state| is optional nigori state to restore from a previous
59 // backend instance. May be null. 64 // backend instance. May be null.
60 virtual void Initialize( 65 virtual void Initialize(
61 SyncFrontend* frontend, 66 sync_driver::SyncFrontend* frontend,
62 std::unique_ptr<base::Thread> sync_thread, 67 std::unique_ptr<base::Thread> sync_thread,
63 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 68 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
64 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 69 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
65 const WeakHandle<JsEventHandler>& event_handler, 70 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
66 const GURL& service_url, 71 const GURL& service_url,
67 const std::string& sync_user_agent, 72 const std::string& sync_user_agent,
68 const SyncCredentials& credentials, 73 const syncer::SyncCredentials& credentials,
69 bool delete_sync_data_folder, 74 bool delete_sync_data_folder,
70 std::unique_ptr<SyncManagerFactory> sync_manager_factory, 75 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory,
71 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, 76 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
77 unrecoverable_error_handler,
72 const base::Closure& report_unrecoverable_error_function, 78 const base::Closure& report_unrecoverable_error_function,
73 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, 79 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
74 std::unique_ptr<SyncEncryptionHandler::NigoriState> 80 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState>
75 saved_nigori_state) = 0; 81 saved_nigori_state) = 0;
76 82
77 // Called on the frontend's thread to trigger a refresh. 83 // Called on the frontend's thread to trigger a refresh.
78 virtual void TriggerRefresh(const ModelTypeSet& types) = 0; 84 virtual void TriggerRefresh(const syncer::ModelTypeSet& types) = 0;
79 85
80 // Called on the frontend's thread to update SyncCredentials. 86 // Called on the frontend's thread to update SyncCredentials.
81 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0; 87 virtual void UpdateCredentials(
88 const syncer::SyncCredentials& credentials) = 0;
82 89
83 // This starts the SyncerThread running a Syncer object to communicate with 90 // This starts the SyncerThread running a Syncer object to communicate with
84 // sync servers. Until this is called, no changes will leave or enter this 91 // sync servers. Until this is called, no changes will leave or enter this
85 // browser from the cloud / sync servers. 92 // browser from the cloud / sync servers.
86 // Called on |frontend_loop_|. 93 // Called on |frontend_loop_|.
87 virtual void StartSyncingWithServer() = 0; 94 virtual void StartSyncingWithServer() = 0;
88 95
89 // Called on |frontend_loop_| to asynchronously set a new passphrase for 96 // Called on |frontend_loop_| to asynchronously set a new passphrase for
90 // encryption. Note that it is an error to call SetEncryptionPassphrase under 97 // encryption. Note that it is an error to call SetEncryptionPassphrase under
91 // the following circumstances: 98 // the following circumstances:
(...skipping 26 matching lines...) Expand all
118 // See the implementation and Core::DoShutdown for details. 125 // See the implementation and Core::DoShutdown for details.
119 // Must be called *after* StopSyncingForShutdown. 126 // Must be called *after* StopSyncingForShutdown.
120 // For any reason other than BROWSER_SHUTDOWN, caller should claim sync 127 // For any reason other than BROWSER_SHUTDOWN, caller should claim sync
121 // thread because: 128 // thread because:
122 // * during browser shutdown sync thread is not claimed to avoid blocking 129 // * during browser shutdown sync thread is not claimed to avoid blocking
123 // browser shutdown on sync shutdown. 130 // browser shutdown on sync shutdown.
124 // * otherwise sync thread is claimed so that if sync backend is recreated 131 // * otherwise sync thread is claimed so that if sync backend is recreated
125 // later, initialization of new backend is serialized on previous sync 132 // later, initialization of new backend is serialized on previous sync
126 // thread after cleanup of previous backend to avoid old/new backends 133 // thread after cleanup of previous backend to avoid old/new backends
127 // interfere with each other. 134 // interfere with each other.
128 virtual std::unique_ptr<base::Thread> Shutdown(ShutdownReason reason) = 0; 135 virtual std::unique_ptr<base::Thread> Shutdown(
136 syncer::ShutdownReason reason) = 0;
129 137
130 // Removes all current registrations from the backend on the 138 // Removes all current registrations from the backend on the
131 // InvalidationService. 139 // InvalidationService.
132 virtual void UnregisterInvalidationIds() = 0; 140 virtual void UnregisterInvalidationIds() = 0;
133 141
134 // Changes the set of data types that are currently being synced. 142 // Changes the set of data types that are currently being synced.
135 // The ready_task will be run when configuration is done with the 143 // The ready_task will be run when configuration is done with the
136 // set of all types that failed configuration (i.e., if its argument 144 // set of all types that failed configuration (i.e., if its argument
137 // is non-empty, then an error was encountered). 145 // is non-empty, then an error was encountered).
138 // Returns the set of types that are ready to start without needing any 146 // Returns the set of types that are ready to start without needing any
139 // further sync activity. 147 // further sync activity.
140 // BackendDataTypeConfigurer implementation. 148 // BackendDataTypeConfigurer implementation.
141 ModelTypeSet ConfigureDataTypes( 149 syncer::ModelTypeSet ConfigureDataTypes(
142 ConfigureReason reason, 150 syncer::ConfigureReason reason,
143 const DataTypeConfigStateMap& config_state_map, 151 const DataTypeConfigStateMap& config_state_map,
144 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, 152 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
153 ready_task,
145 const base::Callback<void()>& retry_callback) override = 0; 154 const base::Callback<void()>& retry_callback) override = 0;
146 155
147 // Turns on encryption of all present and future sync data. 156 // Turns on encryption of all present and future sync data.
148 virtual void EnableEncryptEverything() = 0; 157 virtual void EnableEncryptEverything() = 0;
149 158
150 // Called on |frontend_loop_| to obtain a handle to the UserShare needed for 159 // Called on |frontend_loop_| to obtain a handle to the UserShare needed for
151 // creating transactions. Should not be called before we signal 160 // creating transactions. Should not be called before we signal
152 // initialization is complete with OnBackendInitialized(). 161 // initialization is complete with OnBackendInitialized().
153 virtual UserShare* GetUserShare() const = 0; 162 virtual syncer::UserShare* GetUserShare() const = 0;
154 163
155 // Called from any thread to obtain current status information in detailed or 164 // Called from any thread to obtain current status information in detailed or
156 // summarized form. 165 // summarized form.
157 virtual Status GetDetailedStatus() = 0; 166 virtual Status GetDetailedStatus() = 0;
158 virtual SyncCycleSnapshot GetLastCycleSnapshot() const = 0; 167 virtual syncer::SyncCycleSnapshot GetLastCycleSnapshot() const = 0;
159 168
160 // Determines if the underlying sync engine has made any local changes to 169 // Determines if the underlying sync engine has made any local changes to
161 // items that have not yet been synced with the server. 170 // items that have not yet been synced with the server.
162 // ONLY CALL THIS IF OnInitializationComplete was called! 171 // ONLY CALL THIS IF OnInitializationComplete was called!
163 virtual bool HasUnsyncedItems() const = 0; 172 virtual bool HasUnsyncedItems() const = 0;
164 173
165 // Whether or not we are syncing encryption keys. 174 // Whether or not we are syncing encryption keys.
166 virtual bool IsNigoriEnabled() const = 0; 175 virtual bool IsNigoriEnabled() const = 0;
167 176
168 // Returns the type of passphrase being used to encrypt data. See 177 // Returns the type of passphrase being used to encrypt data. See
169 // sync_encryption_handler.h. 178 // sync_encryption_handler.h.
170 virtual PassphraseType GetPassphraseType() const = 0; 179 virtual syncer::PassphraseType GetPassphraseType() const = 0;
171 180
172 // If an explicit passphrase is in use, returns the time at which that 181 // If an explicit passphrase is in use, returns the time at which that
173 // passphrase was set (if available). 182 // passphrase was set (if available).
174 virtual base::Time GetExplicitPassphraseTime() const = 0; 183 virtual base::Time GetExplicitPassphraseTime() const = 0;
175 184
176 // True if the cryptographer has any keys available to attempt decryption. 185 // True if the cryptographer has any keys available to attempt decryption.
177 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped 186 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped
178 // using a token previously received. 187 // using a token previously received.
179 virtual bool IsCryptographerReady(const BaseTransaction* trans) const = 0; 188 virtual bool IsCryptographerReady(
189 const syncer::BaseTransaction* trans) const = 0;
180 190
181 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const = 0; 191 virtual void GetModelSafeRoutingInfo(
192 syncer::ModelSafeRoutingInfo* out) const = 0;
182 193
183 // Send a message to the sync thread to persist the Directory to disk. 194 // Send a message to the sync thread to persist the Directory to disk.
184 virtual void FlushDirectory() const = 0; 195 virtual void FlushDirectory() const = 0;
185 196
186 // Requests that the backend forward to the fronent any protocol events in 197 // Requests that the backend forward to the fronent any protocol events in
187 // its buffer and begin forwarding automatically from now on. Repeated calls 198 // its buffer and begin forwarding automatically from now on. Repeated calls
188 // to this function may result in the same events being emitted several 199 // to this function may result in the same events being emitted several
189 // times. 200 // times.
190 virtual void RequestBufferedProtocolEventsAndEnableForwarding() = 0; 201 virtual void RequestBufferedProtocolEventsAndEnableForwarding() = 0;
191 202
192 // Disables protocol event forwarding. 203 // Disables protocol event forwarding.
193 virtual void DisableProtocolEventForwarding() = 0; 204 virtual void DisableProtocolEventForwarding() = 0;
194 205
195 // Enables the sending of directory type debug counters. Also, for every 206 // Enables the sending of directory type debug counters. Also, for every
196 // time it is called, it makes an explicit request that updates to an update 207 // time it is called, it makes an explicit request that updates to an update
197 // for all counters be emitted. 208 // for all counters be emitted.
198 virtual void EnableDirectoryTypeDebugInfoForwarding() = 0; 209 virtual void EnableDirectoryTypeDebugInfoForwarding() = 0;
199 210
200 // Disables the sending of directory type debug counters. 211 // Disables the sending of directory type debug counters.
201 virtual void DisableDirectoryTypeDebugInfoForwarding() = 0; 212 virtual void DisableDirectoryTypeDebugInfoForwarding() = 0;
202 213
203 virtual base::MessageLoop* GetSyncLoopForTesting() = 0; 214 virtual base::MessageLoop* GetSyncLoopForTesting() = 0;
204 215
205 // Triggers sync cycle to update |types|. 216 // Triggers sync cycle to update |types|.
206 virtual void RefreshTypesForTest(ModelTypeSet types) = 0; 217 virtual void RefreshTypesForTest(syncer::ModelTypeSet types) = 0;
207 218
208 // See SyncManager::ClearServerData. 219 // See SyncManager::ClearServerData.
209 virtual void ClearServerData( 220 virtual void ClearServerData(
210 const SyncManager::ClearServerDataCallback& callback) = 0; 221 const syncer::SyncManager::ClearServerDataCallback& callback) = 0;
211 222
212 // Notify the syncer that the cookie jar has changed. 223 // Notify the syncer that the cookie jar has changed.
213 // See SyncManager::OnCookieJarChanged. 224 // See SyncManager::OnCookieJarChanged.
214 virtual void OnCookieJarChanged(bool account_mismatch, bool empty_jar) = 0; 225 virtual void OnCookieJarChanged(bool account_mismatch, bool empty_jar) = 0;
215 226
216 private: 227 private:
217 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 228 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
218 }; 229 };
219 230
220 } // namespace syncer 231 } // namespace browser_sync
221 232
222 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ 233 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « components/sync/driver/glue/chrome_report_unrecoverable_error.cc ('k') | components/sync/driver/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698