OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SYNCABLE_SYNCABLE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <bitset> | 10 #include <bitset> |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 class LessField; | 550 class LessField; |
551 class LessEntryMetaHandles { | 551 class LessEntryMetaHandles { |
552 public: | 552 public: |
553 inline bool operator()(const syncable::EntryKernel& a, | 553 inline bool operator()(const syncable::EntryKernel& a, |
554 const syncable::EntryKernel& b) const { | 554 const syncable::EntryKernel& b) const { |
555 return a.ref(META_HANDLE) < b.ref(META_HANDLE); | 555 return a.ref(META_HANDLE) < b.ref(META_HANDLE); |
556 } | 556 } |
557 }; | 557 }; |
558 typedef std::set<EntryKernel, LessEntryMetaHandles> OriginalEntries; | 558 typedef std::set<EntryKernel, LessEntryMetaHandles> OriginalEntries; |
559 | 559 |
560 // Represents one or more model types sharing an update timestamp, as is | |
561 // the case with a GetUpdates request. | |
562 struct MultiTypeTimeStamp { | |
563 syncable::ModelTypeBitSet data_types; | |
564 int64 timestamp; | |
565 }; | |
566 | |
567 // a WriteTransaction has a writer tag describing which body of code is doing | 560 // a WriteTransaction has a writer tag describing which body of code is doing |
568 // the write. This is defined up here since DirectoryChangeEvent also contains | 561 // the write. This is defined up here since DirectoryChangeEvent also contains |
569 // one. | 562 // one. |
570 enum WriterTag { | 563 enum WriterTag { |
571 INVALID, | 564 INVALID, |
572 SYNCER, | 565 SYNCER, |
573 AUTHWATCHER, | 566 AUTHWATCHER, |
574 UNITTEST, | 567 UNITTEST, |
575 VACUUM_AFTER_SAVE, | 568 VACUUM_AFTER_SAVE, |
576 PURGE_ENTRIES, | 569 PURGE_ENTRIES, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 class EventListenerHookup; | 652 class EventListenerHookup; |
660 | 653 |
661 // Various data that the Directory::Kernel we are backing (persisting data | 654 // Various data that the Directory::Kernel we are backing (persisting data |
662 // for) needs saved across runs of the application. | 655 // for) needs saved across runs of the application. |
663 struct PersistedKernelInfo { | 656 struct PersistedKernelInfo { |
664 AutofillMigrationDebugInfo autofill_migration_debug_info; | 657 AutofillMigrationDebugInfo autofill_migration_debug_info; |
665 | 658 |
666 PersistedKernelInfo(); | 659 PersistedKernelInfo(); |
667 ~PersistedKernelInfo(); | 660 ~PersistedKernelInfo(); |
668 | 661 |
662 void reset_download_progress(ModelType model_type); | |
tim (not reviewing)
2011/01/11 19:14:23
comment? Just seems out of place without context..
ncarter (slow)
2011/01/13 00:06:13
Done.
| |
663 | |
669 // Last sync timestamp fetched from the server. | 664 // Last sync timestamp fetched from the server. |
670 int64 last_download_timestamp[MODEL_TYPE_COUNT]; | 665 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT]; |
671 // true iff we ever reached the end of the changelog. | 666 // true iff we ever reached the end of the changelog. |
672 ModelTypeBitSet initial_sync_ended; | 667 ModelTypeBitSet initial_sync_ended; |
673 // The store birthday we were given by the server. Contents are opaque to | 668 // The store birthday we were given by the server. Contents are opaque to |
674 // the client. | 669 // the client. |
675 std::string store_birthday; | 670 std::string store_birthday; |
676 // The next local ID that has not been used with this cache-GUID. | 671 // The next local ID that has not been used with this cache-GUID. |
677 int64 next_id; | 672 int64 next_id; |
678 // The persisted notification state. | 673 // The persisted notification state. |
679 std::string notification_state; | 674 std::string notification_state; |
680 | 675 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 void Close(); | 715 void Close(); |
721 | 716 |
722 int64 NextMetahandle(); | 717 int64 NextMetahandle(); |
723 // Always returns a negative id. Positive client ids are generated | 718 // Always returns a negative id. Positive client ids are generated |
724 // by the server only. | 719 // by the server only. |
725 Id NextId(); | 720 Id NextId(); |
726 | 721 |
727 const FilePath& file_path() const { return kernel_->db_path; } | 722 const FilePath& file_path() const { return kernel_->db_path; } |
728 bool good() const { return NULL != store_; } | 723 bool good() const { return NULL != store_; } |
729 | 724 |
730 // The download timestamp is an index into the server's list of changes for | 725 // The download progress is an opaque token provided by the sync server |
731 // an account. We keep this for each datatype. It doesn't actually map | 726 // to indicate the continuation state of the next GetUpdates operation. |
732 // to any time scale; its name is an historical artifact. | 727 void GetDownloadProgress( |
733 int64 last_download_timestamp(ModelType type) const; | 728 ModelType type, |
734 virtual void set_last_download_timestamp(ModelType type, int64 value); | 729 sync_pb::DataTypeProgressMarker* value_out) const; |
735 | 730 void GetDownloadProgressAsString( |
736 // Find the model type or model types which have the least timestamp, and | 731 ModelType type, |
737 // return them along with the types having that timestamp. This is done | 732 std::string* value_out) const; |
738 // with the intent of sequencing GetUpdates requests in an efficient way: | 733 void SetDownloadProgress( |
739 // bundling together requests that have the same timestamp, and requesting | 734 ModelType type, |
740 // the oldest such bundles first in hopes that they might catch up to | 735 const sync_pb::DataTypeProgressMarker& value); |
741 // (and thus be merged with) the newer bundles. | |
742 MultiTypeTimeStamp GetTypesWithOldestLastDownloadTimestamp( | |
743 ModelTypeBitSet enabled_types) { | |
744 MultiTypeTimeStamp result; | |
745 result.timestamp = std::numeric_limits<int64>::max(); | |
746 for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { | |
747 if (!enabled_types[i]) | |
748 continue; | |
749 int64 stamp = last_download_timestamp(ModelTypeFromInt(i)); | |
750 if (stamp < result.timestamp) { | |
751 result.data_types.reset(); | |
752 result.timestamp = stamp; | |
753 } | |
754 if (stamp == result.timestamp) | |
755 result.data_types.set(i); | |
756 } | |
757 return result; | |
758 } | |
759 | 736 |
760 bool initial_sync_ended_for_type(ModelType type) const; | 737 bool initial_sync_ended_for_type(ModelType type) const; |
761 void set_initial_sync_ended_for_type(ModelType type, bool value); | 738 void set_initial_sync_ended_for_type(ModelType type, bool value); |
762 AutofillMigrationState get_autofill_migration_state() const; | 739 AutofillMigrationState get_autofill_migration_state() const; |
763 | 740 |
764 AutofillMigrationDebugInfo get_autofill_migration_debug_info() const; | 741 AutofillMigrationDebugInfo get_autofill_migration_debug_info() const; |
765 | 742 |
766 void set_autofill_migration_state(AutofillMigrationState state); | 743 void set_autofill_migration_state(AutofillMigrationState state); |
767 | 744 |
768 void set_autofill_migration_state_debug_info( | 745 void set_autofill_migration_state_debug_info( |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 | 904 |
928 // Helper method used to implement GetFirstChildId/GetLastChildId. | 905 // Helper method used to implement GetFirstChildId/GetLastChildId. |
929 Id GetChildWithNullIdField(IdField field, | 906 Id GetChildWithNullIdField(IdField field, |
930 BaseTransaction* trans, | 907 BaseTransaction* trans, |
931 const Id& parent_id); | 908 const Id& parent_id); |
932 | 909 |
933 // Internal setters that do not acquire a lock internally. These are unsafe | 910 // Internal setters that do not acquire a lock internally. These are unsafe |
934 // on their own; caller must guarantee exclusive access manually by holding | 911 // on their own; caller must guarantee exclusive access manually by holding |
935 // a ScopedKernelLock. | 912 // a ScopedKernelLock. |
936 void set_initial_sync_ended_for_type_unsafe(ModelType type, bool x); | 913 void set_initial_sync_ended_for_type_unsafe(ModelType type, bool x); |
937 void set_last_download_timestamp_unsafe(ModelType model_type, int64 x); | |
938 void SetNotificationStateUnsafe(const std::string& notification_state); | 914 void SetNotificationStateUnsafe(const std::string& notification_state); |
939 | 915 |
940 Directory& operator = (const Directory&); | 916 Directory& operator = (const Directory&); |
941 | 917 |
942 // TODO(sync): If lookups and inserts in these sets become | 918 // TODO(sync): If lookups and inserts in these sets become |
943 // the bottle-neck, then we can use hash-sets instead. But | 919 // the bottle-neck, then we can use hash-sets instead. But |
944 // that will require using #ifdefs and compiler-specific code, | 920 // that will require using #ifdefs and compiler-specific code, |
945 // so use standard sets for now. | 921 // so use standard sets for now. |
946 public: | 922 public: |
947 typedef std::set<EntryKernel*, LessField<MetahandleField, META_HANDLE> > | 923 typedef std::set<EntryKernel*, LessField<MetahandleField, META_HANDLE> > |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1154 void ZeroFields(EntryKernel* entry, int first_field); | 1130 void ZeroFields(EntryKernel* entry, int first_field); |
1155 | 1131 |
1156 } // namespace syncable | 1132 } // namespace syncable |
1157 | 1133 |
1158 std::ostream& operator <<(std::ostream&, const syncable::Blob&); | 1134 std::ostream& operator <<(std::ostream&, const syncable::Blob&); |
1159 | 1135 |
1160 browser_sync::FastDump& operator << | 1136 browser_sync::FastDump& operator << |
1161 (browser_sync::FastDump&, const syncable::Blob&); | 1137 (browser_sync::FastDump&, const syncable::Blob&); |
1162 | 1138 |
1163 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ | 1139 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ |
OLD | NEW |