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

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

Issue 10483015: [Sync] Refactor sync configuration logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SetBool -> CallbackCounter Created 8 years, 6 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 SYNC_INTERNAL_API_SYNC_MANAGER_H_ 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_
6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/task_runner.h" 15 #include "base/task_runner.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "sync/internal_api/change_record.h" 18 #include "sync/internal_api/change_record.h"
19 #include "sync/internal_api/configure_reason.h" 19 #include "sync/internal_api/configure_reason.h"
20 #include "sync/internal_api/public/engine/model_safe_worker.h" 20 #include "sync/internal_api/public/engine/model_safe_worker.h"
21 #include "sync/internal_api/public/syncable/model_type.h" 21 #include "sync/internal_api/public/syncable/model_type.h"
22 #include "sync/protocol/sync_protocol_error.h" 22 #include "sync/protocol/sync_protocol_error.h"
23 #include "sync/util/report_unrecoverable_error_function.h" 23 #include "sync/util/report_unrecoverable_error_function.h"
24 #include "sync/util/unrecoverable_error_handler.h" 24 #include "sync/util/unrecoverable_error_handler.h"
25 #include "sync/util/weak_handle.h" 25 #include "sync/util/weak_handle.h"
26 26
27 namespace browser_sync { 27 namespace browser_sync {
28 struct ConfigureParams;
28 class Encryptor; 29 class Encryptor;
29 struct Experiments; 30 struct Experiments;
30 class ExtensionsActivityMonitor; 31 class ExtensionsActivityMonitor;
31 class JsBackend; 32 class JsBackend;
32 class JsEventHandler; 33 class JsEventHandler;
33 34
34 namespace sessions { 35 namespace sessions {
35 class SyncSessionSnapshot; 36 class SyncSessionSnapshot;
36 } // namespace sessions 37 } // namespace sessions
37 } // namespace browser_sync 38 } // namespace browser_sync
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // re-encryption once the pending keys are decrypted. 493 // re-encryption once the pending keys are decrypted.
493 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); 494 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit);
494 495
495 // Provides a passphrase for decrypting the user's existing sync data. 496 // Provides a passphrase for decrypting the user's existing sync data.
496 // Notifies observers of the result of the operation via OnPassphraseAccepted 497 // Notifies observers of the result of the operation via OnPassphraseAccepted
497 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as 498 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as
498 // appropriate if there is a previously cached encryption passphrase. It is an 499 // appropriate if there is a previously cached encryption passphrase. It is an
499 // error to call this when we don't have pending keys. 500 // error to call this when we don't have pending keys.
500 void SetDecryptionPassphrase(const std::string& passphrase); 501 void SetDecryptionPassphrase(const std::string& passphrase);
501 502
502 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic
503 // will occur, but calls to RequestConfig will be supported. If |callback|
504 // is provided, it will be invoked (from the internal SyncScheduler) when
505 // the thread has changed to configuration mode.
506 void StartConfigurationMode(const base::Closure& callback);
507
508 // Switches the mode of operation to CONFIGURATION_MODE and
509 // schedules a config task to fetch updates for |types|.
510 void RequestConfig(const browser_sync::ModelSafeRoutingInfo& routing_info,
511 const syncable::ModelTypeSet& types,
512 sync_api::ConfigureReason reason);
513
514 void RequestCleanupDisabledTypes(
515 const browser_sync::ModelSafeRoutingInfo& routing_info);
516
517 // Request a clearing of all data on the server 503 // Request a clearing of all data on the server
518 void RequestClearServerData(); 504 void RequestClearServerData();
519 505
506 // Switches the mode of operation to CONFIGURATION_MODE and performs
507 // any configuration tasks needed as determined by the params. Once complete,
508 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is
509 // called.
510 // |ready_task| is invoked when the configuration completes.
511 // |retry_task| is invoked if the configuration job could not immediately
512 // execute. |ready_task| will still be called when it eventually
513 // does finish.
514 void ConfigureSyncer(
515 ConfigureReason reason,
516 const syncable::ModelTypeSet& types_to_config,
517 const browser_sync::ModelSafeRoutingInfo& new_routing_info,
518 const base::Closure& ready_task,
519 const base::Closure& retry_task);
520
520 // Adds a listener to be notified of sync events. 521 // Adds a listener to be notified of sync events.
521 // NOTE: It is OK (in fact, it's probably a good idea) to call this before 522 // NOTE: It is OK (in fact, it's probably a good idea) to call this before
522 // having received OnInitializationCompleted. 523 // having received OnInitializationCompleted.
523 void AddObserver(Observer* observer); 524 void AddObserver(Observer* observer);
524 525
525 // Remove the given observer. Make sure to call this if the 526 // Remove the given observer. Make sure to call this if the
526 // Observer is being destroyed so the SyncManager doesn't 527 // Observer is being destroyed so the SyncManager doesn't
527 // potentially dereference garbage. 528 // potentially dereference garbage.
528 void RemoveObserver(Observer* observer); 529 void RemoveObserver(Observer* observer);
529 530
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 604
604 void TriggerOnIncomingNotificationForTest( 605 void TriggerOnIncomingNotificationForTest(
605 syncable::ModelTypeSet model_types); 606 syncable::ModelTypeSet model_types);
606 607
607 static const int kDefaultNudgeDelayMilliseconds; 608 static const int kDefaultNudgeDelayMilliseconds;
608 static const int kPreferencesNudgeDelayMilliseconds; 609 static const int kPreferencesNudgeDelayMilliseconds;
609 static const int kPiggybackNudgeDelay; 610 static const int kPiggybackNudgeDelay;
610 611
611 static const FilePath::CharType kSyncDatabaseFilename[]; 612 static const FilePath::CharType kSyncDatabaseFilename[];
612 613
614 protected:
615 // Returns true if the configuration completed on the first attempt, false
616 // if a retry will be performed at a later time.
617 // Virtual for testing.
618 virtual bool DoConfigureSyncer(const browser_sync::ConfigureParams& params);
619
613 private: 620 private:
614 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); 621 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest);
615 622
616 // For unit tests. 623 // For unit tests.
617 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); 624 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type);
618 625
619 base::ThreadChecker thread_checker_; 626 base::ThreadChecker thread_checker_;
620 627
621 // An opaque pointer to the nested private class. 628 // An opaque pointer to the nested private class.
622 SyncInternal* data_; 629 SyncInternal* data_;
623 630
624 DISALLOW_COPY_AND_ASSIGN(SyncManager); 631 DISALLOW_COPY_AND_ASSIGN(SyncManager);
625 }; 632 };
626 633
627 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); 634 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share);
628 635
629 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( 636 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
630 syncable::ModelTypeSet types, 637 syncable::ModelTypeSet types,
631 sync_api::UserShare* share); 638 sync_api::UserShare* share);
632 639
633 const char* ConnectionStatusToString(ConnectionStatus status); 640 const char* ConnectionStatusToString(ConnectionStatus status);
634 641
635 // Returns the string representation of a PassphraseRequiredReason value. 642 // Returns the string representation of a PassphraseRequiredReason value.
636 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); 643 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason);
637 644
638 } // namespace sync_api 645 } // namespace sync_api
639 646
640 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ 647 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698