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

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: Fix race condition Created 9 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) 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // The ready_task will be run when all of the requested data types 159 // The ready_task will be run when all of the requested data types
160 // are up-to-date and ready for activation. The task will be 160 // are up-to-date and ready for activation. The task will be
161 // cancelled upon shutdown. 161 // cancelled upon shutdown.
162 virtual void ConfigureDataTypes( 162 virtual void ConfigureDataTypes(
163 const syncable::ModelTypeSet& types_to_add, 163 const syncable::ModelTypeSet& types_to_add,
164 const syncable::ModelTypeSet& types_to_remove, 164 const syncable::ModelTypeSet& types_to_remove,
165 sync_api::ConfigureReason reason, 165 sync_api::ConfigureReason reason,
166 base::Callback<void(bool)> ready_task, 166 base::Callback<void(bool)> ready_task,
167 bool enable_nigori); 167 bool enable_nigori);
168 168
169 // Makes an asynchronous call to syncer to switch to config mode. When done 169 // Tells the syncer to switch to config mode. Calls back on
170 // syncer will call us back on FinishConfigureDataTypes. 170 // FinishConfigureDataTypesOnFrontendLoop when done. Overrideable
171 virtual void StartConfiguration(Callback0::Type* callback); 171 // for testing.
172 virtual void StartConfiguration(bool cleanup_disabled_types);
172 173
173 // Encrypts the specified datatypes and marks them as needing encryption on 174 // Encrypts the specified datatypes and marks them as needing encryption on
174 // other machines. This affects all machines synced to this account and all 175 // other machines. This affects all machines synced to this account and all
175 // data belonging to the specified types. 176 // data belonging to the specified types.
176 // Note: actual work is done on sync_thread_'s message loop. 177 // Note: actual work is done on sync_thread_'s message loop.
177 virtual void EncryptDataTypes( 178 virtual void EncryptDataTypes(
178 const syncable::ModelTypeSet& encrypted_types); 179 const syncable::ModelTypeSet& encrypted_types);
179 180
180 syncable::ModelTypeSet GetEncryptedDataTypes() const; 181 syncable::ModelTypeSet GetEncryptedDataTypes() const;
181 182
183 // Returns the set of types for which there is no sync data.
184 // Overrideable for testing.
185 virtual syncable::ModelTypeSet GetPurgedDataTypes() const;
186
182 // Activates change processing for the given data type. This must 187 // Activates change processing for the given data type. This must
183 // be called synchronously with the data type's model association so 188 // be called synchronously with the data type's model association so
184 // no changes are dropped between model association and change 189 // no changes are dropped between model association and change
185 // processor activation. 190 // processor activation.
186 void ActivateDataType( 191 void ActivateDataType(
187 syncable::ModelType type, ModelSafeGroup group, 192 syncable::ModelType type, ModelSafeGroup group,
188 ChangeProcessor* change_processor); 193 ChangeProcessor* change_processor);
189 194
190 // Deactivates change processing for the given data type. 195 // Deactivates change processing for the given data type.
191 void DeactivateDataType(syncable::ModelType type); 196 void DeactivateDataType(syncable::ModelType type);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Called on the SyncBackendHost sync_thread_ to tell the syncapi to start 326 // Called on the SyncBackendHost sync_thread_ to tell the syncapi to start
322 // syncing (generally after initialization and authentication). 327 // syncing (generally after initialization and authentication).
323 void DoStartSyncing(); 328 void DoStartSyncing();
324 329
325 // Called on the SyncBackendHost sync_thread_ to clear server 330 // Called on the SyncBackendHost sync_thread_ to clear server
326 // data. 331 // data.
327 void DoRequestClearServerData(); 332 void DoRequestClearServerData();
328 333
329 // Called on the SyncBackendHost sync_thread_ to cleanup disabled 334 // Called on the SyncBackendHost sync_thread_ to cleanup disabled
330 // types. 335 // types.
331 void DoRequestCleanupDisabledTypes(); 336 void DoRequestCleanupDisabledTypes(const base::Closure& callback);
332 337
333 // Called on our SyncBackendHost's |sync_thread_| to set the passphrase 338 // Called on our SyncBackendHost's |sync_thread_| to set the passphrase
334 // on behalf of SyncBackendHost::SupplyPassphrase. 339 // on behalf of SyncBackendHost::SupplyPassphrase.
335 void DoSetPassphrase(const std::string& passphrase, bool is_explicit); 340 void DoSetPassphrase(const std::string& passphrase, bool is_explicit);
336 341
337 // Getter/setter for whether we are waiting on SetPassphrase to process a 342 // Getter/setter for whether we are waiting on SetPassphrase to process a
338 // passphrase. Set by SetPassphrase, cleared by OnPassphraseRequired or 343 // passphrase. Set by SetPassphrase, cleared by OnPassphraseRequired or
339 // OnPassphraseAccepted. 344 // OnPassphraseAccepted.
340 bool processing_passphrase() const; 345 bool processing_passphrase() const;
341 void set_processing_passphrase(); 346 void set_processing_passphrase();
342 347
343 // Called on SyncBackendHost's |sync_thread_| to set the datatypes we need 348 // Called on SyncBackendHost's |sync_thread_| to set the datatypes we need
344 // to encrypt as well as encrypt all local data of that type. 349 // to encrypt as well as encrypt all local data of that type.
345 void DoEncryptDataTypes(const syncable::ModelTypeSet& encrypted_types); 350 void DoEncryptDataTypes(const syncable::ModelTypeSet& encrypted_types);
346 351
347 // The shutdown order is a bit complicated: 352 // The shutdown order is a bit complicated:
348 // 1) From |sync_thread_|, invoke the syncapi Shutdown call to do 353 // 1) From |sync_thread_|, invoke the syncapi Shutdown call to do
349 // a final SaveChanges, and close sqlite handles. 354 // a final SaveChanges, and close sqlite handles.
350 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is 355 // 2) Then, from |frontend_loop_|, halt the sync_thread_ (which is
351 // a blocking call). This causes syncapi thread-exit handlers 356 // a blocking call). This causes syncapi thread-exit handlers
352 // to run and make use of cached pointers to various components 357 // to run and make use of cached pointers to various components
353 // owned implicitly by us. 358 // owned implicitly by us.
354 // 3) Destroy this Core. That will delete syncapi components in a 359 // 3) Destroy this Core. That will delete syncapi components in a
355 // safe order because the thread that was using them has exited 360 // safe order because the thread that was using them has exited
356 // (in step 2). 361 // (in step 2).
357 void DoShutdown(bool stopping_sync); 362 void DoShutdown(bool stopping_sync);
358 363
359 // Posts a config request on the sync thread. 364 // Posts a config request on the sync thread.
360 virtual void DoRequestConfig( 365 void DoRequestConfig(
361 const syncable::ModelTypeBitSet& types_to_config, 366 const syncable::ModelTypeBitSet& types_to_config,
362 sync_api::ConfigureReason reason); 367 sync_api::ConfigureReason reason);
363 368
364 // Start the configuration mode. 369 // Starts configuration mode, cleaning up disabled types if
365 virtual void DoStartConfiguration(Callback0::Type* callback); 370 // necessary. Calls back on FinishConfigureDataTypes when done.
371 void DoStartConfiguration(bool cleanup_disabled_types);
366 372
367 // Set the base request context to use when making HTTP calls. 373 // Set the base request context to use when making HTTP calls.
368 // This method will add a reference to the context to persist it 374 // This method will add a reference to the context to persist it
369 // on the IO thread. Must be removed from IO thread. 375 // on the IO thread. Must be removed from IO thread.
370 376
371 sync_api::SyncManager* sync_manager() { return sync_manager_.get(); } 377 sync_api::SyncManager* sync_manager() { return sync_manager_.get(); }
372 378
373 // Delete the sync data folder to cleanup backend data. Happens the first 379 // Delete the sync data folder to cleanup backend data. Happens the first
374 // time sync is enabled for a user (to prevent accidentally reusing old 380 // time sync is enabled for a user (to prevent accidentally reusing old
375 // sync databases), as well as shutdown when you're no longer syncing. 381 // sync databases), as well as shutdown when you're no longer syncing.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // For convenience, checks if initialization state is INITIALIZED. 522 // For convenience, checks if initialization state is INITIALIZED.
517 bool initialized() const { return initialization_state_ == INITIALIZED; } 523 bool initialized() const { return initialization_state_ == INITIALIZED; }
518 524
519 // A thread where all the sync operations happen. 525 // A thread where all the sync operations happen.
520 base::Thread sync_thread_; 526 base::Thread sync_thread_;
521 527
522 // A reference to the MessageLoop used to construct |this|, so we know how 528 // A reference to the MessageLoop used to construct |this|, so we know how
523 // to safely talk back to the SyncFrontend. 529 // to safely talk back to the SyncFrontend.
524 MessageLoop* const frontend_loop_; 530 MessageLoop* const frontend_loop_;
525 531
526 Profile* profile_; 532 Profile* const profile_;
533
534 // Name used for debugging (set from profile_->GetDebugName()).
535 const std::string name_;
527 536
528 sync_notifier::SyncNotifierFactory sync_notifier_factory_; 537 sync_notifier::SyncNotifierFactory sync_notifier_factory_;
529 538
530 scoped_ptr<SyncBackendRegistrar> registrar_; 539 scoped_ptr<SyncBackendRegistrar> registrar_;
531 540
532 // The frontend which we serve (and are owned by). 541 // The frontend which we serve (and are owned by).
533 SyncFrontend* frontend_; 542 SyncFrontend* frontend_;
534 543
535 // Path of the folder that stores the sync data files. 544 // Path of the folder that stores the sync data files.
536 FilePath sync_data_folder_path_; 545 FilePath sync_data_folder_path_;
537 546
538 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; 547 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_;
539 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; 548 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_;
540 549
541 // UI-thread cache of the last AuthErrorState received from syncapi. 550 // UI-thread cache of the last AuthErrorState received from syncapi.
542 GoogleServiceAuthError last_auth_error_; 551 GoogleServiceAuthError last_auth_error_;
543 552
544 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 553 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
545 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; 554 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_;
546 555
547 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 556 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
548 }; 557 };
549 558
550 } // namespace browser_sync 559 } // namespace browser_sync
551 560
552 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 561 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698