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

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

Issue 8638001: [Sync] Made some sync session member functions const (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix latent bug in StatusController Created 9 years, 1 month 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 BuildCommitCommand::BuildCommitCommand() {} 52 BuildCommitCommand::BuildCommitCommand() {}
53 BuildCommitCommand::~BuildCommitCommand() {} 53 BuildCommitCommand::~BuildCommitCommand() {}
54 54
55 void BuildCommitCommand::AddExtensionsActivityToMessage( 55 void BuildCommitCommand::AddExtensionsActivityToMessage(
56 SyncSession* session, CommitMessage* message) { 56 SyncSession* session, CommitMessage* message) {
57 // We only send ExtensionsActivity to the server if bookmarks are being 57 // We only send ExtensionsActivity to the server if bookmarks are being
58 // committed. 58 // committed.
59 ExtensionsActivityMonitor* monitor = session->context()->extensions_monitor(); 59 ExtensionsActivityMonitor* monitor = session->context()->extensions_monitor();
60 if (!session->status_controller()->HasBookmarkCommitActivity()) { 60 if (!session->status_controller().HasBookmarkCommitActivity()) {
61 // Return the records to the activity monitor. 61 // Return the records to the activity monitor.
62 monitor->PutRecords(session->extensions_activity()); 62 monitor->PutRecords(session->extensions_activity());
63 session->mutable_extensions_activity()->clear(); 63 session->mutable_extensions_activity()->clear();
64 return; 64 return;
65 } 65 }
66 const ExtensionsActivityMonitor::Records& records = 66 const ExtensionsActivityMonitor::Records& records =
67 session->extensions_activity(); 67 session->extensions_activity();
68 for (ExtensionsActivityMonitor::Records::const_iterator it = records.begin(); 68 for (ExtensionsActivityMonitor::Records::const_iterator it = records.begin();
69 it != records.end(); ++it) { 69 it != records.end(); ++it) {
70 sync_pb::ChromiumExtensionsActivity* activity_message = 70 sync_pb::ChromiumExtensionsActivity* activity_message =
(...skipping 27 matching lines...) Expand all
98 session->write_transaction()->directory(), &message); 98 session->write_transaction()->directory(), &message);
99 99
100 // Cache previously computed position values. Because |commit_ids| 100 // Cache previously computed position values. Because |commit_ids|
101 // is already in sibling order, we should always hit this map after 101 // is already in sibling order, we should always hit this map after
102 // the first sibling in a consecutive run of commit items. The 102 // the first sibling in a consecutive run of commit items. The
103 // entries in this map are (low, high) values describing the 103 // entries in this map are (low, high) values describing the
104 // space of positions that are immediate successors of the item 104 // space of positions that are immediate successors of the item
105 // whose ID is the map's key. 105 // whose ID is the map's key.
106 std::map<Id, std::pair<int64, int64> > position_map; 106 std::map<Id, std::pair<int64, int64> > position_map;
107 107
108 const vector<Id>& commit_ids = session->status_controller()->commit_ids(); 108 const vector<Id>& commit_ids = session->status_controller().commit_ids();
109 for (size_t i = 0; i < commit_ids.size(); i++) { 109 for (size_t i = 0; i < commit_ids.size(); i++) {
110 Id id = commit_ids[i]; 110 Id id = commit_ids[i];
111 SyncEntity* sync_entry = 111 SyncEntity* sync_entry =
112 static_cast<SyncEntity*>(commit_message->add_entries()); 112 static_cast<SyncEntity*>(commit_message->add_entries());
113 sync_entry->set_id(id); 113 sync_entry->set_id(id);
114 MutableEntry meta_entry(session->write_transaction(), 114 MutableEntry meta_entry(session->write_transaction(),
115 syncable::GET_BY_ID, 115 syncable::GET_BY_ID,
116 id); 116 id);
117 CHECK(meta_entry.good()); 117 CHECK(meta_entry.good());
118 // This is the only change we make to the entry in this function. 118 // This is the only change we make to the entry in this function.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 position_block.first = InterpolatePosition(position_block.first, 202 position_block.first = InterpolatePosition(position_block.first,
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->status_controller()->mutable_commit_message()->CopyFrom(message); 211 session->mutable_status_controller()->
212 mutable_commit_message()->CopyFrom(message);
212 } 213 }
213 214
214 int64 BuildCommitCommand::FindAnchorPosition(syncable::IdField direction, 215 int64 BuildCommitCommand::FindAnchorPosition(syncable::IdField direction,
215 const syncable::Entry& entry) { 216 const syncable::Entry& entry) {
216 Id next_id = entry.Get(direction); 217 Id next_id = entry.Get(direction);
217 while (!next_id.IsRoot()) { 218 while (!next_id.IsRoot()) {
218 Entry next_entry(entry.trans(), 219 Entry next_entry(entry.trans(),
219 syncable::GET_BY_ID, 220 syncable::GET_BY_ID,
220 next_id); 221 next_id);
221 if (!next_entry.Get(IS_UNSYNCED) && !next_entry.Get(IS_UNAPPLIED_UPDATE)) { 222 if (!next_entry.Get(IS_UNSYNCED) && !next_entry.Get(IS_UNAPPLIED_UPDATE)) {
(...skipping 21 matching lines...) Expand all
243 if (delta <= static_cast<uint64>(GetGap()*2)) 244 if (delta <= static_cast<uint64>(GetGap()*2))
244 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate. 245 return lo + (static_cast<int64>(delta) + 7) / 8; // Interpolate.
245 else if (lo == GetFirstPosition()) 246 else if (lo == GetFirstPosition())
246 return hi - GetGap(); // Extend range just before successor. 247 return hi - GetGap(); // Extend range just before successor.
247 else 248 else
248 return lo + GetGap(); // Use or extend range just after predecessor. 249 return lo + GetGap(); // Use or extend range just after predecessor.
249 } 250 }
250 251
251 252
252 } // namespace browser_sync 253 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/build_and_process_conflict_sets_command.cc ('k') | chrome/browser/sync/engine/conflict_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698