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

Side by Side Diff: sync/internal_api/sync_manager_impl.h

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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 SYNC_INTERNAL_API_SYNC_MANAGER_H_ 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_
6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // local sync repository (i.e. the same sqlite database), they should share a 44 // local sync repository (i.e. the same sqlite database), they should share a
45 // single SyncManager instance. The caller should typically create one 45 // single SyncManager instance. The caller should typically create one
46 // SyncManager for the lifetime of a user session. 46 // SyncManager for the lifetime of a user session.
47 // 47 //
48 // Unless stated otherwise, all methods of SyncManager should be called on the 48 // Unless stated otherwise, all methods of SyncManager should be called on the
49 // same thread. 49 // same thread.
50 class SYNC_EXPORT_PRIVATE SyncManagerImpl : 50 class SYNC_EXPORT_PRIVATE SyncManagerImpl :
51 public SyncManager, 51 public SyncManager,
52 public net::NetworkChangeNotifier::IPAddressObserver, 52 public net::NetworkChangeNotifier::IPAddressObserver,
53 public net::NetworkChangeNotifier::ConnectionTypeObserver, 53 public net::NetworkChangeNotifier::ConnectionTypeObserver,
54 public InvalidationHandler,
55 public JsBackend, 54 public JsBackend,
56 public SyncEngineEventListener, 55 public SyncEngineEventListener,
57 public ServerConnectionEventListener, 56 public ServerConnectionEventListener,
58 public syncable::DirectoryChangeDelegate, 57 public syncable::DirectoryChangeDelegate,
59 public SyncEncryptionHandler::Observer { 58 public SyncEncryptionHandler::Observer {
60 public: 59 public:
61 // Create an uninitialized SyncManager. Callers must Init() before using. 60 // Create an uninitialized SyncManager. Callers must Init() before using.
62 explicit SyncManagerImpl(const std::string& name); 61 explicit SyncManagerImpl(const std::string& name);
63 virtual ~SyncManagerImpl(); 62 virtual ~SyncManagerImpl();
64 63
65 // SyncManager implementation. 64 // SyncManager implementation.
66 virtual void Init( 65 virtual void Init(
67 const base::FilePath& database_location, 66 const base::FilePath& database_location,
68 const WeakHandle<JsEventHandler>& event_handler, 67 const WeakHandle<JsEventHandler>& event_handler,
69 const std::string& sync_server_and_path, 68 const std::string& sync_server_and_path,
70 int sync_server_port, 69 int sync_server_port,
71 bool use_ssl, 70 bool use_ssl,
72 scoped_ptr<HttpPostProviderFactory> post_factory, 71 scoped_ptr<HttpPostProviderFactory> post_factory,
73 const std::vector<ModelSafeWorker*>& workers, 72 const std::vector<ModelSafeWorker*>& workers,
74 ExtensionsActivityMonitor* extensions_activity_monitor, 73 ExtensionsActivityMonitor* extensions_activity_monitor,
75 SyncManager::ChangeDelegate* change_delegate, 74 SyncManager::ChangeDelegate* change_delegate,
76 const SyncCredentials& credentials, 75 const SyncCredentials& credentials,
77 scoped_ptr<Invalidator> invalidator,
78 const std::string& invalidator_client_id, 76 const std::string& invalidator_client_id,
79 const std::string& restored_key_for_bootstrapping, 77 const std::string& restored_key_for_bootstrapping,
80 const std::string& restored_keystore_key_for_bootstrapping, 78 const std::string& restored_keystore_key_for_bootstrapping,
81 scoped_ptr<InternalComponentsFactory> internal_components_factory, 79 scoped_ptr<InternalComponentsFactory> internal_components_factory,
82 Encryptor* encryptor, 80 Encryptor* encryptor,
83 UnrecoverableErrorHandler* unrecoverable_error_handler, 81 UnrecoverableErrorHandler* unrecoverable_error_handler,
84 ReportUnrecoverableErrorFunction 82 ReportUnrecoverableErrorFunction
85 report_unrecoverable_error_function, 83 report_unrecoverable_error_function,
86 bool use_oauth2_token) OVERRIDE; 84 bool use_oauth2_token) OVERRIDE;
87 virtual void ThrowUnrecoverableError() OVERRIDE; 85 virtual void ThrowUnrecoverableError() OVERRIDE;
88 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; 86 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
89 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 87 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
90 ModelTypeSet types) OVERRIDE; 88 ModelTypeSet types) OVERRIDE;
91 virtual bool PurgePartiallySyncedTypes() OVERRIDE; 89 virtual bool PurgePartiallySyncedTypes() OVERRIDE;
92 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; 90 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
93 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) OVERRIDE;
94 virtual void RegisterInvalidationHandler(
95 InvalidationHandler* handler) OVERRIDE;
96 virtual void UpdateRegisteredInvalidationIds(
97 InvalidationHandler* handler,
98 const ObjectIdSet& ids) OVERRIDE;
99 virtual void UnregisterInvalidationHandler(
100 InvalidationHandler* handler) OVERRIDE;
101 virtual void AcknowledgeInvalidation(
102 const invalidation::ObjectId& id,
103 const syncer::AckHandle& ack_handle) OVERRIDE;
104 virtual void StartSyncingNormally( 91 virtual void StartSyncingNormally(
105 const ModelSafeRoutingInfo& routing_info) OVERRIDE; 92 const ModelSafeRoutingInfo& routing_info) OVERRIDE;
106 virtual void ConfigureSyncer( 93 virtual void ConfigureSyncer(
107 ConfigureReason reason, 94 ConfigureReason reason,
108 ModelTypeSet to_download, 95 ModelTypeSet to_download,
109 ModelTypeSet to_purge, 96 ModelTypeSet to_purge,
110 ModelTypeSet to_journal, 97 ModelTypeSet to_journal,
111 ModelTypeSet to_unapply, 98 ModelTypeSet to_unapply,
112 const ModelSafeRoutingInfo& new_routing_info, 99 const ModelSafeRoutingInfo& new_routing_info,
113 const base::Closure& ready_task, 100 const base::Closure& ready_task,
114 const base::Closure& retry_task) OVERRIDE; 101 const base::Closure& retry_task) OVERRIDE;
102 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
103 virtual void OnIncomingInvalidation(
104 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
115 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; 105 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE;
116 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; 106 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE;
117 virtual SyncStatus GetDetailedStatus() const OVERRIDE; 107 virtual SyncStatus GetDetailedStatus() const OVERRIDE;
118 virtual void SaveChanges() OVERRIDE; 108 virtual void SaveChanges() OVERRIDE;
119 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; 109 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE;
120 virtual void ShutdownOnSyncThread() OVERRIDE; 110 virtual void ShutdownOnSyncThread() OVERRIDE;
121 virtual UserShare* GetUserShare() OVERRIDE; 111 virtual UserShare* GetUserShare() OVERRIDE;
122 virtual const std::string cache_guid() OVERRIDE; 112 virtual const std::string cache_guid() OVERRIDE;
123 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; 113 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
124 virtual bool HasUnsyncedItems() OVERRIDE; 114 virtual bool HasUnsyncedItems() OVERRIDE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 syncable::BaseTransaction* trans) OVERRIDE; 160 syncable::BaseTransaction* trans) OVERRIDE;
171 virtual void HandleCalculateChangesChangeEventFromSyncApi( 161 virtual void HandleCalculateChangesChangeEventFromSyncApi(
172 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, 162 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
173 syncable::BaseTransaction* trans, 163 syncable::BaseTransaction* trans,
174 std::vector<int64>* entries_changed) OVERRIDE; 164 std::vector<int64>* entries_changed) OVERRIDE;
175 virtual void HandleCalculateChangesChangeEventFromSyncer( 165 virtual void HandleCalculateChangesChangeEventFromSyncer(
176 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, 166 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
177 syncable::BaseTransaction* trans, 167 syncable::BaseTransaction* trans,
178 std::vector<int64>* entries_changed) OVERRIDE; 168 std::vector<int64>* entries_changed) OVERRIDE;
179 169
180 // InvalidationHandler implementation.
181 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
182 virtual void OnIncomingInvalidation(
183 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
184
185 // Handle explicit requests to fetch updates for the given types. 170 // Handle explicit requests to fetch updates for the given types.
186 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; 171 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE;
187 172
188 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier. 173 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier.
189 // Called when IP address of primary interface changes. 174 // Called when IP address of primary interface changes.
190 virtual void OnIPAddressChanged() OVERRIDE; 175 virtual void OnIPAddressChanged() OVERRIDE;
191 // Called when the connection type of the system has changed. 176 // Called when the connection type of the system has changed.
192 virtual void OnConnectionTypeChanged( 177 virtual void OnConnectionTypeChanged(
193 net::NetworkChangeNotifier::ConnectionType) OVERRIDE; 178 net::NetworkChangeNotifier::ConnectionType) OVERRIDE;
194 179
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; 314 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_;
330 315
331 // A container of various bits of information used by the SyncScheduler to 316 // A container of various bits of information used by the SyncScheduler to
332 // create SyncSessions. Must outlive the SyncScheduler. 317 // create SyncSessions. Must outlive the SyncScheduler.
333 scoped_ptr<sessions::SyncSessionContext> session_context_; 318 scoped_ptr<sessions::SyncSessionContext> session_context_;
334 319
335 // The scheduler that runs the Syncer. Needs to be explicitly 320 // The scheduler that runs the Syncer. Needs to be explicitly
336 // Start()ed. 321 // Start()ed.
337 scoped_ptr<SyncScheduler> scheduler_; 322 scoped_ptr<SyncScheduler> scheduler_;
338 323
339 // The Invalidator which notifies us when updates need to be downloaded.
340 scoped_ptr<Invalidator> invalidator_;
341
342 // A multi-purpose status watch object that aggregates stats from various 324 // A multi-purpose status watch object that aggregates stats from various
343 // sync components. 325 // sync components.
344 AllStatus allstatus_; 326 AllStatus allstatus_;
345 327
346 // Each element of this map is a store of change records produced by 328 // Each element of this map is a store of change records produced by
347 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes 329 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes
348 // are grouped by model type, and are stored here in tree order to be 330 // are grouped by model type, and are stored here in tree order to be
349 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step 331 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step
350 // by HandleTransactionEndingChangeEvent. The list is cleared after observer 332 // by HandleTransactionEndingChangeEvent. The list is cleared after observer
351 // finishes processing. 333 // finishes processing.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // changing passphrases, and in general handles sync-specific interactions 367 // changing passphrases, and in general handles sync-specific interactions
386 // with the cryptographer. 368 // with the cryptographer.
387 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; 369 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_;
388 370
389 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); 371 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl);
390 }; 372 };
391 373
392 } // namespace syncer 374 } // namespace syncer
393 375
394 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ 376 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/test/fake_sync_manager.h ('k') | sync/internal_api/sync_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698