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

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: Fix typos 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 UpdateRegisteredIds(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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Called when the syncer has finished performing a configuration. 345 // Called when the syncer has finished performing a configuration.
341 void FinishConfigureDataTypesOnFrontendLoop( 346 void FinishConfigureDataTypesOnFrontendLoop(
342 const syncer::ModelTypeSet failed_configuration_types, 347 const syncer::ModelTypeSet failed_configuration_types,
343 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); 348 const base::Callback<void(syncer::ModelTypeSet)>& ready_task);
344 349
345 // Called when the SyncManager has been constructed and initialized. 350 // Called when the SyncManager has been constructed and initialized.
346 virtual void HandleSyncManagerInitializationOnFrontendLoop( 351 virtual void HandleSyncManagerInitializationOnFrontendLoop(
347 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, 352 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
348 syncer::ModelTypeSet restored_types); 353 syncer::ModelTypeSet restored_types);
349 354
355 SyncFrontend* frontend() { return frontend_; }
356
350 private: 357 private:
351 // The real guts of SyncBackendHost, to keep the public client API clean. 358 // The real guts of SyncBackendHost, to keep the public client API clean.
352 class Core; 359 class Core;
353 360
354 // An enum representing the steps to initializing the SyncBackendHost. 361 // An enum representing the steps to initializing the SyncBackendHost.
355 enum InitializationState { 362 enum InitializationState {
356 NOT_ATTEMPTED, 363 NOT_ATTEMPTED,
357 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the 364 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the
358 // sync thread to inform us that the sync manager 365 // sync thread to inform us that the sync manager
359 // has been created. 366 // has been created.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // frontend UI components. 450 // frontend UI components.
444 void HandleConnectionStatusChangeOnFrontendLoop( 451 void HandleConnectionStatusChangeOnFrontendLoop(
445 syncer::ConnectionStatus status); 452 syncer::ConnectionStatus status);
446 453
447 // Called when configuration of the Nigori node has completed as 454 // Called when configuration of the Nigori node has completed as
448 // part of the initialization process. 455 // part of the initialization process.
449 void HandleNigoriConfigurationCompletedOnFrontendLoop( 456 void HandleNigoriConfigurationCompletedOnFrontendLoop(
450 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 457 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
451 syncer::ModelTypeSet failed_configuration_types); 458 syncer::ModelTypeSet failed_configuration_types);
452 459
460 // syncer::SyncNotifierObserver-like functions.
461 void HandleNotificationsEnabledOnFrontendLoop();
462 void HandleNotificationsDisabledOnFrontendLoop(
463 syncer::NotificationsDisabledReason reason);
464 void HandleIncomingNotificationOnFrontendLoop(
465 const syncer::ObjectIdPayloadMap& id_payloads,
466 syncer::IncomingNotificationSource source);
467
453 // Must be called on |frontend_loop_|. |done_callback| is called on 468 // Must be called on |frontend_loop_|. |done_callback| is called on
454 // |frontend_loop_|. 469 // |frontend_loop_|.
455 void RefreshNigori(const base::Closure& done_callback); 470 void RefreshNigori(const base::Closure& done_callback);
456 471
457 // Handles stopping the core's SyncManager, accounting for whether 472 // Handles stopping the core's SyncManager, accounting for whether
458 // initialization is done yet. 473 // initialization is done yet.
459 void StopSyncManagerForShutdown(const base::Closure& closure); 474 void StopSyncManagerForShutdown(const base::Closure& closure);
460 475
461 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; 476 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_;
462 477
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 519
505 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 520 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
506 syncer::sessions::SyncSessionSnapshot last_snapshot_; 521 syncer::sessions::SyncSessionSnapshot last_snapshot_;
507 522
508 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 523 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
509 }; 524 };
510 525
511 } // namespace browser_sync 526 } // namespace browser_sync
512 527
513 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 528 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698