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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl.h

Issue 2559123002: [Sync] SyncEngine refactor part 2: SyncServiceBase. (Closed)
Patch Set: Address comments. Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_IMPL_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 13 matching lines...) Expand all
24 #include "components/sync/base/weak_handle.h" 24 #include "components/sync/base/weak_handle.h"
25 #include "components/sync/engine/configure_reason.h" 25 #include "components/sync/engine/configure_reason.h"
26 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 26 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
27 #include "components/sync/engine/cycle/type_debug_info_observer.h" 27 #include "components/sync/engine/cycle/type_debug_info_observer.h"
28 #include "components/sync/engine/model_type_configurer.h" 28 #include "components/sync/engine/model_type_configurer.h"
29 #include "components/sync/engine/sync_engine.h" 29 #include "components/sync/engine/sync_engine.h"
30 #include "components/sync/engine/sync_manager.h" 30 #include "components/sync/engine/sync_manager.h"
31 #include "components/sync/protocol/encryption.pb.h" 31 #include "components/sync/protocol/encryption.pb.h"
32 #include "components/sync/protocol/sync_protocol_error.h" 32 #include "components/sync/protocol/sync_protocol_error.h"
33 33
34 class GURL;
35
36 namespace invalidation { 34 namespace invalidation {
37 class InvalidationService; 35 class InvalidationService;
38 } // namespace invalidation 36 } // namespace invalidation
39 37
40 namespace syncer { 38 namespace syncer {
41 39
42 class ChangeProcessor; 40 class ChangeProcessor;
43 class SyncBackendHostCore; 41 class SyncBackendHostCore;
44 class SyncBackendRegistrar; 42 class SyncBackendRegistrar;
45 class SyncClient; 43 class SyncClient;
46 class SyncManagerFactory;
47 class SyncPrefs; 44 class SyncPrefs;
48 class UnrecoverableErrorHandler;
49 struct DoInitializeOptions;
50 45
51 // The only real implementation of the SyncEngine. See that interface's 46 // The only real implementation of the SyncEngine. See that interface's
52 // definition for documentation of public methods. 47 // definition for documentation of public methods.
53 class SyncBackendHostImpl : public SyncEngine, public InvalidationHandler { 48 class SyncBackendHostImpl : public SyncEngine, public InvalidationHandler {
54 public: 49 public:
55 typedef SyncStatus Status; 50 typedef SyncStatus Status;
56 51
57 SyncBackendHostImpl( 52 SyncBackendHostImpl(
58 const std::string& name, 53 const std::string& name,
59 SyncClient* sync_client, 54 SyncClient* sync_client,
60 invalidation::InvalidationService* invalidator, 55 invalidation::InvalidationService* invalidator,
61 const base::WeakPtr<SyncPrefs>& sync_prefs, 56 const base::WeakPtr<SyncPrefs>& sync_prefs,
62 const base::FilePath& sync_folder); 57 const base::FilePath& sync_folder);
63 ~SyncBackendHostImpl() override; 58 ~SyncBackendHostImpl() override;
64 59
65 // SyncEngine implementation. 60 // SyncEngine implementation.
66 void Initialize( 61 void Initialize(InitParams params) override;
67 SyncEngineHost* host,
68 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
69 const WeakHandle<JsEventHandler>& event_handler,
70 const GURL& service_url,
71 const std::string& sync_user_agent,
72 const SyncCredentials& credentials,
73 bool delete_sync_data_folder,
74 bool enable_local_sync_backend,
75 const base::FilePath& local_sync_backend_folder,
76 std::unique_ptr<SyncManagerFactory> sync_manager_factory,
77 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
78 const base::Closure& report_unrecoverable_error_function,
79 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
80 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state)
81 override;
82 void TriggerRefresh(const ModelTypeSet& types) override; 62 void TriggerRefresh(const ModelTypeSet& types) override;
83 void UpdateCredentials(const SyncCredentials& credentials) override; 63 void UpdateCredentials(const SyncCredentials& credentials) override;
84 void StartSyncingWithServer() override; 64 void StartSyncingWithServer() override;
85 void SetEncryptionPassphrase(const std::string& passphrase, 65 void SetEncryptionPassphrase(const std::string& passphrase,
86 bool is_explicit) override; 66 bool is_explicit) override;
87 bool SetDecryptionPassphrase(const std::string& passphrase) override 67 bool SetDecryptionPassphrase(const std::string& passphrase) override
88 WARN_UNUSED_RESULT; 68 WARN_UNUSED_RESULT;
89 void StopSyncingForShutdown() override; 69 void StopSyncingForShutdown() override;
90 void Shutdown(ShutdownReason reason) override; 70 void Shutdown(ShutdownReason reason) override;
91 void UnregisterInvalidationIds() override; 71 void UnregisterInvalidationIds() override;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // InvalidationHandler implementation. 104 // InvalidationHandler implementation.
125 void OnInvalidatorStateChange(InvalidatorState state) override; 105 void OnInvalidatorStateChange(InvalidatorState state) override;
126 void OnIncomingInvalidation( 106 void OnIncomingInvalidation(
127 const ObjectIdInvalidationMap& invalidation_map) override; 107 const ObjectIdInvalidationMap& invalidation_map) override;
128 std::string GetOwnerName() const override; 108 std::string GetOwnerName() const override;
129 109
130 protected: 110 protected:
131 // The types and functions below are protected so that test 111 // The types and functions below are protected so that test
132 // subclasses can use them. 112 // subclasses can use them.
133 113
134 // Allows tests to perform alternate core initialization work.
135 virtual void InitCore(std::unique_ptr<DoInitializeOptions> options);
136
137 // Request the syncer to reconfigure with the specfied params. 114 // Request the syncer to reconfigure with the specfied params.
138 // Virtual for testing. 115 // Virtual for testing.
139 virtual void RequestConfigureSyncer( 116 virtual void RequestConfigureSyncer(
140 ConfigureReason reason, 117 ConfigureReason reason,
141 ModelTypeSet to_download, 118 ModelTypeSet to_download,
142 const ModelSafeRoutingInfo& routing_info, 119 const ModelSafeRoutingInfo& routing_info,
143 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, 120 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
144 const base::Closure& retry_callback); 121 const base::Closure& retry_callback);
145 122
146 // Called when the syncer has finished performing a configuration. 123 // Called when the syncer has finished performing a configuration.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 scoped_refptr<SyncBackendHostCore> core_; 270 scoped_refptr<SyncBackendHostCore> core_;
294 271
295 // A handle referencing the main interface for non-blocking sync types. This 272 // A handle referencing the main interface for non-blocking sync types. This
296 // object is owned because in production code it is a proxy object. 273 // object is owned because in production code it is a proxy object.
297 std::unique_ptr<ModelTypeConnector> model_type_connector_; 274 std::unique_ptr<ModelTypeConnector> model_type_connector_;
298 275
299 bool initialized_ = false; 276 bool initialized_ = false;
300 277
301 const base::WeakPtr<SyncPrefs> sync_prefs_; 278 const base::WeakPtr<SyncPrefs> sync_prefs_;
302 279
303 std::unique_ptr<SyncBackendRegistrar> registrar_;
304
305 // The host which we serve (and are owned by). Set in Initialize() and nulled 280 // The host which we serve (and are owned by). Set in Initialize() and nulled
306 // out in StopSyncingForShutdown(). 281 // out in StopSyncingForShutdown().
307 SyncEngineHost* host_ = nullptr; 282 SyncEngineHost* host_ = nullptr;
308 283
284 // A pointer to the registrar; owned by |core_|.
285 SyncBackendRegistrar* registrar_ = nullptr;
286
309 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired 287 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired
310 // is called. This way, before the UI calls SetDecryptionPassphrase on the 288 // is called. This way, before the UI calls SetDecryptionPassphrase on the
311 // syncer, it can avoid the overhead of an asynchronous decryption call and 289 // syncer, it can avoid the overhead of an asynchronous decryption call and
312 // give the user immediate feedback about the passphrase entered by first 290 // give the user immediate feedback about the passphrase entered by first
313 // trying to decrypt the cached pending keys on the UI thread. Note that 291 // trying to decrypt the cached pending keys on the UI thread. Note that
314 // SetDecryptionPassphrase can still fail after the cached pending keys are 292 // SetDecryptionPassphrase can still fail after the cached pending keys are
315 // successfully decrypted if the pending keys have changed since the time they 293 // successfully decrypted if the pending keys have changed since the time they
316 // were cached. 294 // were cached.
317 sync_pb::EncryptedData cached_pending_keys_; 295 sync_pb::EncryptedData cached_pending_keys_;
318 296
(...skipping 17 matching lines...) Expand all
336 base::ThreadChecker thread_checker_; 314 base::ThreadChecker thread_checker_;
337 315
338 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; 316 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_;
339 317
340 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); 318 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl);
341 }; 319 };
342 320
343 } // namespace syncer 321 } // namespace syncer
344 322
345 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 323 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.cc ('k') | components/sync/driver/glue/sync_backend_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698