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" |
14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 15 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
15 #include "chrome/browser/sync/sessions/sync_session.h" | 16 #include "chrome/browser/sync/sessions/sync_session.h" |
16 #include "chrome/browser/sync/syncable/syncable.h" | 17 #include "chrome/browser/sync/syncable/syncable.h" |
17 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 18 #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(TimeToProtoTime(meta_entry.Get(syncable::CTIME))); | 175 sync_entry->set_ctime(ClientTimeToServerTime( |
176 sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME))); | 176 meta_entry.Get(syncable::CTIME))); |
| 177 sync_entry->set_mtime(ClientTimeToServerTime( |
| 178 meta_entry.Get(syncable::MTIME))); |
177 | 179 |
178 // Deletion is final on the server, let's move things and then delete them. | 180 // Deletion is final on the server, let's move things and then delete them. |
179 if (meta_entry.Get(IS_DEL)) { | 181 if (meta_entry.Get(IS_DEL)) { |
180 sync_entry->set_deleted(true); | 182 sync_entry->set_deleted(true); |
181 } else { | 183 } else { |
182 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { | 184 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { |
183 // Common data in both new and old protocol. | 185 // Common data in both new and old protocol. |
184 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); | 186 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); |
185 string prev_id_string = | 187 string prev_id_string = |
186 prev_id.IsRoot() ? string() : prev_id.GetServerId(); | 188 prev_id.IsRoot() ? string() : prev_id.GetServerId(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 if (delta <= static_cast<uint64>(GetGap()*2)) | 245 if (delta <= static_cast<uint64>(GetGap()*2)) |
244 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. | 246 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. |
245 else if (lo == GetFirstPosition()) | 247 else if (lo == GetFirstPosition()) |
246 return hi - GetGap(); // Extend range just before successor. | 248 return hi - GetGap(); // Extend range just before successor. |
247 else | 249 else |
248 return lo + GetGap(); // Use or extend range just after predecessor. | 250 return lo + GetGap(); // Use or extend range just after predecessor. |
249 } | 251 } |
250 | 252 |
251 | 253 |
252 } // namespace browser_sync | 254 } // namespace browser_sync |
OLD | NEW |