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

Side by Side Diff: chrome/browser/sync/engine/conflict_resolver.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/conflict_resolver.h" 5 #include "chrome/browser/sync/engine/conflict_resolver.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 448
449 status->set_syncer_stuck(true); 449 status->set_syncer_stuck(true);
450 UMA_HISTOGRAM_COUNTS("Sync.SyncerConflictStuck", 1); 450 UMA_HISTOGRAM_COUNTS("Sync.SyncerConflictStuck", 1);
451 451
452 return true; 452 return true;
453 // TODO(sync): If we're stuck for a while we need to alert the user, clear 453 // TODO(sync): If we're stuck for a while we need to alert the user, clear
454 // cache or reset syncing. At the very least we should stop trying something 454 // cache or reset syncing. At the very least we should stop trying something
455 // that's obviously not working. 455 // that's obviously not working.
456 } 456 }
457 457
458 bool ConflictResolver::ResolveSimpleConflicts(const ScopedDirLookup& dir, 458 bool ConflictResolver::ResolveSimpleConflicts(
459 StatusController* status) { 459 const ScopedDirLookup& dir,
460 const ConflictProgress& progress,
461 sessions::StatusController* status) {
460 WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); 462 WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
461 bool forward_progress = false; 463 bool forward_progress = false;
462 const ConflictProgress& progress = status->conflict_progress();
463 // First iterate over simple conflict items (those that belong to no set). 464 // First iterate over simple conflict items (those that belong to no set).
464 set<Id>::const_iterator conflicting_item_it; 465 set<Id>::const_iterator conflicting_item_it;
465 for (conflicting_item_it = progress.ConflictingItemsBeginConst(); 466 for (conflicting_item_it = progress.ConflictingItemsBegin();
466 conflicting_item_it != progress.ConflictingItemsEnd(); 467 conflicting_item_it != progress.ConflictingItemsEnd();
467 ++conflicting_item_it) { 468 ++conflicting_item_it) {
468 Id id = *conflicting_item_it; 469 Id id = *conflicting_item_it;
469 map<Id, ConflictSet*>::const_iterator item_set_it = 470 map<Id, ConflictSet*>::const_iterator item_set_it =
470 progress.IdToConflictSetFind(id); 471 progress.IdToConflictSetFind(id);
471 if (item_set_it == progress.IdToConflictSetEnd() || 472 if (item_set_it == progress.IdToConflictSetEnd() ||
472 0 == item_set_it->second) { 473 0 == item_set_it->second) {
473 // We have a simple conflict. 474 // We have a simple conflict.
474 switch (ProcessSimpleConflict(&trans, id, status)) { 475 switch (ProcessSimpleConflict(&trans, id, status)) {
475 case NO_SYNC_PROGRESS: 476 case NO_SYNC_PROGRESS:
(...skipping 14 matching lines...) Expand all
490 while (i != simple_conflict_count_map_.end()) { 491 while (i != simple_conflict_count_map_.end()) {
491 if (0 == --(i->second)) 492 if (0 == --(i->second))
492 simple_conflict_count_map_.erase(i++); 493 simple_conflict_count_map_.erase(i++);
493 else 494 else
494 ++i; 495 ++i;
495 } 496 }
496 return forward_progress; 497 return forward_progress;
497 } 498 }
498 499
499 bool ConflictResolver::ResolveConflicts(const ScopedDirLookup& dir, 500 bool ConflictResolver::ResolveConflicts(const ScopedDirLookup& dir,
500 StatusController* status) { 501 const ConflictProgress& progress,
501 const ConflictProgress& progress = status->conflict_progress(); 502 sessions::StatusController* status) {
502 bool rv = false; 503 bool rv = false;
503 if (ResolveSimpleConflicts(dir, status)) 504 if (ResolveSimpleConflicts(dir, progress, status))
504 rv = true; 505 rv = true;
505 WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); 506 WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
506 set<ConflictSet*>::const_iterator set_it; 507 set<ConflictSet*>::const_iterator set_it;
507 for (set_it = progress.ConflictSetsBegin(); 508 for (set_it = progress.ConflictSetsBegin();
508 set_it != progress.ConflictSetsEnd(); 509 set_it != progress.ConflictSetsEnd();
509 set_it++) { 510 set_it++) {
510 ConflictSet* conflict_set = *set_it; 511 ConflictSet* conflict_set = *set_it;
511 ConflictSetCountMapKey key = GetSetKey(conflict_set); 512 ConflictSetCountMapKey key = GetSetKey(conflict_set);
512 conflict_set_count_map_[key] += 2; 513 conflict_set_count_map_[key] += 2;
513 int conflict_count = conflict_set_count_map_[key]; 514 int conflict_count = conflict_set_count_map_[key];
(...skipping 24 matching lines...) Expand all
538 conflict_set_count_map_.erase(i++); 539 conflict_set_count_map_.erase(i++);
539 // METRIC self resolved conflict sets ++. 540 // METRIC self resolved conflict sets ++.
540 } else { 541 } else {
541 ++i; 542 ++i;
542 } 543 }
543 } 544 }
544 return rv; 545 return rv;
545 } 546 }
546 547
547 } // namespace browser_sync 548 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/conflict_resolver.h ('k') | chrome/browser/sync/engine/download_updates_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698