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

Side by Side Diff: sync/internal_api/public/sync_manager.h

Issue 451743002: Pass args to SyncManager::Init via a struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add SYNC_EXPORT tag to InitArgs. Created 6 years, 4 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 | Annotate | Revision Log
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 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"
28 #include "sync/internal_api/public/shutdown_reason.h" 29 #include "sync/internal_api/public/shutdown_reason.h"
29 #include "sync/internal_api/public/sync_context_proxy.h" 30 #include "sync/internal_api/public/sync_context_proxy.h"
30 #include "sync/internal_api/public/sync_encryption_handler.h" 31 #include "sync/internal_api/public/sync_encryption_handler.h"
31 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 32 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
32 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 33 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
33 #include "sync/internal_api/public/util/weak_handle.h" 34 #include "sync/internal_api/public/util/weak_handle.h"
34 #include "sync/protocol/sync_protocol_error.h" 35 #include "sync/protocol/sync_protocol_error.h"
35 36
36 class GURL; 37 class GURL;
37 38
38 namespace sync_pb { 39 namespace sync_pb {
39 class EncryptedData; 40 class EncryptedData;
40 } // namespace sync_pb 41 } // namespace sync_pb
41 42
42 namespace syncer { 43 namespace syncer {
43 44
44 class BaseTransaction; 45 class BaseTransaction;
45 class CancelationSignal; 46 class CancelationSignal;
46 class DataTypeDebugInfoListener; 47 class DataTypeDebugInfoListener;
47 class Encryptor; 48 class Encryptor;
48 class ExtensionsActivity; 49 class ExtensionsActivity;
49 class HttpPostProviderFactory;
50 class InternalComponentsFactory; 50 class InternalComponentsFactory;
51 class JsBackend; 51 class JsBackend;
52 class JsEventHandler; 52 class JsEventHandler;
53 class ProtocolEvent; 53 class ProtocolEvent;
54 class SyncContextProxy; 54 class SyncContextProxy;
55 class SyncEncryptionHandler; 55 class SyncEncryptionHandler;
56 class SyncScheduler; 56 class SyncScheduler;
57 class TypeDebugInfoObserver; 57 class TypeDebugInfoObserver;
58 struct Experiments; 58 struct Experiments;
59 struct UserShare; 59 struct UserShare;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 const SyncProtocolError& sync_protocol_error) = 0; 213 const SyncProtocolError& sync_protocol_error) = 0;
214 214
215 virtual void OnMigrationRequested(ModelTypeSet types) = 0; 215 virtual void OnMigrationRequested(ModelTypeSet types) = 0;
216 216
217 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; 217 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0;
218 218
219 protected: 219 protected:
220 virtual ~Observer(); 220 virtual ~Observer();
221 }; 221 };
222 222
223 // Arguments for initializing SyncManager.
224 struct SYNC_EXPORT InitArgs {
225 InitArgs();
226 ~InitArgs();
227
228 // Path in which to create or open sync's sqlite database (aka the
229 // directory).
230 base::FilePath database_location;
231
232 // Used to propagate events to chrome://sync-internals. Optional.
233 WeakHandle<JsEventHandler> event_handler;
234
235 // URL of the sync server.
236 GURL service_url;
237
238 // Used to communicate with the sync server.
239 scoped_ptr<HttpPostProviderFactory> post_factory;
240 // TODO(akalin): Replace post_factory parameter with a URLFetcher.
tim (not reviewing) 2014/08/07 20:10:14 I don't think this is really a goal anymore.
maniscalco 2014/08/07 20:55:08 Good point. Removed.
241
242 std::vector<scoped_refptr<ModelSafeWorker> > workers;
243 ExtensionsActivity* extensions_activity;
tim (not reviewing) 2014/08/07 20:10:14 It'd be good to comment on lifetimes for the vario
maniscalco 2014/08/07 20:55:08 Good idea. Done. I've also converted internal_co
244 ChangeDelegate* change_delegate;
245
246 // Credentials to be used when talking to the sync server.
247 SyncCredentials credentials;
248
249 // Unqiuely identifies this client to the invalidation notification server.
250 std::string invalidator_client_id;
251
252 // Used to boostrap the cryptographer.
253 std::string restored_key_for_bootstrapping;
254 std::string restored_keystore_key_for_bootstrapping;
255
256 InternalComponentsFactory* internal_components_factory;
257 Encryptor* encryptor;
258 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler;
259 ReportUnrecoverableErrorFunction report_unrecoverable_error_function;
260
261 // Carries shutdown requests across threads and will be used to cut short
262 // any network I/O and tell the syncer to exit early.
263 CancelationSignal* cancelation_signal;
264 };
265
223 SyncManager(); 266 SyncManager();
224 virtual ~SyncManager(); 267 virtual ~SyncManager();
225 268
226 // Initialize the sync manager. |database_location| specifies the path of 269 // 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 // 270 //
250 // TODO(akalin): Replace the |post_factory| parameter with a 271 // Note, args is passed by non-const pointer because it contains objects like
251 // URLFetcher parameter. 272 // scoped_ptr.
252 virtual void Init( 273 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 274
270 virtual ModelTypeSet InitialSyncEndedTypes() = 0; 275 virtual ModelTypeSet InitialSyncEndedTypes() = 0;
271 276
272 // Returns those types within |types| that have an empty progress marker 277 // Returns those types within |types| that have an empty progress marker
273 // token. 278 // token.
274 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 279 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
275 ModelTypeSet types) = 0; 280 ModelTypeSet types) = 0;
276 281
277 // Purge from the directory those types with non-empty progress markers 282 // Purge from the directory those types with non-empty progress markers
278 // but without initial synced ended set. 283 // but without initial synced ended set.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 syncer::TypeDebugInfoObserver* observer) = 0; 382 syncer::TypeDebugInfoObserver* observer) = 0;
378 383
379 // Request that all current counter values be emitted as though they had just 384 // Request that all current counter values be emitted as though they had just
380 // been updated. Useful for initializing new observers' state. 385 // been updated. Useful for initializing new observers' state.
381 virtual void RequestEmitDebugInfo() = 0; 386 virtual void RequestEmitDebugInfo() = 0;
382 }; 387 };
383 388
384 } // namespace syncer 389 } // namespace syncer
385 390
386 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 391 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_core.cc ('k') | sync/internal_api/public/sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698