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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.h

Issue 10805002: [Sync] Enable adding notifier observers from ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
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/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "chrome/browser/sync/glue/backend_data_type_configurer.h" 17 #include "chrome/browser/sync/glue/backend_data_type_configurer.h"
18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h" 18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h"
19 #include "chrome/common/net/gaia/google_service_auth_error.h" 19 #include "chrome/common/net/gaia/google_service_auth_error.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "sync/internal_api/public/base/model_type.h" 21 #include "sync/internal_api/public/base/model_type.h"
22 #include "sync/internal_api/public/configure_reason.h" 22 #include "sync/internal_api/public/configure_reason.h"
23 #include "sync/internal_api/public/engine/model_safe_worker.h" 23 #include "sync/internal_api/public/engine/model_safe_worker.h"
24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
25 #include "sync/internal_api/public/sync_manager.h" 25 #include "sync/internal_api/public/sync_manager.h"
26 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 26 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
27 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 27 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
28 #include "sync/internal_api/public/util/weak_handle.h" 28 #include "sync/internal_api/public/util/weak_handle.h"
29 #include "sync/notifier/sync_notifier_factory.h" 29 #include "sync/notifier/sync_notifier_factory.h"
30 #include "sync/notifier/sync_notifier_observer.h"
30 #include "sync/protocol/encryption.pb.h" 31 #include "sync/protocol/encryption.pb.h"
31 #include "sync/protocol/sync_protocol_error.h" 32 #include "sync/protocol/sync_protocol_error.h"
32 33
33 class MessageLoop; 34 class MessageLoop;
34 class Profile; 35 class Profile;
35 36
36 namespace syncer { 37 namespace syncer {
37 class SyncManagerFactory; 38 class SyncManagerFactory;
38 } 39 }
39 40
40 namespace browser_sync { 41 namespace browser_sync {
41 42
42 class ChangeProcessor; 43 class ChangeProcessor;
43 class ChromeSyncNotificationBridge; 44 class ChromeSyncNotificationBridge;
44 struct Experiments; 45 struct Experiments;
45 class InvalidatorStorage; 46 class InvalidatorStorage;
46 class SyncBackendRegistrar; 47 class SyncBackendRegistrar;
47 class SyncPrefs; 48 class SyncPrefs;
48 49
49 // SyncFrontend is the interface used by SyncBackendHost to communicate with 50 // SyncFrontend is the interface used by SyncBackendHost to communicate with
50 // the entity that created it and, presumably, is interested in sync-related 51 // the entity that created it and, presumably, is interested in sync-related
51 // activity. 52 // activity.
52 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread 53 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread
53 // used to create that SyncBackendHost. 54 // used to create that SyncBackendHost.
54 class SyncFrontend { 55 class SyncFrontend : public syncer::SyncNotifierObserver {
55 public: 56 public:
56 SyncFrontend() {} 57 SyncFrontend() {}
57 58
58 // The backend has completed initialization and it is now ready to 59 // The backend has completed initialization and it is now ready to
59 // accept and process changes. If success is false, initialization 60 // accept and process changes. If success is false, initialization
60 // wasn't able to be completed and should be retried. 61 // wasn't able to be completed and should be retried.
61 // 62 //
62 // |js_backend| is what about:sync interacts with; it's different 63 // |js_backend| is what about:sync interacts with; it's different
63 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It 64 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It
64 // is initialized only if |success| is true. 65 // is initialized only if |success| is true.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 SyncFrontend* frontend, 169 SyncFrontend* frontend,
169 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 170 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
170 const GURL& service_url, 171 const GURL& service_url,
171 const syncer::SyncCredentials& credentials, 172 const syncer::SyncCredentials& credentials,
172 bool delete_sync_data_folder, 173 bool delete_sync_data_folder,
173 syncer::SyncManagerFactory* sync_manager_factory, 174 syncer::SyncManagerFactory* sync_manager_factory,
174 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, 175 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
175 syncer::ReportUnrecoverableErrorFunction 176 syncer::ReportUnrecoverableErrorFunction
176 report_unrecoverable_error_function); 177 report_unrecoverable_error_function);
177 178
178 // Called from |frontend_loop| to update SyncCredentials. 179 // Called on |frontend_loop| to update SyncCredentials.
179 void UpdateCredentials(const syncer::SyncCredentials& credentials); 180 void UpdateCredentials(const syncer::SyncCredentials& credentials);
180 181
182 // Registers the underlying frontend for the given IDs to the
183 // underlying notifier.
184 void UpdateRegisteredInvalidationIds(const syncer::ObjectIdSet& ids);
185
181 // This starts the SyncerThread running a Syncer object to communicate with 186 // This starts the SyncerThread running a Syncer object to communicate with
182 // sync servers. Until this is called, no changes will leave or enter this 187 // sync servers. Until this is called, no changes will leave or enter this
183 // browser from the cloud / sync servers. 188 // browser from the cloud / sync servers.
184 // Called on |frontend_loop_|. 189 // Called on |frontend_loop_|.
185 virtual void StartSyncingWithServer(); 190 virtual void StartSyncingWithServer();
186 191
187 // Called on |frontend_loop_| to asynchronously set a new passphrase for 192 // Called on |frontend_loop_| to asynchronously set a new passphrase for
188 // encryption. Note that it is an error to call SetEncryptionPassphrase under 193 // encryption. Note that it is an error to call SetEncryptionPassphrase under
189 // the following circumstances: 194 // the following circumstances:
190 // - An explicit passphrase has already been set 195 // - An explicit passphrase has already been set
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Called when the syncer has finished performing a configuration. 347 // Called when the syncer has finished performing a configuration.
343 void FinishConfigureDataTypesOnFrontendLoop( 348 void FinishConfigureDataTypesOnFrontendLoop(
344 const syncer::ModelTypeSet failed_configuration_types, 349 const syncer::ModelTypeSet failed_configuration_types,
345 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); 350 const base::Callback<void(syncer::ModelTypeSet)>& ready_task);
346 351
347 // Called when the SyncManager has been constructed and initialized. 352 // Called when the SyncManager has been constructed and initialized.
348 virtual void HandleSyncManagerInitializationOnFrontendLoop( 353 virtual void HandleSyncManagerInitializationOnFrontendLoop(
349 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, 354 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
350 syncer::ModelTypeSet restored_types); 355 syncer::ModelTypeSet restored_types);
351 356
357 SyncFrontend* frontend() { return frontend_; }
358
352 private: 359 private:
353 // The real guts of SyncBackendHost, to keep the public client API clean. 360 // The real guts of SyncBackendHost, to keep the public client API clean.
354 class Core; 361 class Core;
355 362
356 // An enum representing the steps to initializing the SyncBackendHost. 363 // An enum representing the steps to initializing the SyncBackendHost.
357 enum InitializationState { 364 enum InitializationState {
358 NOT_ATTEMPTED, 365 NOT_ATTEMPTED,
359 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the 366 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the
360 // sync thread to inform us that the sync manager 367 // sync thread to inform us that the sync manager
361 // has been created. 368 // has been created.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // frontend UI components. 460 // frontend UI components.
454 void HandleConnectionStatusChangeOnFrontendLoop( 461 void HandleConnectionStatusChangeOnFrontendLoop(
455 syncer::ConnectionStatus status); 462 syncer::ConnectionStatus status);
456 463
457 // Called when configuration of the Nigori node has completed as 464 // Called when configuration of the Nigori node has completed as
458 // part of the initialization process. 465 // part of the initialization process.
459 void HandleNigoriConfigurationCompletedOnFrontendLoop( 466 void HandleNigoriConfigurationCompletedOnFrontendLoop(
460 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 467 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
461 syncer::ModelTypeSet failed_configuration_types); 468 syncer::ModelTypeSet failed_configuration_types);
462 469
470 // syncer::SyncNotifierObserver-like functions.
471 void HandleNotificationsEnabledOnFrontendLoop();
472 void HandleNotificationsDisabledOnFrontendLoop(
473 syncer::NotificationsDisabledReason reason);
474 void HandleIncomingNotificationOnFrontendLoop(
475 const syncer::ObjectIdPayloadMap& id_payloads,
476 syncer::IncomingNotificationSource source);
477
463 // Must be called on |frontend_loop_|. |done_callback| is called on 478 // Must be called on |frontend_loop_|. |done_callback| is called on
464 // |frontend_loop_|. 479 // |frontend_loop_|.
465 void RefreshNigori(const base::Closure& done_callback); 480 void RefreshNigori(const base::Closure& done_callback);
466 481
467 // Handles stopping the core's SyncManager, accounting for whether 482 // Handles stopping the core's SyncManager, accounting for whether
468 // initialization is done yet. 483 // initialization is done yet.
469 void StopSyncManagerForShutdown(const base::Closure& closure); 484 void StopSyncManagerForShutdown(const base::Closure& closure);
470 485
471 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; 486 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_;
472 487
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 529
515 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 530 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
516 syncer::sessions::SyncSessionSnapshot last_snapshot_; 531 syncer::sessions::SyncSessionSnapshot last_snapshot_;
517 532
518 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 533 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
519 }; 534 };
520 535
521 } // namespace browser_sync 536 } // namespace browser_sync
522 537
523 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 538 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698