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

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

Issue 442053002: sync: Add non-blocking type encryption (retry) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « sync/engine/entity_tracker.cc ('k') | sync/engine/model_type_entity.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_MODEL_TYPE_ENTITY_H_ 5 #ifndef SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
6 #define SYNC_ENGINE_MODEL_TYPE_ENTITY_H_ 6 #define SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 28 matching lines...) Expand all
39 39
40 // Construct an instance representing an item newly received from the server. 40 // Construct an instance representing an item newly received from the server.
41 static scoped_ptr<ModelTypeEntity> FromServerUpdate( 41 static scoped_ptr<ModelTypeEntity> FromServerUpdate(
42 const std::string& id, 42 const std::string& id,
43 const std::string& client_tag_hash, 43 const std::string& client_tag_hash,
44 const std::string& non_unique_name, 44 const std::string& non_unique_name,
45 int64 version, 45 int64 version,
46 const sync_pb::EntitySpecifics& specifics, 46 const sync_pb::EntitySpecifics& specifics,
47 bool deleted, 47 bool deleted,
48 base::Time ctime, 48 base::Time ctime,
49 base::Time mtime); 49 base::Time mtime,
50 const std::string& encryption_key_name);
50 51
51 // TODO(rlarocque): Implement FromDisk constructor when we implement storage. 52 // TODO(rlarocque): Implement FromDisk constructor when we implement storage.
52 53
53 ~ModelTypeEntity(); 54 ~ModelTypeEntity();
54 55
55 // Returns true if this data is out of sync with local storage. 56 // Returns true if this data is out of sync with local storage.
56 bool IsWriteRequired() const; 57 bool IsWriteRequired() const;
57 58
58 // Returns true if this data is out of sync with the server. 59 // Returns true if this data is out of sync with the server.
59 // A commit may or may not be in progress at this time. 60 // A commit may or may not be in progress at this time.
(...skipping 12 matching lines...) Expand all
72 // Returns true if the specified update version conflicts with local changes. 73 // Returns true if the specified update version conflicts with local changes.
73 bool UpdateIsInConflict(int64 update_version) const; 74 bool UpdateIsInConflict(int64 update_version) const;
74 75
75 // Applies an update from the sync server. 76 // Applies an update from the sync server.
76 // 77 //
77 // Overrides any local changes. Check UpdateIsInConflict() before calling 78 // Overrides any local changes. Check UpdateIsInConflict() before calling
78 // this function if you want to handle conflicts differently. 79 // this function if you want to handle conflicts differently.
79 void ApplyUpdateFromServer(int64 update_version, 80 void ApplyUpdateFromServer(int64 update_version,
80 bool deleted, 81 bool deleted,
81 const sync_pb::EntitySpecifics& specifics, 82 const sync_pb::EntitySpecifics& specifics,
82 base::Time mtime); 83 base::Time mtime,
84 const std::string& encryption_key_name);
83 85
84 // Applies a local change to this item. 86 // Applies a local change to this item.
85 void MakeLocalChange(const sync_pb::EntitySpecifics& specifics); 87 void MakeLocalChange(const sync_pb::EntitySpecifics& specifics);
86 88
89 // Schedule a commit if the |name| does not match this item's last known
90 // encryption key. The worker that performs the commit is expected to
91 // encrypt the item using the latest available key.
92 void UpdateDesiredEncryptionKey(const std::string& name);
93
87 // Applies a local deletion to this item. 94 // Applies a local deletion to this item.
88 void Delete(); 95 void Delete();
89 96
90 // Initializes a message representing this item's uncommitted state 97 // Initializes a message representing this item's uncommitted state
91 // to be forwarded to the sync server for committing. 98 // to be forwarded to the sync server for committing.
92 void InitializeCommitRequestData(CommitRequestData* request) const; 99 void InitializeCommitRequestData(CommitRequestData* request) const;
93 100
94 // Notes that the current version of this item has been queued for commit. 101 // Notes that the current version of this item has been queued for commit.
95 void SetCommitRequestInProgress(); 102 void SetCommitRequestInProgress();
96 103
97 // Receives a successful commit response. 104 // Receives a successful commit response.
98 // 105 //
99 // Sucssful commit responses can overwrite an item's ID. 106 // Sucssful commit responses can overwrite an item's ID.
100 // 107 //
101 // Note that the receipt of a successful commit response does not necessarily 108 // Note that the receipt of a successful commit response does not necessarily
102 // unset IsUnsynced(). If many local changes occur in quick succession, it's 109 // unset IsUnsynced(). If many local changes occur in quick succession, it's
103 // possible that the committed item was already out of date by the time it 110 // possible that the committed item was already out of date by the time it
104 // reached the server. 111 // reached the server.
105 void ReceiveCommitResponse(const std::string& id, 112 void ReceiveCommitResponse(const std::string& id,
106 int64 sequence_number, 113 int64 sequence_number,
107 int64 response_version); 114 int64 response_version,
115 const std::string& encryption_key_name);
108 116
109 // Clears any in-memory sync state associated with outstanding commits. 117 // Clears any in-memory sync state associated with outstanding commits.
110 void ClearTransientSyncState(); 118 void ClearTransientSyncState();
111 119
112 // Clears all sync state. Invoked when a user signs out. 120 // Clears all sync state. Invoked when a user signs out.
113 void ClearSyncState(); 121 void ClearSyncState();
114 122
115 private: 123 private:
116 ModelTypeEntity(int64 sequence_number, 124 ModelTypeEntity(int64 sequence_number,
117 int64 commit_requested_sequence_number, 125 int64 commit_requested_sequence_number,
118 int64 acked_sequence_number, 126 int64 acked_sequence_number,
119 int64 base_version, 127 int64 base_version,
120 bool is_dirty, 128 bool is_dirty,
121 const std::string& id, 129 const std::string& id,
122 const std::string& client_tag_hash, 130 const std::string& client_tag_hash,
123 const std::string& non_unique_name, 131 const std::string& non_unique_name,
124 const sync_pb::EntitySpecifics& specifics, 132 const sync_pb::EntitySpecifics& specifics,
125 bool deleted, 133 bool deleted,
126 base::Time ctime, 134 base::Time ctime,
127 base::Time mtime); 135 base::Time mtime,
136 const std::string& encryption_key_name);
128 137
129 // A sequence number used to track in-progress commits. Each local change 138 // A sequence number used to track in-progress commits. Each local change
130 // increments this number. 139 // increments this number.
131 int64 sequence_number_; 140 int64 sequence_number_;
132 141
133 // The sequence number of the last item sent to the sync thread. 142 // The sequence number of the last item sent to the sync thread.
134 int64 commit_requested_sequence_number_; 143 int64 commit_requested_sequence_number_;
135 144
136 // The sequence number of the last item known to be successfully committed. 145 // The sequence number of the last item known to be successfully committed.
137 int64 acked_sequence_number_; 146 int64 acked_sequence_number_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 187
179 // Whether or not the item is deleted. The |specifics_| field may be empty 188 // Whether or not the item is deleted. The |specifics_| field may be empty
180 // if this flag is true. 189 // if this flag is true.
181 bool deleted_; 190 bool deleted_;
182 191
183 // Entity creation and modification timestamps. 192 // Entity creation and modification timestamps.
184 // Assigned by the client and synced by the server, though the server usually 193 // Assigned by the client and synced by the server, though the server usually
185 // doesn't bother to inspect their values. 194 // doesn't bother to inspect their values.
186 base::Time ctime_; 195 base::Time ctime_;
187 base::Time mtime_; 196 base::Time mtime_;
197
198 // The name of the encryption key used to encrypt this item on the server.
199 // Empty when no encryption is in use.
200 std::string encryption_key_name_;
188 }; 201 };
189 202
190 } // namespace syncer 203 } // namespace syncer
191 204
192 #endif // SYNC_ENGINE_MODEL_TYPE_ENTITY_H_ 205 #endif // SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
OLDNEW
« no previous file with comments | « sync/engine/entity_tracker.cc ('k') | sync/engine/model_type_entity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698