OLD | NEW |
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/engine/sync_status.h" | 21 #include "sync/internal_api/public/engine/sync_status.h" |
22 #include "sync/internal_api/public/syncable/model_type.h" | 22 #include "sync/internal_api/public/syncable/model_type.h" |
23 #include "sync/protocol/sync_protocol_error.h" | 23 #include "sync/protocol/sync_protocol_error.h" |
24 #include "sync/util/report_unrecoverable_error_function.h" | 24 #include "sync/util/report_unrecoverable_error_function.h" |
25 #include "sync/util/unrecoverable_error_handler.h" | 25 #include "sync/util/unrecoverable_error_handler.h" |
26 #include "sync/util/weak_handle.h" | 26 #include "sync/util/weak_handle.h" |
27 | 27 |
28 namespace browser_sync { | 28 namespace browser_sync { |
| 29 struct ConfigurationParams; |
29 class Encryptor; | 30 class Encryptor; |
30 struct Experiments; | 31 struct Experiments; |
31 class ExtensionsActivityMonitor; | 32 class ExtensionsActivityMonitor; |
32 class JsBackend; | 33 class JsBackend; |
33 class JsEventHandler; | 34 class JsEventHandler; |
34 | 35 |
35 namespace sessions { | 36 namespace sessions { |
36 class SyncSessionSnapshot; | 37 class SyncSessionSnapshot; |
37 } // namespace sessions | 38 } // namespace sessions |
38 } // namespace browser_sync | 39 } // namespace browser_sync |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // re-encryption once the pending keys are decrypted. | 425 // re-encryption once the pending keys are decrypted. |
425 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); | 426 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); |
426 | 427 |
427 // Provides a passphrase for decrypting the user's existing sync data. | 428 // Provides a passphrase for decrypting the user's existing sync data. |
428 // Notifies observers of the result of the operation via OnPassphraseAccepted | 429 // Notifies observers of the result of the operation via OnPassphraseAccepted |
429 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as | 430 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as |
430 // appropriate if there is a previously cached encryption passphrase. It is an | 431 // appropriate if there is a previously cached encryption passphrase. It is an |
431 // error to call this when we don't have pending keys. | 432 // error to call this when we don't have pending keys. |
432 void SetDecryptionPassphrase(const std::string& passphrase); | 433 void SetDecryptionPassphrase(const std::string& passphrase); |
433 | 434 |
434 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic | |
435 // will occur, but calls to RequestConfig will be supported. If |callback| | |
436 // is provided, it will be invoked (from the internal SyncScheduler) when | |
437 // the thread has changed to configuration mode. | |
438 void StartConfigurationMode(const base::Closure& callback); | |
439 | |
440 // Switches the mode of operation to CONFIGURATION_MODE and | |
441 // schedules a config task to fetch updates for |types|. | |
442 void RequestConfig(const browser_sync::ModelSafeRoutingInfo& routing_info, | |
443 const syncable::ModelTypeSet& types, | |
444 sync_api::ConfigureReason reason); | |
445 | |
446 void RequestCleanupDisabledTypes( | |
447 const browser_sync::ModelSafeRoutingInfo& routing_info); | |
448 | |
449 // Request a clearing of all data on the server | 435 // Request a clearing of all data on the server |
450 void RequestClearServerData(); | 436 void RequestClearServerData(); |
451 | 437 |
| 438 // Switches the mode of operation to CONFIGURATION_MODE and performs |
| 439 // any configuration tasks needed as determined by the params. Once complete, |
| 440 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is |
| 441 // called. |
| 442 // |ready_task| is invoked when the configuration completes. |
| 443 // |retry_task| is invoked if the configuration job could not immediately |
| 444 // execute. |ready_task| will still be called when it eventually |
| 445 // does finish. |
| 446 void ConfigureSyncer( |
| 447 ConfigureReason reason, |
| 448 const syncable::ModelTypeSet& types_to_config, |
| 449 const browser_sync::ModelSafeRoutingInfo& new_routing_info, |
| 450 const base::Closure& ready_task, |
| 451 const base::Closure& retry_task); |
| 452 |
452 // Adds a listener to be notified of sync events. | 453 // Adds a listener to be notified of sync events. |
453 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 454 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
454 // having received OnInitializationCompleted. | 455 // having received OnInitializationCompleted. |
455 void AddObserver(Observer* observer); | 456 void AddObserver(Observer* observer); |
456 | 457 |
457 // Remove the given observer. Make sure to call this if the | 458 // Remove the given observer. Make sure to call this if the |
458 // Observer is being destroyed so the SyncManager doesn't | 459 // Observer is being destroyed so the SyncManager doesn't |
459 // potentially dereference garbage. | 460 // potentially dereference garbage. |
460 void RemoveObserver(Observer* observer); | 461 void RemoveObserver(Observer* observer); |
461 | 462 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 | 536 |
536 void TriggerOnIncomingNotificationForTest( | 537 void TriggerOnIncomingNotificationForTest( |
537 syncable::ModelTypeSet model_types); | 538 syncable::ModelTypeSet model_types); |
538 | 539 |
539 static const int kDefaultNudgeDelayMilliseconds; | 540 static const int kDefaultNudgeDelayMilliseconds; |
540 static const int kPreferencesNudgeDelayMilliseconds; | 541 static const int kPreferencesNudgeDelayMilliseconds; |
541 static const int kPiggybackNudgeDelay; | 542 static const int kPiggybackNudgeDelay; |
542 | 543 |
543 static const FilePath::CharType kSyncDatabaseFilename[]; | 544 static const FilePath::CharType kSyncDatabaseFilename[]; |
544 | 545 |
| 546 protected: |
| 547 // Returns true if the configuration completed on the first attempt, false |
| 548 // if a retry will be performed at a later time. |
| 549 // Virtual for testing. |
| 550 virtual bool DoConfigureSyncer( |
| 551 const browser_sync::ConfigurationParams& params); |
| 552 |
545 private: | 553 private: |
546 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); | 554 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
547 | 555 |
548 // For unit tests. | 556 // For unit tests. |
549 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); | 557 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); |
550 | 558 |
551 base::ThreadChecker thread_checker_; | 559 base::ThreadChecker thread_checker_; |
552 | 560 |
553 // An opaque pointer to the nested private class. | 561 // An opaque pointer to the nested private class. |
554 SyncInternal* data_; | 562 SyncInternal* data_; |
555 | 563 |
556 DISALLOW_COPY_AND_ASSIGN(SyncManager); | 564 DISALLOW_COPY_AND_ASSIGN(SyncManager); |
557 }; | 565 }; |
558 | 566 |
559 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); | 567 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); |
560 | 568 |
561 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 569 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
562 syncable::ModelTypeSet types, | 570 syncable::ModelTypeSet types, |
563 sync_api::UserShare* share); | 571 sync_api::UserShare* share); |
564 | 572 |
565 const char* ConnectionStatusToString(ConnectionStatus status); | 573 const char* ConnectionStatusToString(ConnectionStatus status); |
566 | 574 |
567 // Returns the string representation of a PassphraseRequiredReason value. | 575 // Returns the string representation of a PassphraseRequiredReason value. |
568 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 576 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
569 | 577 |
570 } // namespace sync_api | 578 } // namespace sync_api |
571 | 579 |
572 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 580 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
OLD | NEW |