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 10523003: Refactor following sync commit loop change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 years, 6 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 | « chrome/browser/sync/sync_ui_util.cc ('k') | sync/engine/commit.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // space of positions that are immediate successors of the item 117 // space of positions that are immediate successors of the item
118 // whose ID is the map's key. 118 // whose ID is the map's key.
119 std::map<Id, std::pair<int64, int64> > position_map; 119 std::map<Id, std::pair<int64, int64> > position_map;
120 120
121 for (size_t i = 0; i < batch_commit_set_.Size(); i++) { 121 for (size_t i = 0; i < batch_commit_set_.Size(); i++) {
122 Id id = batch_commit_set_.GetCommitIdAt(i); 122 Id id = batch_commit_set_.GetCommitIdAt(i);
123 SyncEntity* sync_entry = 123 SyncEntity* sync_entry =
124 static_cast<SyncEntity*>(commit_message->add_entries()); 124 static_cast<SyncEntity*>(commit_message->add_entries());
125 sync_entry->set_id(id); 125 sync_entry->set_id(id);
126 MutableEntry meta_entry(session->write_transaction(), 126 MutableEntry meta_entry(session->write_transaction(),
127 syncable::GET_BY_ID, 127 syncable::GET_BY_ID, id);
128 id);
129 CHECK(meta_entry.good()); 128 CHECK(meta_entry.good());
130 // This is the only change we make to the entry in this function.
131 meta_entry.Put(syncable::SYNCING, true);
132 129
133 DCHECK(0 != session->routing_info().count(meta_entry.GetModelType())) 130 DCHECK(0 != session->routing_info().count(meta_entry.GetModelType()))
134 << "Committing change to datatype that's not actively enabled."; 131 << "Committing change to datatype that's not actively enabled.";
135 132
136 string name = meta_entry.Get(syncable::NON_UNIQUE_NAME); 133 string name = meta_entry.Get(syncable::NON_UNIQUE_NAME);
137 CHECK(!name.empty()); // Make sure this isn't an update. 134 CHECK(!name.empty()); // Make sure this isn't an update.
138 TruncateUTF8ToByteSize(name, 255, &name); 135 TruncateUTF8ToByteSize(name, 255, &name);
139 sync_entry->set_name(name); 136 sync_entry->set_name(name);
140 137
141 // Set the non_unique_name. If we do, the server ignores 138 // Set the non_unique_name. If we do, the server ignores
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (delta <= static_cast<uint64>(GetGap()*2)) 253 if (delta <= static_cast<uint64>(GetGap()*2))
257 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. 254 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate.
258 else if (lo == GetFirstPosition()) 255 else if (lo == GetFirstPosition())
259 return hi - GetGap(); // Extend range just before successor. 256 return hi - GetGap(); // Extend range just before successor.
260 else 257 else
261 return lo + GetGap(); // Use or extend range just after predecessor. 258 return lo + GetGap(); // Use or extend range just after predecessor.
262 } 259 }
263 260
264 261
265 } // namespace browser_sync 262 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_ui_util.cc ('k') | sync/engine/commit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698