OLD | NEW |
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 SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "google_apis/gaia/oauth2_token_service.h" | 19 #include "google_apis/gaia/oauth2_token_service.h" |
20 #include "sync/base/sync_export.h" | 20 #include "sync/base/sync_export.h" |
21 #include "sync/internal_api/public/base/invalidation_interface.h" | 21 #include "sync/internal_api/public/base/invalidation_interface.h" |
22 #include "sync/internal_api/public/base/model_type.h" | 22 #include "sync/internal_api/public/base/model_type.h" |
23 #include "sync/internal_api/public/change_record.h" | 23 #include "sync/internal_api/public/change_record.h" |
24 #include "sync/internal_api/public/configure_reason.h" | 24 #include "sync/internal_api/public/configure_reason.h" |
25 #include "sync/internal_api/public/engine/model_safe_worker.h" | 25 #include "sync/internal_api/public/engine/model_safe_worker.h" |
26 #include "sync/internal_api/public/engine/sync_status.h" | 26 #include "sync/internal_api/public/engine/sync_status.h" |
27 #include "sync/internal_api/public/events/protocol_event.h" | 27 #include "sync/internal_api/public/events/protocol_event.h" |
| 28 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 29 #include "sync/internal_api/public/internal_components_factory.h" |
28 #include "sync/internal_api/public/shutdown_reason.h" | 30 #include "sync/internal_api/public/shutdown_reason.h" |
29 #include "sync/internal_api/public/sync_context_proxy.h" | 31 #include "sync/internal_api/public/sync_context_proxy.h" |
30 #include "sync/internal_api/public/sync_encryption_handler.h" | 32 #include "sync/internal_api/public/sync_encryption_handler.h" |
31 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 33 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
32 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 34 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
33 #include "sync/internal_api/public/util/weak_handle.h" | 35 #include "sync/internal_api/public/util/weak_handle.h" |
34 #include "sync/protocol/sync_protocol_error.h" | 36 #include "sync/protocol/sync_protocol_error.h" |
35 | 37 |
36 class GURL; | 38 class GURL; |
37 | 39 |
38 namespace sync_pb { | 40 namespace sync_pb { |
39 class EncryptedData; | 41 class EncryptedData; |
40 } // namespace sync_pb | 42 } // namespace sync_pb |
41 | 43 |
42 namespace syncer { | 44 namespace syncer { |
43 | 45 |
44 class BaseTransaction; | 46 class BaseTransaction; |
45 class CancelationSignal; | 47 class CancelationSignal; |
46 class DataTypeDebugInfoListener; | 48 class DataTypeDebugInfoListener; |
47 class Encryptor; | 49 class Encryptor; |
48 class ExtensionsActivity; | 50 class ExtensionsActivity; |
49 class HttpPostProviderFactory; | |
50 class InternalComponentsFactory; | 51 class InternalComponentsFactory; |
51 class JsBackend; | 52 class JsBackend; |
52 class JsEventHandler; | 53 class JsEventHandler; |
53 class ProtocolEvent; | 54 class ProtocolEvent; |
54 class SyncContextProxy; | 55 class SyncContextProxy; |
55 class SyncEncryptionHandler; | 56 class SyncEncryptionHandler; |
56 class SyncScheduler; | 57 class SyncScheduler; |
57 class TypeDebugInfoObserver; | 58 class TypeDebugInfoObserver; |
58 struct Experiments; | 59 struct Experiments; |
59 struct UserShare; | 60 struct UserShare; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const SyncProtocolError& sync_protocol_error) = 0; | 214 const SyncProtocolError& sync_protocol_error) = 0; |
214 | 215 |
215 virtual void OnMigrationRequested(ModelTypeSet types) = 0; | 216 virtual void OnMigrationRequested(ModelTypeSet types) = 0; |
216 | 217 |
217 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; | 218 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; |
218 | 219 |
219 protected: | 220 protected: |
220 virtual ~Observer(); | 221 virtual ~Observer(); |
221 }; | 222 }; |
222 | 223 |
| 224 // Arguments for initializing SyncManager. |
| 225 struct SYNC_EXPORT InitArgs { |
| 226 InitArgs(); |
| 227 ~InitArgs(); |
| 228 |
| 229 // Path in which to create or open sync's sqlite database (aka the |
| 230 // directory). |
| 231 base::FilePath database_location; |
| 232 |
| 233 // Used to propagate events to chrome://sync-internals. Optional. |
| 234 WeakHandle<JsEventHandler> event_handler; |
| 235 |
| 236 // URL of the sync server. |
| 237 GURL service_url; |
| 238 |
| 239 // Used to communicate with the sync server. |
| 240 scoped_ptr<HttpPostProviderFactory> post_factory; |
| 241 |
| 242 std::vector<scoped_refptr<ModelSafeWorker> > workers; |
| 243 |
| 244 // Must outlive SyncManager. |
| 245 ExtensionsActivity* extensions_activity; |
| 246 |
| 247 // Must outlive SyncManager. |
| 248 ChangeDelegate* change_delegate; |
| 249 |
| 250 // Credentials to be used when talking to the sync server. |
| 251 SyncCredentials credentials; |
| 252 |
| 253 // Unqiuely identifies this client to the invalidation notification server. |
| 254 std::string invalidator_client_id; |
| 255 |
| 256 // Used to boostrap the cryptographer. |
| 257 std::string restored_key_for_bootstrapping; |
| 258 std::string restored_keystore_key_for_bootstrapping; |
| 259 |
| 260 scoped_ptr<InternalComponentsFactory> internal_components_factory; |
| 261 |
| 262 // Must outlive SyncManager. |
| 263 Encryptor* encryptor; |
| 264 |
| 265 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler; |
| 266 ReportUnrecoverableErrorFunction report_unrecoverable_error_function; |
| 267 |
| 268 // Carries shutdown requests across threads and will be used to cut short |
| 269 // any network I/O and tell the syncer to exit early. |
| 270 // |
| 271 // Must outlive SyncManager. |
| 272 CancelationSignal* cancelation_signal; |
| 273 }; |
| 274 |
223 SyncManager(); | 275 SyncManager(); |
224 virtual ~SyncManager(); | 276 virtual ~SyncManager(); |
225 | 277 |
226 // Initialize the sync manager. |database_location| specifies the path of | 278 // Initialize the sync manager using arguments from |args|. |
227 // the directory in which to locate a sqlite repository storing the syncer | |
228 // backend state. Initialization will open the database, or create it if it | |
229 // does not already exist. Returns false on failure. | |
230 // |event_handler| is the JsEventHandler used to propagate events to | |
231 // chrome://sync-internals. |event_handler| may be uninitialized. | |
232 // |service_url| is the URL of the Chrome Sync Server. | |
233 // |post_factory| will be owned internally and used to create | |
234 // instances of an HttpPostProvider. | |
235 // |model_safe_worker| ownership is given to the SyncManager. | |
236 // |user_agent| is a 7-bit ASCII string suitable for use as the User-Agent | |
237 // HTTP header. Used internally when collecting stats to classify clients. | |
238 // |invalidator| is owned and used to listen for invalidations. | |
239 // |invalidator_client_id| is used to unqiuely identify this client to the | |
240 // invalidation notification server. | |
241 // |restored_key_for_bootstrapping| is the key used to boostrap the | |
242 // cryptographer | |
243 // |keystore_encryption_enabled| determines whether we enable the keystore | |
244 // encryption functionality in the cryptographer/nigori. | |
245 // |report_unrecoverable_error_function| may be NULL. | |
246 // |cancelation_signal| carries shutdown requests across threads. This one | |
247 // will be used to cut short any network I/O and tell the syncer to exit | |
248 // early. | |
249 // | 279 // |
250 // TODO(akalin): Replace the |post_factory| parameter with a | 280 // Note, args is passed by non-const pointer because it contains objects like |
251 // URLFetcher parameter. | 281 // scoped_ptr. |
252 virtual void Init( | 282 virtual void Init(InitArgs* args) = 0; |
253 const base::FilePath& database_location, | |
254 const WeakHandle<JsEventHandler>& event_handler, | |
255 const GURL& service_url, | |
256 scoped_ptr<HttpPostProviderFactory> post_factory, | |
257 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | |
258 ExtensionsActivity* extensions_activity, | |
259 ChangeDelegate* change_delegate, | |
260 const SyncCredentials& credentials, | |
261 const std::string& invalidator_client_id, | |
262 const std::string& restored_key_for_bootstrapping, | |
263 const std::string& restored_keystore_key_for_bootstrapping, | |
264 InternalComponentsFactory* internal_components_factory, | |
265 Encryptor* encryptor, | |
266 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | |
267 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | |
268 CancelationSignal* cancelation_signal) = 0; | |
269 | 283 |
270 virtual ModelTypeSet InitialSyncEndedTypes() = 0; | 284 virtual ModelTypeSet InitialSyncEndedTypes() = 0; |
271 | 285 |
272 // Returns those types within |types| that have an empty progress marker | 286 // Returns those types within |types| that have an empty progress marker |
273 // token. | 287 // token. |
274 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 288 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
275 ModelTypeSet types) = 0; | 289 ModelTypeSet types) = 0; |
276 | 290 |
277 // Purge from the directory those types with non-empty progress markers | 291 // Purge from the directory those types with non-empty progress markers |
278 // but without initial synced ended set. | 292 // but without initial synced ended set. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 syncer::TypeDebugInfoObserver* observer) = 0; | 391 syncer::TypeDebugInfoObserver* observer) = 0; |
378 | 392 |
379 // Request that all current counter values be emitted as though they had just | 393 // Request that all current counter values be emitted as though they had just |
380 // been updated. Useful for initializing new observers' state. | 394 // been updated. Useful for initializing new observers' state. |
381 virtual void RequestEmitDebugInfo() = 0; | 395 virtual void RequestEmitDebugInfo() = 0; |
382 }; | 396 }; |
383 | 397 |
384 } // namespace syncer | 398 } // namespace syncer |
385 | 399 |
386 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 400 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
OLD | NEW |