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

Side by Side Diff: sync/engine/get_commit_ids.cc

Issue 211523002: Add AttachmentMetadata to Sync's EntryKernel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot about using META_PROTO_TIMES_VALS in the test. Created 6 years, 8 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
« no previous file with comments | « no previous file | sync/protocol/attachments.proto » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "sync/engine/get_commit_ids.h" 5 #include "sync/engine/get_commit_ids.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // The local and server versions don't match. The item must be in 98 // The local and server versions don't match. The item must be in
99 // conflict, so there's no point in attempting to commit. 99 // conflict, so there's no point in attempting to commit.
100 DCHECK(entry.GetIsUnappliedUpdate()); 100 DCHECK(entry.GetIsUnappliedUpdate());
101 DVLOG(1) << "Excluding entry from commit due to version mismatch " 101 DVLOG(1) << "Excluding entry from commit due to version mismatch "
102 << entry; 102 << entry;
103 return true; 103 return true;
104 } 104 }
105 return false; 105 return false;
106 } 106 }
107 107
108 // Return true if this entry has any attachments that haven't yet been uploaded
109 // to the server.
110 bool HasAttachmentNotOnServer(const syncable::Entry& entry) {
111 // TODO(maniscalco): Once AttachmentMetadata is fleshed out, implement this
112 // function to return true if any of the attachments haven't been uploaded to
113 // the server. Add test case (bug 356266).
114 return false;
115 }
116
108 // An entry is not considered ready for commit if any are true: 117 // An entry is not considered ready for commit if any are true:
109 // 1. It's in conflict. 118 // 1. It's in conflict.
110 // 2. It requires encryption (either the type is encrypted but a passphrase 119 // 2. It requires encryption (either the type is encrypted but a passphrase
111 // is missing from the cryptographer, or the entry itself wasn't properly 120 // is missing from the cryptographer, or the entry itself wasn't properly
112 // encrypted). 121 // encrypted).
113 // 3. It's type is currently throttled. 122 // 3. It's type is currently throttled.
114 // 4. It's a delete but has not been committed. 123 // 4. It's a delete but has not been committed.
115 bool IsEntryReadyForCommit(ModelTypeSet requested_types, 124 bool IsEntryReadyForCommit(ModelTypeSet requested_types,
116 ModelTypeSet encrypted_types, 125 ModelTypeSet encrypted_types,
117 bool passphrase_missing, 126 bool passphrase_missing,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // If the root becomes unsynced it can cause us problems. 163 // If the root becomes unsynced it can cause us problems.
155 NOTREACHED() << "Root item became unsynced " << entry; 164 NOTREACHED() << "Root item became unsynced " << entry;
156 return false; 165 return false;
157 } 166 }
158 167
159 if (entry.IsRoot()) { 168 if (entry.IsRoot()) {
160 NOTREACHED() << "Permanent item became unsynced " << entry; 169 NOTREACHED() << "Permanent item became unsynced " << entry;
161 return false; 170 return false;
162 } 171 }
163 172
173 if (HasAttachmentNotOnServer(entry)) {
174 // This entry is not ready to be sent to the server because it has one or
175 // more attachments that have not yet been uploaded to the server. The idea
176 // here is avoid propagating an entry with dangling attachment references.
177 return false;
178 }
179
164 DVLOG(2) << "Entry is ready for commit: " << entry; 180 DVLOG(2) << "Entry is ready for commit: " << entry;
165 return true; 181 return true;
166 } 182 }
167 183
168 // Filters |unsynced_handles| to remove all entries that do not belong to the 184 // Filters |unsynced_handles| to remove all entries that do not belong to the
169 // specified |requested_types|, or are not eligible for a commit at this time. 185 // specified |requested_types|, or are not eligible for a commit at this time.
170 void FilterUnreadyEntries( 186 void FilterUnreadyEntries(
171 syncable::BaseTransaction* trans, 187 syncable::BaseTransaction* trans,
172 ModelTypeSet requested_types, 188 ModelTypeSet requested_types,
173 ModelTypeSet encrypted_types, 189 ModelTypeSet encrypted_types,
174 bool passphrase_missing, 190 bool passphrase_missing,
175 const syncable::Directory::Metahandles& unsynced_handles, 191 const syncable::Directory::Metahandles& unsynced_handles,
176 std::set<int64>* ready_unsynced_set) { 192 std::set<int64>* ready_unsynced_set) {
177 for (syncable::Directory::Metahandles::const_iterator iter = 193 for (syncable::Directory::Metahandles::const_iterator iter =
178 unsynced_handles.begin(); iter != unsynced_handles.end(); ++iter) { 194 unsynced_handles.begin(); iter != unsynced_handles.end(); ++iter) {
179 syncable::Entry entry(trans, syncable::GET_BY_HANDLE, *iter); 195 syncable::Entry entry(trans, syncable::GET_BY_HANDLE, *iter);
196 // TODO(maniscalco): While we check if entry is ready to be committed, we
197 // also need to check that all of its ancestors (parents, transitive) are
198 // ready to be committed. Once attachments can prevent an entry from being
199 // committable, this method must ensure all ancestors are ready for commit
200 // (bug 356273).
180 if (IsEntryReadyForCommit(requested_types, 201 if (IsEntryReadyForCommit(requested_types,
181 encrypted_types, 202 encrypted_types,
182 passphrase_missing, 203 passphrase_missing,
183 entry)) { 204 entry)) {
184 ready_unsynced_set->insert(*iter); 205 ready_unsynced_set->insert(*iter);
185 } 206 }
186 } 207 }
187 } 208 }
188 209
189 // This class helps to implement OrderCommitIds(). Its members track the 210 // This class helps to implement OrderCommitIds(). Its members track the
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Add moves and creates, and prepend their uncommitted parents. 520 // Add moves and creates, and prepend their uncommitted parents.
500 traversal.AddCreatesAndMoves(ready_unsynced_set); 521 traversal.AddCreatesAndMoves(ready_unsynced_set);
501 522
502 // Add all deletes. 523 // Add all deletes.
503 traversal.AddDeletes(ready_unsynced_set); 524 traversal.AddDeletes(ready_unsynced_set);
504 } 525 }
505 526
506 } // namespace 527 } // namespace
507 528
508 } // namespace syncer 529 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/protocol/attachments.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698