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

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

Issue 7655055: [Sync] Make BackendMigrator not wait for full sync cycles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address more comments Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // dispatch of potentially blocking calls to appropriate threads and ensures 110 // dispatch of potentially blocking calls to appropriate threads and ensures
111 // that the SyncFrontend is only accessed on the UI loop. 111 // that the SyncFrontend is only accessed on the UI loop.
112 class SyncBackendHost { 112 class SyncBackendHost {
113 public: 113 public:
114 typedef sync_api::SyncManager::Status::Summary StatusSummary; 114 typedef sync_api::SyncManager::Status::Summary StatusSummary;
115 typedef sync_api::SyncManager::Status Status; 115 typedef sync_api::SyncManager::Status Status;
116 116
117 // Create a SyncBackendHost with a reference to the |frontend| that it serves 117 // Create a SyncBackendHost with a reference to the |frontend| that it serves
118 // and communicates to via the SyncFrontend interface (on the same thread 118 // and communicates to via the SyncFrontend interface (on the same thread
119 // it used to call the constructor). 119 // it used to call the constructor).
120 explicit SyncBackendHost(Profile* profile); 120 SyncBackendHost(const std::string& name, Profile* profile);
121 // For testing. 121 // For testing.
122 // TODO(skrul): Extract an interface so this is not needed. 122 // TODO(skrul): Extract an interface so this is not needed.
123 SyncBackendHost(); 123 SyncBackendHost();
124 virtual ~SyncBackendHost(); 124 virtual ~SyncBackendHost();
125 125
126 // Called on |frontend_loop_| to kick off asynchronous initialization. 126 // Called on |frontend_loop_| to kick off asynchronous initialization.
127 // As a fallback when no cached auth information is available, try to 127 // As a fallback when no cached auth information is available, try to
128 // bootstrap authentication using |lsid|, if it isn't empty. 128 // bootstrap authentication using |lsid|, if it isn't empty.
129 // Optionally delete the Sync Data folder (if it's corrupt). 129 // Optionally delete the Sync Data folder (if it's corrupt).
130 void Initialize(SyncFrontend* frontend, 130 void Initialize(SyncFrontend* frontend,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 DOWNLOADING_NIGORI, // The SyncManager is initialized, but we're fetching 241 DOWNLOADING_NIGORI, // The SyncManager is initialized, but we're fetching
242 // encryption information before alerting the 242 // encryption information before alerting the
243 // frontend. 243 // frontend.
244 INITIALIZED, // Initialization is complete. 244 INITIALIZED, // Initialization is complete.
245 }; 245 };
246 246
247 // The real guts of SyncBackendHost, to keep the public client API clean. 247 // The real guts of SyncBackendHost, to keep the public client API clean.
248 class Core : public base::RefCountedThreadSafe<SyncBackendHost::Core>, 248 class Core : public base::RefCountedThreadSafe<SyncBackendHost::Core>,
249 public sync_api::SyncManager::Observer { 249 public sync_api::SyncManager::Observer {
250 public: 250 public:
251 Core(Profile* profile, SyncBackendHost* backend); 251 Core(const std::string& name, SyncBackendHost* backend);
252 252
253 // SyncManager::Observer implementation. The Core just acts like an air 253 // SyncManager::Observer implementation. The Core just acts like an air
254 // traffic controller here, forwarding incoming messages to appropriate 254 // traffic controller here, forwarding incoming messages to appropriate
255 // landing threads. 255 // landing threads.
256 virtual void OnChangesApplied( 256 virtual void OnChangesApplied(
257 syncable::ModelType model_type, 257 syncable::ModelType model_type,
258 const sync_api::BaseTransaction* trans, 258 const sync_api::BaseTransaction* trans,
259 const sync_api::SyncManager::ChangeRecord* changes, 259 const sync_api::SyncManager::ChangeRecord* changes,
260 int change_count) OVERRIDE; 260 int change_count) OVERRIDE;
261 virtual void OnChangesComplete( 261 virtual void OnChangesComplete(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 sessions::SyncSessionSnapshot* snapshot); 430 sessions::SyncSessionSnapshot* snapshot);
431 431
432 void HandleStopSyncingPermanentlyOnFrontendLoop(); 432 void HandleStopSyncingPermanentlyOnFrontendLoop();
433 433
434 // Called to handle success/failure of clearing server data 434 // Called to handle success/failure of clearing server data
435 void HandleClearServerDataSucceededOnFrontendLoop(); 435 void HandleClearServerDataSucceededOnFrontendLoop();
436 void HandleClearServerDataFailedOnFrontendLoop(); 436 void HandleClearServerDataFailedOnFrontendLoop();
437 437
438 void FinishConfigureDataTypesOnFrontendLoop(); 438 void FinishConfigureDataTypesOnFrontendLoop();
439 439
440 Profile* profile_; 440 // Name used for debugging.
441 const std::string name_;
441 442
442 // Our parent SyncBackendHost 443 // Our parent SyncBackendHost
443 SyncBackendHost* host_; 444 SyncBackendHost* host_;
444 445
445 // Our parent's registrar (not owned). Non-NULL only between 446 // Our parent's registrar (not owned). Non-NULL only between
446 // calls to DoInitialize() and DoShutdown(). 447 // calls to DoInitialize() and DoShutdown().
447 SyncBackendRegistrar* registrar_; 448 SyncBackendRegistrar* registrar_;
448 449
449 // The timer used to periodically call SaveChanges. 450 // The timer used to periodically call SaveChanges.
450 base::RepeatingTimer<Core> save_changes_timer_; 451 base::RepeatingTimer<Core> save_changes_timer_;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // For convenience, checks if initialization state is INITIALIZED. 517 // For convenience, checks if initialization state is INITIALIZED.
517 bool initialized() const { return initialization_state_ == INITIALIZED; } 518 bool initialized() const { return initialization_state_ == INITIALIZED; }
518 519
519 // A thread where all the sync operations happen. 520 // A thread where all the sync operations happen.
520 base::Thread sync_thread_; 521 base::Thread sync_thread_;
521 522
522 // A reference to the MessageLoop used to construct |this|, so we know how 523 // A reference to the MessageLoop used to construct |this|, so we know how
523 // to safely talk back to the SyncFrontend. 524 // to safely talk back to the SyncFrontend.
524 MessageLoop* const frontend_loop_; 525 MessageLoop* const frontend_loop_;
525 526
526 Profile* profile_; 527 Profile* const profile_;
528
529 // Name used for debugging (set from profile_->GetDebugName()).
530 const std::string name_;
527 531
528 sync_notifier::SyncNotifierFactory sync_notifier_factory_; 532 sync_notifier::SyncNotifierFactory sync_notifier_factory_;
529 533
530 scoped_ptr<SyncBackendRegistrar> registrar_; 534 scoped_ptr<SyncBackendRegistrar> registrar_;
531 535
532 // The frontend which we serve (and are owned by). 536 // The frontend which we serve (and are owned by).
533 SyncFrontend* frontend_; 537 SyncFrontend* frontend_;
534 538
535 // Path of the folder that stores the sync data files. 539 // Path of the folder that stores the sync data files.
536 FilePath sync_data_folder_path_; 540 FilePath sync_data_folder_path_;
537 541
538 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; 542 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_;
539 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; 543 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_;
540 544
541 // UI-thread cache of the last AuthErrorState received from syncapi. 545 // UI-thread cache of the last AuthErrorState received from syncapi.
542 GoogleServiceAuthError last_auth_error_; 546 GoogleServiceAuthError last_auth_error_;
543 547
544 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 548 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
545 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; 549 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_;
546 550
547 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 551 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
548 }; 552 };
549 553
550 } // namespace browser_sync 554 } // namespace browser_sync
551 555
552 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 556 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/data_type_manager_impl_unittest.cc ('k') | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698