OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/engine/build_commit_command.h" | 5 #include "chrome/browser/sync/engine/build_commit_command.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 DCHECK(id.ServerKnows()) << meta_entry; | 172 DCHECK(id.ServerKnows()) << meta_entry; |
173 sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION)); | 173 sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION)); |
174 } | 174 } |
175 sync_entry->set_ctime(TimeToProtoTime(meta_entry.Get(syncable::CTIME))); | 175 sync_entry->set_ctime(TimeToProtoTime(meta_entry.Get(syncable::CTIME))); |
176 sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME))); | 176 sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME))); |
177 | 177 |
178 // Deletion is final on the server, let's move things and then delete them. | 178 // Deletion is final on the server, let's move things and then delete them. |
179 if (meta_entry.Get(IS_DEL)) { | 179 if (meta_entry.Get(IS_DEL)) { |
180 sync_entry->set_deleted(true); | 180 sync_entry->set_deleted(true); |
181 } else { | 181 } else { |
182 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { | 182 if (meta_entry.Get(SPECIFICS).has_bookmark()) { |
183 // Common data in both new and old protocol. | 183 // Common data in both new and old protocol. |
184 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); | 184 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); |
185 string prev_id_string = | 185 string prev_id_string = |
186 prev_id.IsRoot() ? string() : prev_id.GetServerId(); | 186 prev_id.IsRoot() ? string() : prev_id.GetServerId(); |
187 sync_entry->set_insert_after_item_id(prev_id_string); | 187 sync_entry->set_insert_after_item_id(prev_id_string); |
188 | 188 |
189 // Compute a numeric position based on what we know locally. | 189 // Compute a numeric position based on what we know locally. |
190 std::pair<int64, int64> position_block( | 190 std::pair<int64, int64> position_block( |
191 GetFirstPosition(), GetLastPosition()); | 191 GetFirstPosition(), GetLastPosition()); |
192 std::map<Id, std::pair<int64, int64> >::iterator prev_pos = | 192 std::map<Id, std::pair<int64, int64> >::iterator prev_pos = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 if (delta <= static_cast<uint64>(GetGap()*2)) | 246 if (delta <= static_cast<uint64>(GetGap()*2)) |
247 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. | 247 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. |
248 else if (lo == GetFirstPosition()) | 248 else if (lo == GetFirstPosition()) |
249 return hi - GetGap(); // Extend range just before successor. | 249 return hi - GetGap(); // Extend range just before successor. |
250 else | 250 else |
251 return lo + GetGap(); // Use or extend range just after predecessor. | 251 return lo + GetGap(); // Use or extend range just after predecessor. |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 } // namespace browser_sync | 255 } // namespace browser_sync |
OLD | NEW |