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

Side by Side Diff: sync/internal_api/public/sync_manager.h

Issue 10791002: Finish commit 146665. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« no previous file with comments | « sync/engine/sync_scheduler_whitebox_unittest.cc ('k') | sync/internal_api/sync_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 24 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
25 #include "sync/internal_api/public/util/weak_handle.h" 25 #include "sync/internal_api/public/util/weak_handle.h"
26 #include "sync/protocol/sync_protocol_error.h" 26 #include "sync/protocol/sync_protocol_error.h"
27 27
28 namespace syncer { 28 namespace syncer {
29 class Encryptor; 29 class Encryptor;
30 struct Experiments; 30 struct Experiments;
31 class ExtensionsActivityMonitor; 31 class ExtensionsActivityMonitor;
32 class JsBackend; 32 class JsBackend;
33 class JsEventHandler; 33 class JsEventHandler;
34 class SyncScheduler;
34 35
35 namespace sessions { 36 namespace sessions {
36 class SyncSessionSnapshot; 37 class SyncSessionSnapshot;
37 } // namespace sessions 38 } // namespace sessions
38 } // namespace syncer 39 } // namespace syncer
39 40
40 namespace syncer { 41 namespace syncer {
41 class SyncNotifier; 42 class SyncNotifier;
42 } // namespace syncer 43 } // namespace syncer
43 44
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 syncer::ReportUnrecoverableErrorFunction 395 syncer::ReportUnrecoverableErrorFunction
395 report_unrecoverable_error_function); 396 report_unrecoverable_error_function);
396 397
397 // Throw an unrecoverable error from a transaction (mostly used for 398 // Throw an unrecoverable error from a transaction (mostly used for
398 // testing). 399 // testing).
399 void ThrowUnrecoverableError(); 400 void ThrowUnrecoverableError();
400 401
401 // Returns the set of types for which we have stored some sync data. 402 // Returns the set of types for which we have stored some sync data.
402 syncer::ModelTypeSet InitialSyncEndedTypes(); 403 syncer::ModelTypeSet InitialSyncEndedTypes();
403 404
405 // Returns those types within |types| that have an empty progress marker
406 // token.
407 syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
408 syncer::ModelTypeSet types);
409
410 // Purge from the directory those types with non-empty progress markers
411 // but without initial synced ended set.
412 // Returns false if an error occurred, true otherwise.
413 bool PurgePartiallySyncedTypes();
414
404 // Update tokens that we're using in Sync. Email must stay the same. 415 // Update tokens that we're using in Sync. Email must stay the same.
405 void UpdateCredentials(const SyncCredentials& credentials); 416 void UpdateCredentials(const SyncCredentials& credentials);
406 417
407 // Called when the user disables or enables a sync type. 418 // Called when the user disables or enables a sync type.
408 void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types); 419 void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types);
409 420
410 // Put the syncer in normal mode ready to perform nudges and polls. 421 // Put the syncer in normal mode ready to perform nudges and polls.
411 void StartSyncingNormally( 422 void StartSyncingNormally(
412 const syncer::ModelSafeRoutingInfo& routing_info); 423 const syncer::ModelSafeRoutingInfo& routing_info);
413 424
414 // Attempts to re-encrypt encrypted data types using the passphrase provided. 425 // Attempts to re-encrypt encrypted data types using the passphrase provided.
415 // Notifies observers of the result of the operation via OnPassphraseAccepted 426 // Notifies observers of the result of the operation via OnPassphraseAccepted
416 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as 427 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as
417 // appropriate. If an explicit password has been set previously, we drop 428 // appropriate. If an explicit password has been set previously, we drop
418 // subsequent requests to set a passphrase. If the cryptographer has pending 429 // subsequent requests to set a passphrase. If the cryptographer has pending
419 // keys, and a new implicit passphrase is provided, we try decrypting the 430 // keys, and a new implicit passphrase is provided, we try decrypting the
420 // pending keys with it, and if that fails, we cache the passphrase for 431 // pending keys with it, and if that fails, we cache the passphrase for
421 // re-encryption once the pending keys are decrypted. 432 // re-encryption once the pending keys are decrypted.
422 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); 433 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit);
423 434
424 // Provides a passphrase for decrypting the user's existing sync data. 435 // Provides a passphrase for decrypting the user's existing sync data.
425 // Notifies observers of the result of the operation via OnPassphraseAccepted 436 // Notifies observers of the result of the operation via OnPassphraseAccepted
426 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as 437 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as
427 // appropriate if there is a previously cached encryption passphrase. It is an 438 // appropriate if there is a previously cached encryption passphrase. It is an
428 // error to call this when we don't have pending keys. 439 // error to call this when we don't have pending keys.
429 void SetDecryptionPassphrase(const std::string& passphrase); 440 void SetDecryptionPassphrase(const std::string& passphrase);
430 441
431 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic 442 // Switches the mode of operation to CONFIGURATION_MODE and performs
432 // will occur, but calls to RequestConfig will be supported. If |callback| 443 // any configuration tasks needed as determined by the params. Once complete,
433 // is provided, it will be invoked (from the internal SyncScheduler) when 444 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is
434 // the thread has changed to configuration mode. 445 // called.
435 void StartConfigurationMode(const base::Closure& callback); 446 // |ready_task| is invoked when the configuration completes.
436 447 // |retry_task| is invoked if the configuration job could not immediately
437 // Switches the mode of operation to CONFIGURATION_MODE and 448 // execute. |ready_task| will still be called when it eventually
438 // schedules a config task to fetch updates for |types|. 449 // does finish.
439 void RequestConfig(const syncer::ModelSafeRoutingInfo& routing_info, 450 void ConfigureSyncer(
440 const syncer::ModelTypeSet& types, 451 ConfigureReason reason,
441 syncer::ConfigureReason reason); 452 const syncer::ModelTypeSet& types_to_config,
442 453 const syncer::ModelSafeRoutingInfo& new_routing_info,
443 void RequestCleanupDisabledTypes( 454 const base::Closure& ready_task,
444 const syncer::ModelSafeRoutingInfo& routing_info); 455 const base::Closure& retry_task);
445 456
446 // Adds a listener to be notified of sync events. 457 // Adds a listener to be notified of sync events.
447 // NOTE: It is OK (in fact, it's probably a good idea) to call this before 458 // NOTE: It is OK (in fact, it's probably a good idea) to call this before
448 // having received OnInitializationCompleted. 459 // having received OnInitializationCompleted.
449 void AddObserver(Observer* observer); 460 void AddObserver(Observer* observer);
450 461
451 // Remove the given observer. Make sure to call this if the 462 // Remove the given observer. Make sure to call this if the
452 // Observer is being destroyed so the SyncManager doesn't 463 // Observer is being destroyed so the SyncManager doesn't
453 // potentially dereference garbage. 464 // potentially dereference garbage.
454 void RemoveObserver(Observer* observer); 465 void RemoveObserver(Observer* observer);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 void TriggerOnIncomingNotificationForTest( 542 void TriggerOnIncomingNotificationForTest(
532 syncer::ModelTypeSet model_types); 543 syncer::ModelTypeSet model_types);
533 544
534 static const int kDefaultNudgeDelayMilliseconds; 545 static const int kDefaultNudgeDelayMilliseconds;
535 static const int kPreferencesNudgeDelayMilliseconds; 546 static const int kPreferencesNudgeDelayMilliseconds;
536 static const int kPiggybackNudgeDelay; 547 static const int kPiggybackNudgeDelay;
537 548
538 static const FilePath::CharType kSyncDatabaseFilename[]; 549 static const FilePath::CharType kSyncDatabaseFilename[];
539 550
540 private: 551 private:
552 friend class SyncManagerTest;
541 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); 553 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest);
542 554
543 // For unit tests. 555 // For unit tests.
544 base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type); 556 base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type);
545 557
558 // Set the internal scheduler for testing purposes.
559 // TODO(sync): Use dependency injection instead. crbug.com/133061
560 void SetSyncSchedulerForTest(
561 scoped_ptr<syncer::SyncScheduler> scheduler);
562
546 base::ThreadChecker thread_checker_; 563 base::ThreadChecker thread_checker_;
547 564
548 // An opaque pointer to the nested private class. 565 // An opaque pointer to the nested private class.
549 SyncInternal* data_; 566 SyncInternal* data_;
550 567
551 DISALLOW_COPY_AND_ASSIGN(SyncManager); 568 DISALLOW_COPY_AND_ASSIGN(SyncManager);
552 }; 569 };
553 570
554 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, UserShare* share); 571 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, UserShare* share);
555 572
556 syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
557 syncer::ModelTypeSet types,
558 syncer::UserShare* share);
559
560 const char* ConnectionStatusToString(ConnectionStatus status); 573 const char* ConnectionStatusToString(ConnectionStatus status);
561 574
562 // Returns the string representation of a PassphraseRequiredReason value. 575 // Returns the string representation of a PassphraseRequiredReason value.
563 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); 576 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason);
564 577
565 } // namespace syncer 578 } // namespace syncer
566 579
567 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ 580 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_whitebox_unittest.cc ('k') | sync/internal_api/sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698