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/syncable/directory.cc

Issue 11958029: [Sync] Add support for proxy types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to ProxyTypes Created 7 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/syncable/directory.h" 5 #include "sync/syncable/directory.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/perftimer.h" 8 #include "base/perftimer.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void Directory::InitKernelForTest( 74 void Directory::InitKernelForTest(
75 const std::string& name, 75 const std::string& name,
76 DirectoryChangeDelegate* delegate, 76 DirectoryChangeDelegate* delegate,
77 const WeakHandle<TransactionObserver>& transaction_observer) { 77 const WeakHandle<TransactionObserver>& transaction_observer) {
78 DCHECK(!kernel_); 78 DCHECK(!kernel_);
79 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer); 79 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer);
80 } 80 }
81 81
82 Directory::PersistedKernelInfo::PersistedKernelInfo() 82 Directory::PersistedKernelInfo::PersistedKernelInfo()
83 : next_id(0) { 83 : next_id(0) {
84 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 84 ModelTypeSet protocol_types = ProtocolTypes();
85 reset_download_progress(ModelTypeFromInt(i)); 85 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
86 transaction_version[i] = 0; 86 iter.Inc()) {
87 reset_download_progress(iter.Get());
88 transaction_version[iter.Get()] = 0;
87 } 89 }
88 } 90 }
89 91
90 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} 92 Directory::PersistedKernelInfo::~PersistedKernelInfo() {}
91 93
92 void Directory::PersistedKernelInfo::reset_download_progress( 94 void Directory::PersistedKernelInfo::reset_download_progress(
93 ModelType model_type) { 95 ModelType model_type) {
94 download_progress[model_type].set_data_type_id( 96 download_progress[model_type].set_data_type_id(
95 GetSpecificsFieldNumberFromModelType(model_type)); 97 GetSpecificsFieldNumberFromModelType(model_type));
96 // An empty-string token indicates no prior knowledge. 98 // An empty-string token indicates no prior knowledge.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 delete entry; 558 delete entry;
557 } 559 }
558 if (trans.unrecoverable_error_set()) 560 if (trans.unrecoverable_error_set())
559 return false; 561 return false;
560 } 562 }
561 return true; 563 return true;
562 } 564 }
563 565
564 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet types, 566 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet types,
565 ModelTypeSet types_to_journal) { 567 ModelTypeSet types_to_journal) {
568 types.RemoveAll(ProxyTypes());
569
566 if (types.Empty()) 570 if (types.Empty())
567 return true; 571 return true;
568 572
569 { 573 {
570 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); 574 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this);
571 575
572 EntryKernelSet entries_to_journal; 576 EntryKernelSet entries_to_journal;
573 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal); 577 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal);
574 578
575 { 579 {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return kernel_->persisted_info.transaction_version[type]; 699 return kernel_->persisted_info.transaction_version[type];
696 } 700 }
697 701
698 void Directory::IncrementTransactionVersion(ModelType type) { 702 void Directory::IncrementTransactionVersion(ModelType type) {
699 kernel_->transaction_mutex.AssertAcquired(); 703 kernel_->transaction_mutex.AssertAcquired();
700 kernel_->persisted_info.transaction_version[type]++; 704 kernel_->persisted_info.transaction_version[type]++;
701 } 705 }
702 706
703 ModelTypeSet Directory::InitialSyncEndedTypes() { 707 ModelTypeSet Directory::InitialSyncEndedTypes() {
704 syncable::ReadTransaction trans(FROM_HERE, this); 708 syncable::ReadTransaction trans(FROM_HERE, this);
705 const ModelTypeSet all_types = ModelTypeSet::All(); 709 ModelTypeSet protocol_types = ProtocolTypes();
706 ModelTypeSet initial_sync_ended_types; 710 ModelTypeSet initial_sync_ended_types;
707 for (ModelTypeSet::Iterator i = all_types.First(); i.Good(); i.Inc()) { 711 for (ModelTypeSet::Iterator i = protocol_types.First(); i.Good(); i.Inc()) {
708 if (InitialSyncEndedForType(&trans, i.Get())) { 712 if (InitialSyncEndedForType(&trans, i.Get())) {
709 initial_sync_ended_types.Put(i.Get()); 713 initial_sync_ended_types.Put(i.Get());
710 } 714 }
711 } 715 }
712 return initial_sync_ended_types; 716 return initial_sync_ended_types;
713 } 717 }
714 718
715 bool Directory::InitialSyncEndedForType(ModelType type) { 719 bool Directory::InitialSyncEndedForType(ModelType type) {
716 syncable::ReadTransaction trans(FROM_HERE, this); 720 syncable::ReadTransaction trans(FROM_HERE, this);
717 return InitialSyncEndedForType(&trans, type); 721 return InitialSyncEndedForType(&trans, type);
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 // There were no children in the linked list. 1285 // There were no children in the linked list.
1282 return NULL; 1286 return NULL;
1283 } 1287 }
1284 1288
1285 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1289 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1286 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1290 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1287 } 1291 }
1288 1292
1289 } // namespace syncable 1293 } // namespace syncable
1290 } // namespace syncer 1294 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl_unittest.cc ('k') | sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698