OLD | NEW |
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_INTERNAL_API_SYNC_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
6 #define CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define CHROME_BROWSER_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.h" | 12 #include "base/callback.h" |
| 13 #include "base/time.h" |
13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
14 #include "chrome/browser/sync/internal_api/change_record.h" | 15 #include "chrome/browser/sync/internal_api/change_record.h" |
15 #include "chrome/browser/sync/internal_api/configure_reason.h" | 16 #include "chrome/browser/sync/internal_api/configure_reason.h" |
16 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 17 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
17 #include "chrome/browser/sync/syncable/model_type.h" | 18 #include "chrome/browser/sync/syncable/model_type.h" |
18 #include "chrome/browser/sync/util/weak_handle.h" | 19 #include "chrome/browser/sync/util/weak_handle.h" |
19 #include "chrome/common/net/gaia/google_service_auth_error.h" | 20 #include "chrome/common/net/gaia/google_service_auth_error.h" |
20 | 21 |
21 class FilePath; | 22 class FilePath; |
22 | 23 |
(...skipping 26 matching lines...) Expand all Loading... |
49 // migration or upgrade. | 50 // migration or upgrade. |
50 REASON_DECRYPTION = 2, // The cryptographer requires a | 51 REASON_DECRYPTION = 2, // The cryptographer requires a |
51 // passphrase for its first attempt at | 52 // passphrase for its first attempt at |
52 // decryption. | 53 // decryption. |
53 REASON_SET_PASSPHRASE_FAILED = 3, // The cryptographer requires a new | 54 REASON_SET_PASSPHRASE_FAILED = 3, // The cryptographer requires a new |
54 // passphrase because its attempt at | 55 // passphrase because its attempt at |
55 // decryption with the cached passphrase | 56 // decryption with the cached passphrase |
56 // was unsuccessful. | 57 // was unsuccessful. |
57 }; | 58 }; |
58 | 59 |
| 60 // Possible types of nudge delay for datatypes. |
| 61 // Note: These are just hints. If a sync happens then all dirty entries |
| 62 // would be committed as part of the sync. |
| 63 enum NudgeDelayType { |
| 64 // Sync right away. |
| 65 IMMEDIATE, |
| 66 |
| 67 // Sync this change while syncing another change. |
| 68 PIGGY_BACK_WITH_ANOTHER_CHANGE, |
| 69 |
| 70 // The datatype does not use one of the predefined wait times but defines its |
| 71 // own wait time logic for nudge. |
| 72 CUSTOM, |
| 73 }; |
| 74 |
59 // Contains everything needed to talk to and identify a user account. | 75 // Contains everything needed to talk to and identify a user account. |
60 struct SyncCredentials { | 76 struct SyncCredentials { |
61 std::string email; | 77 std::string email; |
62 std::string sync_token; | 78 std::string sync_token; |
63 }; | 79 }; |
64 | 80 |
65 // SyncManager encapsulates syncable::DirectoryManager and serves as | 81 // SyncManager encapsulates syncable::DirectoryManager and serves as |
66 // the parent of all other objects in the sync API. If multiple | 82 // the parent of all other objects in the sync API. If multiple |
67 // threads interact with the same local sync repository (i.e. the same | 83 // threads interact with the same local sync repository (i.e. the same |
68 // sqlite database), they should share a single SyncManager instance. | 84 // sqlite database), they should share a single SyncManager instance. |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 bool HasUnsyncedItems() const; | 592 bool HasUnsyncedItems() const; |
577 | 593 |
578 // Functions used for testing. | 594 // Functions used for testing. |
579 | 595 |
580 void TriggerOnNotificationStateChangeForTest( | 596 void TriggerOnNotificationStateChangeForTest( |
581 bool notifications_enabled); | 597 bool notifications_enabled); |
582 | 598 |
583 void TriggerOnIncomingNotificationForTest( | 599 void TriggerOnIncomingNotificationForTest( |
584 const syncable::ModelTypeBitSet& model_types); | 600 const syncable::ModelTypeBitSet& model_types); |
585 | 601 |
| 602 static const int kDefaultNudgeDelayMilliseconds; |
| 603 static const int kPreferencesNudgeDelayMilliseconds; |
| 604 static const int kPiggybackNudgeDelay; |
| 605 |
586 private: | 606 private: |
| 607 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
| 608 |
| 609 // For unit tests. |
| 610 base::TimeDelta GetNudgeDelayTimeDelta(const syncable::ModelType& model_type); |
| 611 |
587 base::ThreadChecker thread_checker_; | 612 base::ThreadChecker thread_checker_; |
588 | 613 |
589 // An opaque pointer to the nested private class. | 614 // An opaque pointer to the nested private class. |
590 SyncInternal* data_; | 615 SyncInternal* data_; |
591 | 616 |
592 DISALLOW_COPY_AND_ASSIGN(SyncManager); | 617 DISALLOW_COPY_AND_ASSIGN(SyncManager); |
593 }; | 618 }; |
594 | 619 |
595 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); | 620 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); |
596 | 621 |
597 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 622 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
598 const syncable::ModelTypeSet types, | 623 const syncable::ModelTypeSet types, |
599 sync_api::UserShare* share); | 624 sync_api::UserShare* share); |
600 | 625 |
601 // Returns the string representation of a PassphraseRequiredReason value. | 626 // Returns the string representation of a PassphraseRequiredReason value. |
602 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 627 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
603 | 628 |
604 } // namespace sync_api | 629 } // namespace sync_api |
605 | 630 |
606 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 631 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
OLD | NEW |