OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 13 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
14 #include "chrome/browser/sync/engine/syncer_util.h" | |
15 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
16 #include "chrome/browser/sync/sessions/sync_session.h" | 15 #include "chrome/browser/sync/sessions/sync_session.h" |
17 #include "chrome/browser/sync/syncable/syncable.h" | 16 #include "chrome/browser/sync/syncable/syncable.h" |
18 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 17 #include "chrome/browser/sync/syncable/syncable_changes_version.h" |
| 18 #include "chrome/browser/sync/util/time.h" |
19 | 19 |
20 using std::set; | 20 using std::set; |
21 using std::string; | 21 using std::string; |
22 using std::vector; | 22 using std::vector; |
23 using syncable::Entry; | 23 using syncable::Entry; |
24 using syncable::IS_DEL; | 24 using syncable::IS_DEL; |
25 using syncable::SERVER_POSITION_IN_PARENT; | 25 using syncable::SERVER_POSITION_IN_PARENT; |
26 using syncable::IS_UNAPPLIED_UPDATE; | 26 using syncable::IS_UNAPPLIED_UPDATE; |
27 using syncable::IS_UNSYNCED; | 27 using syncable::IS_UNSYNCED; |
28 using syncable::Id; | 28 using syncable::Id; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 DCHECK(!id.ServerKnows() || | 165 DCHECK(!id.ServerKnows() || |
166 !meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty()) | 166 !meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty()) |
167 << meta_entry; | 167 << meta_entry; |
168 | 168 |
169 // Version 0 means to create or undelete an object. | 169 // Version 0 means to create or undelete an object. |
170 sync_entry->set_version(0); | 170 sync_entry->set_version(0); |
171 } else { | 171 } else { |
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(ClientTimeToServerTime( | 175 sync_entry->set_ctime(TimeToProtoTime(meta_entry.Get(syncable::CTIME))); |
176 meta_entry.Get(syncable::CTIME))); | 176 sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME))); |
177 sync_entry->set_mtime(ClientTimeToServerTime( | |
178 meta_entry.Get(syncable::MTIME))); | |
179 | 177 |
180 // 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. |
181 if (meta_entry.Get(IS_DEL)) { | 179 if (meta_entry.Get(IS_DEL)) { |
182 sync_entry->set_deleted(true); | 180 sync_entry->set_deleted(true); |
183 } else { | 181 } else { |
184 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { | 182 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { |
185 // Common data in both new and old protocol. | 183 // Common data in both new and old protocol. |
186 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); | 184 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); |
187 string prev_id_string = | 185 string prev_id_string = |
188 prev_id.IsRoot() ? string() : prev_id.GetServerId(); | 186 prev_id.IsRoot() ? string() : prev_id.GetServerId(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 if (delta <= static_cast<uint64>(GetGap()*2)) | 243 if (delta <= static_cast<uint64>(GetGap()*2)) |
246 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. | 244 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. |
247 else if (lo == GetFirstPosition()) | 245 else if (lo == GetFirstPosition()) |
248 return hi - GetGap(); // Extend range just before successor. | 246 return hi - GetGap(); // Extend range just before successor. |
249 else | 247 else |
250 return lo + GetGap(); // Use or extend range just after predecessor. | 248 return lo + GetGap(); // Use or extend range just after predecessor. |
251 } | 249 } |
252 | 250 |
253 | 251 |
254 } // namespace browser_sync | 252 } // namespace browser_sync |
OLD | NEW |