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

Side by Side Diff: chrome/browser/sync/syncable/syncable.h

Issue 6104003: sync: use progress markers instead of timestamps during GetUpdates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tim's fixes Created 9 years, 11 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
« no previous file with comments | « chrome/browser/sync/syncable/model_type.cc ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // Set the |download_progress| entry for the given model to a
663 // "first sync" start point. When such a value is sent to the server,
664 // a full download of all objects of the model will be initiated.
665 void reset_download_progress(ModelType model_type);
666
669 // Last sync timestamp fetched from the server. 667 // Last sync timestamp fetched from the server.
670 int64 last_download_timestamp[MODEL_TYPE_COUNT]; 668 sync_pb::DataTypeProgressMarker download_progress[MODEL_TYPE_COUNT];
671 // true iff we ever reached the end of the changelog. 669 // true iff we ever reached the end of the changelog.
672 ModelTypeBitSet initial_sync_ended; 670 ModelTypeBitSet initial_sync_ended;
673 // The store birthday we were given by the server. Contents are opaque to 671 // The store birthday we were given by the server. Contents are opaque to
674 // the client. 672 // the client.
675 std::string store_birthday; 673 std::string store_birthday;
676 // The next local ID that has not been used with this cache-GUID. 674 // The next local ID that has not been used with this cache-GUID.
677 int64 next_id; 675 int64 next_id;
678 // The persisted notification state. 676 // The persisted notification state.
679 std::string notification_state; 677 std::string notification_state;
680 678
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 void Close(); 718 void Close();
721 719
722 int64 NextMetahandle(); 720 int64 NextMetahandle();
723 // Always returns a negative id. Positive client ids are generated 721 // Always returns a negative id. Positive client ids are generated
724 // by the server only. 722 // by the server only.
725 Id NextId(); 723 Id NextId();
726 724
727 const FilePath& file_path() const { return kernel_->db_path; } 725 const FilePath& file_path() const { return kernel_->db_path; }
728 bool good() const { return NULL != store_; } 726 bool good() const { return NULL != store_; }
729 727
730 // The download timestamp is an index into the server's list of changes for 728 // 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 729 // to indicate the continuation state of the next GetUpdates operation.
732 // to any time scale; its name is an historical artifact. 730 void GetDownloadProgress(
733 int64 last_download_timestamp(ModelType type) const; 731 ModelType type,
734 virtual void set_last_download_timestamp(ModelType type, int64 value); 732 sync_pb::DataTypeProgressMarker* value_out) const;
735 733 void GetDownloadProgressAsString(
736 // Find the model type or model types which have the least timestamp, and 734 ModelType type,
737 // return them along with the types having that timestamp. This is done 735 std::string* value_out) const;
738 // with the intent of sequencing GetUpdates requests in an efficient way: 736 void SetDownloadProgress(
739 // bundling together requests that have the same timestamp, and requesting 737 ModelType type,
740 // the oldest such bundles first in hopes that they might catch up to 738 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 739
760 bool initial_sync_ended_for_type(ModelType type) const; 740 bool initial_sync_ended_for_type(ModelType type) const;
761 void set_initial_sync_ended_for_type(ModelType type, bool value); 741 void set_initial_sync_ended_for_type(ModelType type, bool value);
762 AutofillMigrationState get_autofill_migration_state() const; 742 AutofillMigrationState get_autofill_migration_state() const;
763 743
764 AutofillMigrationDebugInfo get_autofill_migration_debug_info() const; 744 AutofillMigrationDebugInfo get_autofill_migration_debug_info() const;
765 745
766 void set_autofill_migration_state(AutofillMigrationState state); 746 void set_autofill_migration_state(AutofillMigrationState state);
767 747
768 void set_autofill_migration_state_debug_info( 748 void set_autofill_migration_state_debug_info(
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 907
928 // Helper method used to implement GetFirstChildId/GetLastChildId. 908 // Helper method used to implement GetFirstChildId/GetLastChildId.
929 Id GetChildWithNullIdField(IdField field, 909 Id GetChildWithNullIdField(IdField field,
930 BaseTransaction* trans, 910 BaseTransaction* trans,
931 const Id& parent_id); 911 const Id& parent_id);
932 912
933 // Internal setters that do not acquire a lock internally. These are unsafe 913 // Internal setters that do not acquire a lock internally. These are unsafe
934 // on their own; caller must guarantee exclusive access manually by holding 914 // on their own; caller must guarantee exclusive access manually by holding
935 // a ScopedKernelLock. 915 // a ScopedKernelLock.
936 void set_initial_sync_ended_for_type_unsafe(ModelType type, bool x); 916 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); 917 void SetNotificationStateUnsafe(const std::string& notification_state);
939 918
940 Directory& operator = (const Directory&); 919 Directory& operator = (const Directory&);
941 920
942 // TODO(sync): If lookups and inserts in these sets become 921 // TODO(sync): If lookups and inserts in these sets become
943 // the bottle-neck, then we can use hash-sets instead. But 922 // the bottle-neck, then we can use hash-sets instead. But
944 // that will require using #ifdefs and compiler-specific code, 923 // that will require using #ifdefs and compiler-specific code,
945 // so use standard sets for now. 924 // so use standard sets for now.
946 public: 925 public:
947 typedef std::set<EntryKernel*, LessField<MetahandleField, META_HANDLE> > 926 typedef std::set<EntryKernel*, LessField<MetahandleField, META_HANDLE> >
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 void ZeroFields(EntryKernel* entry, int first_field); 1133 void ZeroFields(EntryKernel* entry, int first_field);
1155 1134
1156 } // namespace syncable 1135 } // namespace syncable
1157 1136
1158 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1137 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1159 1138
1160 browser_sync::FastDump& operator << 1139 browser_sync::FastDump& operator <<
1161 (browser_sync::FastDump&, const syncable::Blob&); 1140 (browser_sync::FastDump&, const syncable::Blob&);
1162 1141
1163 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1142 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/model_type.cc ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698