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

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

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 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
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
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/tracked.h"
12 #include "chrome/browser/sync/engine/syncer.h" 13 #include "chrome/browser/sync/engine/syncer.h"
13 #include "chrome/browser/sync/engine/syncer_util.h" 14 #include "chrome/browser/sync/engine/syncer_util.h"
14 #include "chrome/browser/sync/protocol/service_constants.h" 15 #include "chrome/browser/sync/protocol/service_constants.h"
15 #include "chrome/browser/sync/sessions/status_controller.h" 16 #include "chrome/browser/sync/sessions/status_controller.h"
16 #include "chrome/browser/sync/syncable/directory_manager.h" 17 #include "chrome/browser/sync/syncable/directory_manager.h"
17 #include "chrome/browser/sync/syncable/syncable.h" 18 #include "chrome/browser/sync/syncable/syncable.h"
18 #include "chrome/common/deprecated/event_sys-inl.h" 19 #include "chrome/common/deprecated/event_sys-inl.h"
19 20
20 using std::map; 21 using std::map;
21 using std::set; 22 using std::set;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 UMA_HISTOGRAM_COUNTS("Sync.SyncerConflictStuck", 1); 426 UMA_HISTOGRAM_COUNTS("Sync.SyncerConflictStuck", 1);
426 427
427 return true; 428 return true;
428 // TODO(sync): If we're stuck for a while we need to alert the user, clear 429 // TODO(sync): If we're stuck for a while we need to alert the user, clear
429 // cache or reset syncing. At the very least we should stop trying something 430 // cache or reset syncing. At the very least we should stop trying something
430 // that's obviously not working. 431 // that's obviously not working.
431 } 432 }
432 433
433 bool ConflictResolver::ResolveSimpleConflicts(const ScopedDirLookup& dir, 434 bool ConflictResolver::ResolveSimpleConflicts(const ScopedDirLookup& dir,
434 StatusController* status) { 435 StatusController* status) {
435 WriteTransaction trans(dir, syncable::SYNCER, __FILE__, __LINE__); 436 WriteTransaction trans(dir, syncable::SYNCER, FROM_HERE);
436 bool forward_progress = false; 437 bool forward_progress = false;
437 const ConflictProgress& progress = status->conflict_progress(); 438 const ConflictProgress& progress = status->conflict_progress();
438 // First iterate over simple conflict items (those that belong to no set). 439 // First iterate over simple conflict items (those that belong to no set).
439 set<Id>::const_iterator conflicting_item_it; 440 set<Id>::const_iterator conflicting_item_it;
440 for (conflicting_item_it = progress.ConflictingItemsBeginConst(); 441 for (conflicting_item_it = progress.ConflictingItemsBeginConst();
441 conflicting_item_it != progress.ConflictingItemsEnd(); 442 conflicting_item_it != progress.ConflictingItemsEnd();
442 ++conflicting_item_it) { 443 ++conflicting_item_it) {
443 Id id = *conflicting_item_it; 444 Id id = *conflicting_item_it;
444 map<Id, ConflictSet*>::const_iterator item_set_it = 445 map<Id, ConflictSet*>::const_iterator item_set_it =
445 progress.IdToConflictSetFind(id); 446 progress.IdToConflictSetFind(id);
(...skipping 24 matching lines...) Expand all
470 } 471 }
471 return forward_progress; 472 return forward_progress;
472 } 473 }
473 474
474 bool ConflictResolver::ResolveConflicts(const ScopedDirLookup& dir, 475 bool ConflictResolver::ResolveConflicts(const ScopedDirLookup& dir,
475 StatusController* status) { 476 StatusController* status) {
476 const ConflictProgress& progress = status->conflict_progress(); 477 const ConflictProgress& progress = status->conflict_progress();
477 bool rv = false; 478 bool rv = false;
478 if (ResolveSimpleConflicts(dir, status)) 479 if (ResolveSimpleConflicts(dir, status))
479 rv = true; 480 rv = true;
480 WriteTransaction trans(dir, syncable::SYNCER, __FILE__, __LINE__); 481 WriteTransaction trans(dir, syncable::SYNCER, FROM_HERE);
481 set<ConflictSet*>::const_iterator set_it; 482 set<ConflictSet*>::const_iterator set_it;
482 for (set_it = progress.ConflictSetsBegin(); 483 for (set_it = progress.ConflictSetsBegin();
483 set_it != progress.ConflictSetsEnd(); 484 set_it != progress.ConflictSetsEnd();
484 set_it++) { 485 set_it++) {
485 ConflictSet* conflict_set = *set_it; 486 ConflictSet* conflict_set = *set_it;
486 ConflictSetCountMapKey key = GetSetKey(conflict_set); 487 ConflictSetCountMapKey key = GetSetKey(conflict_set);
487 conflict_set_count_map_[key] += 2; 488 conflict_set_count_map_[key] += 2;
488 int conflict_count = conflict_set_count_map_[key]; 489 int conflict_count = conflict_set_count_map_[key];
489 // Keep a metric for new sets. 490 // Keep a metric for new sets.
490 if (2 == conflict_count) { 491 if (2 == conflict_count) {
(...skipping 22 matching lines...) Expand all
513 conflict_set_count_map_.erase(i++); 514 conflict_set_count_map_.erase(i++);
514 // METRIC self resolved conflict sets ++. 515 // METRIC self resolved conflict sets ++.
515 } else { 516 } else {
516 ++i; 517 ++i;
517 } 518 }
518 } 519 }
519 return rv; 520 return rv;
520 } 521 }
521 522
522 } // namespace browser_sync 523 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698