| 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 "sync/engine/build_commit_command.h" | 5 #include "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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) { | 106 SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) { |
| 107 commit_message_->set_share(session->context()->account_name()); | 107 commit_message_->set_share(session->context()->account_name()); |
| 108 commit_message_->set_message_contents(sync_pb::ClientToServerMessage::COMMIT); | 108 commit_message_->set_message_contents(sync_pb::ClientToServerMessage::COMMIT); |
| 109 | 109 |
| 110 sync_pb::CommitMessage* commit_message = commit_message_->mutable_commit(); | 110 sync_pb::CommitMessage* commit_message = commit_message_->mutable_commit(); |
| 111 commit_message->set_cache_guid( | 111 commit_message->set_cache_guid( |
| 112 session->write_transaction()->directory()->cache_guid()); | 112 session->write_transaction()->directory()->cache_guid()); |
| 113 AddExtensionsActivityToMessage(session, commit_message); | 113 AddExtensionsActivityToMessage(session, commit_message); |
| 114 SyncerProtoUtil::SetProtocolVersion(commit_message_); | |
| 115 SyncerProtoUtil::AddRequestBirthday( | |
| 116 session->write_transaction()->directory(), commit_message_); | |
| 117 SyncerProtoUtil::AddBagOfChips( | |
| 118 session->write_transaction()->directory(), commit_message_); | |
| 119 | 114 |
| 120 // Cache previously computed position values. Because |commit_ids| | 115 // Cache previously computed position values. Because |commit_ids| |
| 121 // is already in sibling order, we should always hit this map after | 116 // is already in sibling order, we should always hit this map after |
| 122 // the first sibling in a consecutive run of commit items. The | 117 // the first sibling in a consecutive run of commit items. The |
| 123 // entries in this map are (low, high) values describing the | 118 // entries in this map are (low, high) values describing the |
| 124 // space of positions that are immediate successors of the item | 119 // space of positions that are immediate successors of the item |
| 125 // whose ID is the map's key. | 120 // whose ID is the map's key. |
| 126 std::map<Id, std::pair<int64, int64> > position_map; | 121 std::map<Id, std::pair<int64, int64> > position_map; |
| 127 | 122 |
| 128 for (size_t i = 0; i < batch_commit_set_.Size(); i++) { | 123 for (size_t i = 0; i < batch_commit_set_.Size(); i++) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 if (delta <= static_cast<uint64>(GetGap()*2)) | 255 if (delta <= static_cast<uint64>(GetGap()*2)) |
| 261 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. | 256 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. |
| 262 else if (lo == GetFirstPosition()) | 257 else if (lo == GetFirstPosition()) |
| 263 return hi - GetGap(); // Extend range just before successor. | 258 return hi - GetGap(); // Extend range just before successor. |
| 264 else | 259 else |
| 265 return lo + GetGap(); // Use or extend range just after predecessor. | 260 return lo + GetGap(); // Use or extend range just after predecessor. |
| 266 } | 261 } |
| 267 | 262 |
| 268 | 263 |
| 269 } // namespace syncer | 264 } // namespace syncer |
| OLD | NEW |