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

Side by Side Diff: chrome/browser/sync/engine/syncer_util.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/syncer_util.h" 5 #include "chrome/browser/sync/engine/syncer_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/tracked.h"
12 #include "chrome/browser/sync/engine/conflict_resolver.h" 13 #include "chrome/browser/sync/engine/conflict_resolver.h"
13 #include "chrome/browser/sync/engine/syncer_proto_util.h" 14 #include "chrome/browser/sync/engine/syncer_proto_util.h"
14 #include "chrome/browser/sync/engine/syncer_types.h" 15 #include "chrome/browser/sync/engine/syncer_types.h"
15 #include "chrome/browser/sync/engine/syncproto.h" 16 #include "chrome/browser/sync/engine/syncproto.h"
16 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 17 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
17 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 18 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
18 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 19 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
19 #include "chrome/browser/sync/protocol/sync.pb.h" 20 #include "chrome/browser/sync/protocol/sync.pb.h"
20 #include "chrome/browser/sync/syncable/directory_manager.h" 21 #include "chrome/browser/sync/syncable/directory_manager.h"
21 #include "chrome/browser/sync/syncable/model_type.h" 22 #include "chrome/browser/sync/syncable/model_type.h"
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 // 1. Scan deleted unsynced entries looking up their pre-delete tree for any 653 // 1. Scan deleted unsynced entries looking up their pre-delete tree for any
653 // of the deleted folders. 654 // of the deleted folders.
654 // 2. Take each folder and do a tree walk of all entries underneath it. 655 // 2. Take each folder and do a tree walk of all entries underneath it.
655 // #2 has a lower big O cost, but writing code to limit the time spent inside 656 // #2 has a lower big O cost, but writing code to limit the time spent inside
656 // the transaction during each step is simpler with 1. Changing this decision 657 // the transaction during each step is simpler with 1. Changing this decision
657 // may be sensible if this code shows up in profiling. 658 // may be sensible if this code shows up in profiling.
658 if (deleted_folders->empty()) 659 if (deleted_folders->empty())
659 return; 660 return;
660 Directory::UnsyncedMetaHandles handles; 661 Directory::UnsyncedMetaHandles handles;
661 { 662 {
662 ReadTransaction trans(dir, __FILE__, __LINE__); 663 ReadTransaction trans(dir, FROM_HERE);
663 dir->GetUnsyncedMetaHandles(&trans, &handles); 664 dir->GetUnsyncedMetaHandles(&trans, &handles);
664 } 665 }
665 if (handles.empty()) 666 if (handles.empty())
666 return; 667 return;
667 Directory::UnsyncedMetaHandles::iterator it; 668 Directory::UnsyncedMetaHandles::iterator it;
668 for (it = handles.begin() ; it != handles.end() ; ++it) { 669 for (it = handles.begin() ; it != handles.end() ; ++it) {
669 // Single transaction / entry we deal with. 670 // Single transaction / entry we deal with.
670 WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__); 671 WriteTransaction trans(dir, SYNCER, FROM_HERE);
671 MutableEntry entry(&trans, GET_BY_HANDLE, *it); 672 MutableEntry entry(&trans, GET_BY_HANDLE, *it);
672 if (!entry.Get(IS_UNSYNCED) || !entry.Get(IS_DEL)) 673 if (!entry.Get(IS_UNSYNCED) || !entry.Get(IS_DEL))
673 continue; 674 continue;
674 syncable::Id id = entry.Get(PARENT_ID); 675 syncable::Id id = entry.Get(PARENT_ID);
675 while (id != trans.root_id()) { 676 while (id != trans.root_id()) {
676 if (deleted_folders->find(id) != deleted_folders->end()) { 677 if (deleted_folders->find(id) != deleted_folders->end()) {
677 // We've synced the deletion of this deleted entries parent. 678 // We've synced the deletion of this deleted entries parent.
678 entry.Put(IS_UNSYNCED, false); 679 entry.Put(IS_UNSYNCED, false);
679 break; 680 break;
680 } 681 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (update.version() < target->Get(SERVER_VERSION)) { 821 if (update.version() < target->Get(SERVER_VERSION)) {
821 LOG(WARNING) << "Update older than current server version for " 822 LOG(WARNING) << "Update older than current server version for "
822 << *target << " Update:" 823 << *target << " Update:"
823 << SyncerProtoUtil::SyncEntityDebugString(update); 824 << SyncerProtoUtil::SyncEntityDebugString(update);
824 return VERIFY_SUCCESS; // Expected in new sync protocol. 825 return VERIFY_SUCCESS; // Expected in new sync protocol.
825 } 826 }
826 return VERIFY_UNDECIDED; 827 return VERIFY_UNDECIDED;
827 } 828 }
828 829
829 } // namespace browser_sync 830 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_unittest.cc ('k') | chrome/browser/sync/engine/verify_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698