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

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

Issue 10916174: Implement a bag of chips for sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/engine/download_updates_command.cc » ('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 (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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_); 114 SyncerProtoUtil::SetProtocolVersion(commit_message_);
115 SyncerProtoUtil::AddRequestBirthday( 115 SyncerProtoUtil::AddRequestBirthday(
116 session->write_transaction()->directory(), commit_message_); 116 session->write_transaction()->directory(), commit_message_);
117 SyncerProtoUtil::AddBagOfChips(
118 session->write_transaction()->directory(), commit_message_);
117 119
118 // Cache previously computed position values. Because |commit_ids| 120 // Cache previously computed position values. Because |commit_ids|
119 // is already in sibling order, we should always hit this map after 121 // is already in sibling order, we should always hit this map after
120 // the first sibling in a consecutive run of commit items. The 122 // the first sibling in a consecutive run of commit items. The
121 // entries in this map are (low, high) values describing the 123 // entries in this map are (low, high) values describing the
122 // space of positions that are immediate successors of the item 124 // space of positions that are immediate successors of the item
123 // whose ID is the map's key. 125 // whose ID is the map's key.
124 std::map<Id, std::pair<int64, int64> > position_map; 126 std::map<Id, std::pair<int64, int64> > position_map;
125 127
126 for (size_t i = 0; i < batch_commit_set_.Size(); i++) { 128 for (size_t i = 0; i < batch_commit_set_.Size(); i++) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (delta <= static_cast<uint64>(GetGap()*2)) 260 if (delta <= static_cast<uint64>(GetGap()*2))
259 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. 261 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate.
260 else if (lo == GetFirstPosition()) 262 else if (lo == GetFirstPosition())
261 return hi - GetGap(); // Extend range just before successor. 263 return hi - GetGap(); // Extend range just before successor.
262 else 264 else
263 return lo + GetGap(); // Use or extend range just after predecessor. 265 return lo + GetGap(); // Use or extend range just after predecessor.
264 } 266 }
265 267
266 268
267 } // namespace syncer 269 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/engine/download_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698