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

Side by Side Diff: sync/engine/entity_tracker.h

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « sync/engine/directory_update_handler_unittest.cc ('k') | sync/engine/entity_tracker.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ENGINE_ENTITY_TRACKER_H_ 5 #ifndef SYNC_ENGINE_ENTITY_TRACKER_H_
6 #define SYNC_ENGINE_ENTITY_TRACKER_H_ 6 #define SYNC_ENGINE_ENTITY_TRACKER_H_
7 7
8 #include <stdint.h>
9
8 #include <string> 10 #include <string>
9 11
10 #include "base/basictypes.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "sync/base/sync_export.h" 15 #include "sync/base/sync_export.h"
14 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.pb.h"
15 17
16 namespace syncer_v2 { 18 namespace syncer_v2 {
17 struct CommitRequestData; 19 struct CommitRequestData;
18 struct UpdateResponseData; 20 struct UpdateResponseData;
19 21
20 // Manages the pending commit and update state for an entity on the sync 22 // Manages the pending commit and update state for an entity on the sync
(...skipping 19 matching lines...) Expand all
40 // Initialize a new entity based on a commit request. 42 // Initialize a new entity based on a commit request.
41 static scoped_ptr<EntityTracker> FromCommitRequest( 43 static scoped_ptr<EntityTracker> FromCommitRequest(
42 const CommitRequestData& data); 44 const CommitRequestData& data);
43 45
44 // Returns true if this entity should be commited to the server. 46 // Returns true if this entity should be commited to the server.
45 bool HasPendingCommit() const; 47 bool HasPendingCommit() const;
46 48
47 // Populates a sync_pb::SyncEntity for a commit. Also sets the 49 // Populates a sync_pb::SyncEntity for a commit. Also sets the
48 // |sequence_number|, so we can track it throughout the commit process. 50 // |sequence_number|, so we can track it throughout the commit process.
49 void PrepareCommitProto(sync_pb::SyncEntity* commit_entity, 51 void PrepareCommitProto(sync_pb::SyncEntity* commit_entity,
50 int64* sequence_number) const; 52 int64_t* sequence_number) const;
51 53
52 // Updates this entity with data from the latest version that the 54 // Updates this entity with data from the latest version that the
53 // model asked us to commit. May clobber state related to the 55 // model asked us to commit. May clobber state related to the
54 // model's previous commit attempt(s). 56 // model's previous commit attempt(s).
55 void RequestCommit(const CommitRequestData& data); 57 void RequestCommit(const CommitRequestData& data);
56 58
57 // Handles the receipt of a commit response. 59 // Handles the receipt of a commit response.
58 // 60 //
59 // Since commits happen entirely on the sync thread, we can safely assume 61 // Since commits happen entirely on the sync thread, we can safely assume
60 // that our item's state at the end of the commit is the same as it was at 62 // that our item's state at the end of the commit is the same as it was at
61 // the start. 63 // the start.
62 void ReceiveCommitResponse(const std::string& response_id, 64 void ReceiveCommitResponse(const std::string& response_id,
63 int64 response_version, 65 int64_t response_version,
64 int64 sequence_number); 66 int64_t sequence_number);
65 67
66 // Handles receipt of an update from the server. 68 // Handles receipt of an update from the server.
67 void ReceiveUpdate(int64 version); 69 void ReceiveUpdate(int64_t version);
68 70
69 // Handles the receipt of an pending update from the server. 71 // Handles the receipt of an pending update from the server.
70 // 72 //
71 // Returns true if the tracker decides this item is worth keeping. Returns 73 // Returns true if the tracker decides this item is worth keeping. Returns
72 // false if the item is discarded, which could happen if the version number 74 // false if the item is discarded, which could happen if the version number
73 // is out of date. 75 // is out of date.
74 bool ReceivePendingUpdate(const UpdateResponseData& data); 76 bool ReceivePendingUpdate(const UpdateResponseData& data);
75 77
76 // Functions to fetch the latest pending update. 78 // Functions to fetch the latest pending update.
77 bool HasPendingUpdate() const; 79 bool HasPendingUpdate() const;
78 UpdateResponseData GetPendingUpdate() const; 80 UpdateResponseData GetPendingUpdate() const;
79 81
80 // Clears the pending update. Allows us to resume regular commit behavior. 82 // Clears the pending update. Allows us to resume regular commit behavior.
81 void ClearPendingUpdate(); 83 void ClearPendingUpdate();
82 84
83 private: 85 private:
84 // Initializes the entity tracker's main fields. Does not initialize state 86 // Initializes the entity tracker's main fields. Does not initialize state
85 // related to a pending commit. 87 // related to a pending commit.
86 EntityTracker(const std::string& id, 88 EntityTracker(const std::string& id,
87 const std::string& client_tag_hash, 89 const std::string& client_tag_hash,
88 int64 highest_commit_response_version, 90 int64_t highest_commit_response_version,
89 int64 highest_gu_response_version); 91 int64_t highest_gu_response_version);
90 92
91 // Checks if the current state indicates a conflict. 93 // Checks if the current state indicates a conflict.
92 // 94 //
93 // This can be true only while a call to this object is in progress. 95 // This can be true only while a call to this object is in progress.
94 // Conflicts are always cleared before the method call ends. 96 // Conflicts are always cleared before the method call ends.
95 bool IsInConflict() const; 97 bool IsInConflict() const;
96 98
97 // Checks if the server knows about this item. 99 // Checks if the server knows about this item.
98 bool IsServerKnown() const; 100 bool IsServerKnown() const;
99 101
100 // Clears flag and optionally clears state associated with a pending commit. 102 // Clears flag and optionally clears state associated with a pending commit.
101 void ClearPendingCommit(); 103 void ClearPendingCommit();
102 104
103 // The ID for this entry. May be empty if the entry has never been committed. 105 // The ID for this entry. May be empty if the entry has never been committed.
104 std::string id_; 106 std::string id_;
105 107
106 // The hashed client tag for this entry. 108 // The hashed client tag for this entry.
107 std::string client_tag_hash_; 109 std::string client_tag_hash_;
108 110
109 // The highest version seen in a commit response for this entry. 111 // The highest version seen in a commit response for this entry.
110 int64 highest_commit_response_version_; 112 int64_t highest_commit_response_version_;
111 113
112 // The highest version seen in a GU response for this entry. 114 // The highest version seen in a GU response for this entry.
113 int64 highest_gu_response_version_; 115 int64_t highest_gu_response_version_;
114 116
115 // Used to track in-flight commit requests on the model thread. All we need 117 // Used to track in-flight commit requests on the model thread. All we need
116 // to do here is return it back to the model thread when the pending commit 118 // to do here is return it back to the model thread when the pending commit
117 // is completed and confirmed. Not valid if no commit is pending. 119 // is completed and confirmed. Not valid if no commit is pending.
118 int64 sequence_number_; 120 int64_t sequence_number_;
119 121
120 // The server version on which this item is based. 122 // The server version on which this item is based.
121 int64 base_version_; 123 int64_t base_version_;
122 124
123 // A commit for this entity waiting for a sync cycle to be committed. 125 // A commit for this entity waiting for a sync cycle to be committed.
124 scoped_ptr<CommitRequestData> pending_commit_; 126 scoped_ptr<CommitRequestData> pending_commit_;
125 127
126 // An update for this entity which can't be applied right now. The presence 128 // An update for this entity which can't be applied right now. The presence
127 // of an pending update prevents commits. As of this writing, the only 129 // of an pending update prevents commits. As of this writing, the only
128 // source of pending updates is updates that can't currently be decrypted. 130 // source of pending updates is updates that can't currently be decrypted.
129 scoped_ptr<UpdateResponseData> pending_update_; 131 scoped_ptr<UpdateResponseData> pending_update_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(EntityTracker); 133 DISALLOW_COPY_AND_ASSIGN(EntityTracker);
132 }; 134 };
133 135
134 } // namespace syncer_v2 136 } // namespace syncer_v2
135 137
136 #endif // SYNC_ENGINE_ENTITY_TRACKER_H_ 138 #endif // SYNC_ENGINE_ENTITY_TRACKER_H_
OLDNEW
« no previous file with comments | « sync/engine/directory_update_handler_unittest.cc ('k') | sync/engine/entity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698