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

Side by Side Diff: sync/sessions/session_state.cc

Issue 9950137: [not for review] sync: Don't use group_restriction from ApplyUpdatesCommand. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | « sync/sessions/session_state.h ('k') | sync/sessions/status_controller.h » ('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/sessions/session_state.h" 5 #include "sync/sessions/session_state.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base64.h" 13 #include "base/base64.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "sync/engine/model_safe_worker.h"
17 #include "sync/protocol/proto_enum_conversions.h" 18 #include "sync/protocol/proto_enum_conversions.h"
18 19
19 using std::set; 20 using std::set;
20 using std::vector; 21 using std::vector;
21 22
22 namespace browser_sync { 23 namespace browser_sync {
23 namespace sessions { 24 namespace sessions {
24 25
25 SyncSourceInfo::SyncSourceInfo() 26 SyncSourceInfo::SyncSourceInfo()
26 : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {} 27 : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {}
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void ConflictProgress::AddServerConflictingItemById( 248 void ConflictProgress::AddServerConflictingItemById(
248 const syncable::Id& the_id) { 249 const syncable::Id& the_id) {
249 std::pair<std::set<syncable::Id>::iterator, bool> ret = 250 std::pair<std::set<syncable::Id>::iterator, bool> ret =
250 unresolvable_conflicting_item_ids_.insert(the_id); 251 unresolvable_conflicting_item_ids_.insert(the_id);
251 if (ret.second) { 252 if (ret.second) {
252 num_server_conflicting_items++; 253 num_server_conflicting_items++;
253 *dirty_ = true; 254 *dirty_ = true;
254 } 255 }
255 } 256 }
256 257
257 UpdateProgress::UpdateProgress() {} 258 UpdateProgress::UpdateProgress(ModelSafeGroup group,
259 const ModelSafeRoutingInfo& routes)
260 : types_in_model_safe_group_(GetModelTypesForGroup(group, routes)) {
261 }
258 262
259 UpdateProgress::~UpdateProgress() {} 263 UpdateProgress::~UpdateProgress() {}
260 264
261 void UpdateProgress::AddVerifyResult(const VerifyResult& verify_result, 265 void UpdateProgress::AddVerifyResult(const VerifyResult& verify_result,
262 const sync_pb::SyncEntity& entity) { 266 const sync_pb::SyncEntity& entity) {
263 verified_updates_.push_back(std::make_pair(verify_result, entity)); 267 verified_updates_.push_back(std::make_pair(verify_result, entity));
264 } 268 }
265 269
266 void UpdateProgress::AddAppliedUpdate(const UpdateAttemptResponse& response, 270 void UpdateProgress::AddAppliedUpdate(const UpdateAttemptResponse& response,
267 const syncable::Id& id) { 271 const syncable::Id& id) {
268 applied_updates_.push_back(std::make_pair(response, id)); 272 applied_updates_.push_back(std::make_pair(response, id));
269 } 273 }
270 274
271 std::vector<AppliedUpdate>::iterator UpdateProgress::AppliedUpdatesBegin() { 275 void UpdateProgress::CollectUpdatesToApply(
272 return applied_updates_.begin(); 276 syncable::Directory* dir,
277 syncable::BaseTransaction* trans) {
278 dir->GetUnappliedUpdateMetaHandles(trans,
279 types_in_model_safe_group_,
280 &unapplied_updates_);
273 } 281 }
274 282
275 std::vector<VerifiedUpdate>::const_iterator 283 std::vector<VerifiedUpdate>::const_iterator
276 UpdateProgress::VerifiedUpdatesBegin() const { 284 UpdateProgress::VerifiedUpdatesBegin() const {
277 return verified_updates_.begin(); 285 return verified_updates_.begin();
278 } 286 }
279 287
280 std::vector<AppliedUpdate>::const_iterator
281 UpdateProgress::AppliedUpdatesEnd() const {
282 return applied_updates_.end();
283 }
284
285 std::vector<VerifiedUpdate>::const_iterator 288 std::vector<VerifiedUpdate>::const_iterator
286 UpdateProgress::VerifiedUpdatesEnd() const { 289 UpdateProgress::VerifiedUpdatesEnd() const {
287 return verified_updates_.end(); 290 return verified_updates_.end();
288 } 291 }
289 292
290 int UpdateProgress::SuccessfullyAppliedUpdateCount() const { 293 int UpdateProgress::SuccessfullyAppliedUpdateCount() const {
291 int count = 0; 294 int count = 0;
292 for (std::vector<AppliedUpdate>::const_iterator it = 295 for (std::vector<AppliedUpdate>::const_iterator it =
293 applied_updates_.begin(); 296 applied_updates_.begin();
294 it != applied_updates_.end(); 297 it != applied_updates_.end();
(...skipping 19 matching lines...) Expand all
314 AllModelTypeState::AllModelTypeState(bool* dirty_flag) 317 AllModelTypeState::AllModelTypeState(bool* dirty_flag)
315 : unsynced_handles(dirty_flag), 318 : unsynced_handles(dirty_flag),
316 syncer_status(dirty_flag), 319 syncer_status(dirty_flag),
317 error(dirty_flag), 320 error(dirty_flag),
318 num_server_changes_remaining(dirty_flag, 0), 321 num_server_changes_remaining(dirty_flag, 0),
319 commit_set(ModelSafeRoutingInfo()) { 322 commit_set(ModelSafeRoutingInfo()) {
320 } 323 }
321 324
322 AllModelTypeState::~AllModelTypeState() {} 325 AllModelTypeState::~AllModelTypeState() {}
323 326
324 PerModelSafeGroupState::PerModelSafeGroupState(bool* dirty_flag) 327 PerModelSafeGroupState::PerModelSafeGroupState(
325 : conflict_progress(dirty_flag) { 328 bool* dirty_flag,
329 ModelSafeGroup group,
330 const ModelSafeRoutingInfo& routes)
331 : update_progress(group, routes), conflict_progress(dirty_flag) {
326 } 332 }
327 333
328 PerModelSafeGroupState::~PerModelSafeGroupState() { 334 PerModelSafeGroupState::~PerModelSafeGroupState() {
329 } 335 }
330 336
331 } // namespace sessions 337 } // namespace sessions
332 } // namespace browser_sync 338 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/sessions/session_state.h ('k') | sync/sessions/status_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698