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

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: Cleanup 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
85 reset_download_progress(ModelTypeFromInt(i)); 85 ModelType type = ModelTypeFromInt(i);
86 if (VirtualTypes().Has(type))
87 continue;
88 reset_download_progress(type);
86 transaction_version[i] = 0; 89 transaction_version[i] = 0;
87 } 90 }
88 } 91 }
89 92
90 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} 93 Directory::PersistedKernelInfo::~PersistedKernelInfo() {}
91 94
92 void Directory::PersistedKernelInfo::reset_download_progress( 95 void Directory::PersistedKernelInfo::reset_download_progress(
93 ModelType model_type) { 96 ModelType model_type) {
94 download_progress[model_type].set_data_type_id( 97 download_progress[model_type].set_data_type_id(
95 GetSpecificsFieldNumberFromModelType(model_type)); 98 GetSpecificsFieldNumberFromModelType(model_type));
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 560 }
558 if (trans.unrecoverable_error_set()) 561 if (trans.unrecoverable_error_set())
559 return false; 562 return false;
560 } 563 }
561 return true; 564 return true;
562 } 565 }
563 566
564 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet types, 567 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet types,
565 ModelTypeSet types_to_journal) { 568 ModelTypeSet types_to_journal) {
566 DCHECK(types.HasAll(types_to_journal)); 569 DCHECK(types.HasAll(types_to_journal));
570 types.RemoveAll(VirtualTypes());
567 571
568 if (types.Empty()) 572 if (types.Empty())
569 return true; 573 return true;
570 574
571 { 575 {
572 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); 576 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this);
573 577
574 EntryKernelSet entries_to_journal; 578 EntryKernelSet entries_to_journal;
575 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal); 579 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal);
576 580
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return kernel_->persisted_info.transaction_version[type]; 701 return kernel_->persisted_info.transaction_version[type];
698 } 702 }
699 703
700 void Directory::IncrementTransactionVersion(ModelType type) { 704 void Directory::IncrementTransactionVersion(ModelType type) {
701 kernel_->transaction_mutex.AssertAcquired(); 705 kernel_->transaction_mutex.AssertAcquired();
702 kernel_->persisted_info.transaction_version[type]++; 706 kernel_->persisted_info.transaction_version[type]++;
703 } 707 }
704 708
705 ModelTypeSet Directory::InitialSyncEndedTypes() { 709 ModelTypeSet Directory::InitialSyncEndedTypes() {
706 syncable::ReadTransaction trans(FROM_HERE, this); 710 syncable::ReadTransaction trans(FROM_HERE, this);
707 const ModelTypeSet all_types = ModelTypeSet::All(); 711 ModelTypeSet all_types = ModelTypeSet::All();
712 all_types.RemoveAll(VirtualTypes());
708 ModelTypeSet initial_sync_ended_types; 713 ModelTypeSet initial_sync_ended_types;
709 for (ModelTypeSet::Iterator i = all_types.First(); i.Good(); i.Inc()) { 714 for (ModelTypeSet::Iterator i = all_types.First(); i.Good(); i.Inc()) {
710 if (InitialSyncEndedForType(&trans, i.Get())) { 715 if (InitialSyncEndedForType(&trans, i.Get())) {
711 initial_sync_ended_types.Put(i.Get()); 716 initial_sync_ended_types.Put(i.Get());
712 } 717 }
713 } 718 }
714 return initial_sync_ended_types; 719 return initial_sync_ended_types;
715 } 720 }
716 721
717 bool Directory::InitialSyncEndedForType(ModelType type) { 722 bool Directory::InitialSyncEndedForType(ModelType type) {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 // There were no children in the linked list. 1306 // There were no children in the linked list.
1302 return NULL; 1307 return NULL;
1303 } 1308 }
1304 1309
1305 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1310 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1306 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1311 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1307 } 1312 }
1308 1313
1309 } // namespace syncable 1314 } // namespace syncable
1310 } // namespace syncer 1315 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698