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

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

Issue 9036003: Avoid useless SYNC_CYCLE_CONTINUATION sync cycle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
OLDNEW
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>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 namespace { 78 namespace {
79 void SetEntrySpecifics(MutableEntry* meta_entry, SyncEntity* sync_entry) { 79 void SetEntrySpecifics(MutableEntry* meta_entry, SyncEntity* sync_entry) {
80 // Add the new style extension and the folder bit. 80 // Add the new style extension and the folder bit.
81 sync_entry->mutable_specifics()->CopyFrom(meta_entry->Get(SPECIFICS)); 81 sync_entry->mutable_specifics()->CopyFrom(meta_entry->Get(SPECIFICS));
82 sync_entry->set_folder(meta_entry->Get(syncable::IS_DIR)); 82 sync_entry->set_folder(meta_entry->Get(syncable::IS_DIR));
83 83
84 DCHECK(meta_entry->GetModelType() == sync_entry->GetModelType()); 84 DCHECK(meta_entry->GetModelType() == sync_entry->GetModelType());
85 } 85 }
86 } // namespace 86 } // namespace
87 87
88 void BuildCommitCommand::ExecuteImpl(SyncSession* session) { 88 SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
89 ClientToServerMessage message; 89 ClientToServerMessage message;
90 message.set_share(session->context()->account_name()); 90 message.set_share(session->context()->account_name());
91 message.set_message_contents(ClientToServerMessage::COMMIT); 91 message.set_message_contents(ClientToServerMessage::COMMIT);
92 92
93 CommitMessage* commit_message = message.mutable_commit(); 93 CommitMessage* commit_message = message.mutable_commit();
94 commit_message->set_cache_guid( 94 commit_message->set_cache_guid(
95 session->write_transaction()->directory()->cache_guid()); 95 session->write_transaction()->directory()->cache_guid());
96 AddExtensionsActivityToMessage(session, commit_message); 96 AddExtensionsActivityToMessage(session, commit_message);
97 SyncerProtoUtil::AddRequestBirthday( 97 SyncerProtoUtil::AddRequestBirthday(
98 session->write_transaction()->directory(), &message); 98 session->write_transaction()->directory(), &message);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 position_block.second); 203 position_block.second);
204 204
205 position_map[id] = position_block; 205 position_map[id] = position_block;
206 sync_entry->set_position_in_parent(position_block.first); 206 sync_entry->set_position_in_parent(position_block.first);
207 } 207 }
208 SetEntrySpecifics(&meta_entry, sync_entry); 208 SetEntrySpecifics(&meta_entry, sync_entry);
209 } 209 }
210 } 210 }
211 session->mutable_status_controller()-> 211 session->mutable_status_controller()->
212 mutable_commit_message()->CopyFrom(message); 212 mutable_commit_message()->CopyFrom(message);
213
214 return NO_ERROR;
213 } 215 }
214 216
215 int64 BuildCommitCommand::FindAnchorPosition(syncable::IdField direction, 217 int64 BuildCommitCommand::FindAnchorPosition(syncable::IdField direction,
216 const syncable::Entry& entry) { 218 const syncable::Entry& entry) {
217 Id next_id = entry.Get(direction); 219 Id next_id = entry.Get(direction);
218 while (!next_id.IsRoot()) { 220 while (!next_id.IsRoot()) {
219 Entry next_entry(entry.trans(), 221 Entry next_entry(entry.trans(),
220 syncable::GET_BY_ID, 222 syncable::GET_BY_ID,
221 next_id); 223 next_id);
222 if (!next_entry.Get(IS_UNSYNCED) && !next_entry.Get(IS_UNAPPLIED_UPDATE)) { 224 if (!next_entry.Get(IS_UNSYNCED) && !next_entry.Get(IS_UNAPPLIED_UPDATE)) {
(...skipping 21 matching lines...) Expand all
244 if (delta <= static_cast<uint64>(GetGap()*2)) 246 if (delta <= static_cast<uint64>(GetGap()*2))
245 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. 247 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate.
246 else if (lo == GetFirstPosition()) 248 else if (lo == GetFirstPosition())
247 return hi - GetGap(); // Extend range just before successor. 249 return hi - GetGap(); // Extend range just before successor.
248 else 250 else
249 return lo + GetGap(); // Use or extend range just after predecessor. 251 return lo + GetGap(); // Use or extend range just after predecessor.
250 } 252 }
251 253
252 254
253 } // namespace browser_sync 255 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/build_commit_command.h ('k') | chrome/browser/sync/engine/cleanup_disabled_types_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698