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; |
| 35 class SyncScheduler; |
34 | 36 |
35 namespace sessions { | 37 namespace sessions { |
36 class SyncSessionSnapshot; | 38 class SyncSessionSnapshot; |
37 } // namespace sessions | 39 } // namespace sessions |
38 } // namespace browser_sync | 40 } // namespace browser_sync |
39 | 41 |
40 namespace sync_notifier { | 42 namespace sync_notifier { |
41 class SyncNotifier; | 43 class SyncNotifier; |
42 } // namespace sync_notifier | 44 } // namespace sync_notifier |
43 | 45 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // re-encryption once the pending keys are decrypted. | 426 // re-encryption once the pending keys are decrypted. |
425 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); | 427 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); |
426 | 428 |
427 // Provides a passphrase for decrypting the user's existing sync data. | 429 // Provides a passphrase for decrypting the user's existing sync data. |
428 // Notifies observers of the result of the operation via OnPassphraseAccepted | 430 // Notifies observers of the result of the operation via OnPassphraseAccepted |
429 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as | 431 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as |
430 // appropriate if there is a previously cached encryption passphrase. It is an | 432 // appropriate if there is a previously cached encryption passphrase. It is an |
431 // error to call this when we don't have pending keys. | 433 // error to call this when we don't have pending keys. |
432 void SetDecryptionPassphrase(const std::string& passphrase); | 434 void SetDecryptionPassphrase(const std::string& passphrase); |
433 | 435 |
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 | 436 // Request a clearing of all data on the server |
450 void RequestClearServerData(); | 437 void RequestClearServerData(); |
451 | 438 |
| 439 // Switches the mode of operation to CONFIGURATION_MODE and performs |
| 440 // any configuration tasks needed as determined by the params. Once complete, |
| 441 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is |
| 442 // called. |
| 443 // |ready_task| is invoked when the configuration completes. |
| 444 // |retry_task| is invoked if the configuration job could not immediately |
| 445 // execute. |ready_task| will still be called when it eventually |
| 446 // does finish. |
| 447 void ConfigureSyncer( |
| 448 ConfigureReason reason, |
| 449 const syncable::ModelTypeSet& types_to_config, |
| 450 const browser_sync::ModelSafeRoutingInfo& new_routing_info, |
| 451 const base::Closure& ready_task, |
| 452 const base::Closure& retry_task); |
| 453 |
452 // Adds a listener to be notified of sync events. | 454 // 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 | 455 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
454 // having received OnInitializationCompleted. | 456 // having received OnInitializationCompleted. |
455 void AddObserver(Observer* observer); | 457 void AddObserver(Observer* observer); |
456 | 458 |
457 // Remove the given observer. Make sure to call this if the | 459 // Remove the given observer. Make sure to call this if the |
458 // Observer is being destroyed so the SyncManager doesn't | 460 // Observer is being destroyed so the SyncManager doesn't |
459 // potentially dereference garbage. | 461 // potentially dereference garbage. |
460 void RemoveObserver(Observer* observer); | 462 void RemoveObserver(Observer* observer); |
461 | 463 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 void TriggerOnIncomingNotificationForTest( | 538 void TriggerOnIncomingNotificationForTest( |
537 syncable::ModelTypeSet model_types); | 539 syncable::ModelTypeSet model_types); |
538 | 540 |
539 static const int kDefaultNudgeDelayMilliseconds; | 541 static const int kDefaultNudgeDelayMilliseconds; |
540 static const int kPreferencesNudgeDelayMilliseconds; | 542 static const int kPreferencesNudgeDelayMilliseconds; |
541 static const int kPiggybackNudgeDelay; | 543 static const int kPiggybackNudgeDelay; |
542 | 544 |
543 static const FilePath::CharType kSyncDatabaseFilename[]; | 545 static const FilePath::CharType kSyncDatabaseFilename[]; |
544 | 546 |
545 private: | 547 private: |
| 548 friend class SyncManagerTest; |
546 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); | 549 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
547 | 550 |
548 // For unit tests. | 551 // For unit tests. |
549 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); | 552 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); |
550 | 553 |
| 554 // Set the internal scheduler for testing purposes. |
| 555 // TODO(sync): Use dependency injection instead. crbug.com/133061 |
| 556 void SetSyncSchedulerForTest( |
| 557 scoped_ptr<browser_sync::SyncScheduler> scheduler); |
| 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 |