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

Side by Side Diff: sync/syncable/directory.cc

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 years, 5 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
« no previous file with comments | « sync/syncable/directory.h ('k') | sync/syncable/directory_backing_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return !a->ref(IS_DEL) && !a->ref(ID).IsRoot(); 101 return !a->ref(IS_DEL) && !a->ref(ID).IsRoot();
102 } 102 }
103 103
104 // static 104 // static
105 const FilePath::CharType Directory::kSyncDatabaseFilename[] = 105 const FilePath::CharType Directory::kSyncDatabaseFilename[] =
106 FILE_PATH_LITERAL("SyncData.sqlite3"); 106 FILE_PATH_LITERAL("SyncData.sqlite3");
107 107
108 void Directory::InitKernelForTest( 108 void Directory::InitKernelForTest(
109 const std::string& name, 109 const std::string& name,
110 DirectoryChangeDelegate* delegate, 110 DirectoryChangeDelegate* delegate,
111 const syncer::WeakHandle<TransactionObserver>& 111 const WeakHandle<TransactionObserver>& transaction_observer) {
112 transaction_observer) {
113 DCHECK(!kernel_); 112 DCHECK(!kernel_);
114 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer); 113 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer);
115 } 114 }
116 115
117 Directory::PersistedKernelInfo::PersistedKernelInfo() 116 Directory::PersistedKernelInfo::PersistedKernelInfo()
118 : next_id(0) { 117 : next_id(0) {
119 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 118 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
120 reset_download_progress(ModelTypeFromInt(i)); 119 reset_download_progress(ModelTypeFromInt(i));
121 } 120 }
122 } 121 }
(...skipping 10 matching lines...) Expand all
133 132
134 Directory::SaveChangesSnapshot::SaveChangesSnapshot() 133 Directory::SaveChangesSnapshot::SaveChangesSnapshot()
135 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { 134 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) {
136 } 135 }
137 136
138 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} 137 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {}
139 138
140 Directory::Kernel::Kernel( 139 Directory::Kernel::Kernel(
141 const std::string& name, 140 const std::string& name,
142 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate, 141 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate,
143 const syncer::WeakHandle<TransactionObserver>& 142 const WeakHandle<TransactionObserver>& transaction_observer)
144 transaction_observer)
145 : next_write_transaction_id(0), 143 : next_write_transaction_id(0),
146 name(name), 144 name(name),
147 metahandles_index(new Directory::MetahandlesIndex), 145 metahandles_index(new Directory::MetahandlesIndex),
148 ids_index(new Directory::IdsIndex), 146 ids_index(new Directory::IdsIndex),
149 parent_id_child_index(new Directory::ParentIdChildIndex), 147 parent_id_child_index(new Directory::ParentIdChildIndex),
150 client_tag_index(new Directory::ClientTagIndex), 148 client_tag_index(new Directory::ClientTagIndex),
151 unsynced_metahandles(new MetahandleSet), 149 unsynced_metahandles(new MetahandleSet),
152 dirty_metahandles(new MetahandleSet), 150 dirty_metahandles(new MetahandleSet),
153 metahandles_to_purge(new MetahandleSet), 151 metahandles_to_purge(new MetahandleSet),
154 info_status(Directory::KERNEL_SHARE_INFO_VALID), 152 info_status(Directory::KERNEL_SHARE_INFO_VALID),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 invariant_check_level_(VERIFY_CHANGES) { 185 invariant_check_level_(VERIFY_CHANGES) {
188 } 186 }
189 187
190 Directory::~Directory() { 188 Directory::~Directory() {
191 Close(); 189 Close();
192 } 190 }
193 191
194 DirOpenResult Directory::Open( 192 DirOpenResult Directory::Open(
195 const string& name, 193 const string& name,
196 DirectoryChangeDelegate* delegate, 194 DirectoryChangeDelegate* delegate,
197 const syncer::WeakHandle<TransactionObserver>& 195 const WeakHandle<TransactionObserver>& transaction_observer) {
198 transaction_observer) {
199 TRACE_EVENT0("sync", "SyncDatabaseOpen"); 196 TRACE_EVENT0("sync", "SyncDatabaseOpen");
200 197
201 const DirOpenResult result = 198 const DirOpenResult result =
202 OpenImpl(name, delegate, transaction_observer); 199 OpenImpl(name, delegate, transaction_observer);
203 200
204 if (OPENED != result) 201 if (OPENED != result)
205 Close(); 202 Close();
206 return result; 203 return result;
207 } 204 }
208 205
(...skipping 12 matching lines...) Expand all
221 const ModelType type = entry->GetServerModelType(); 218 const ModelType type = entry->GetServerModelType();
222 kernel_->unapplied_update_metahandles[type].insert(metahandle); 219 kernel_->unapplied_update_metahandles[type].insert(metahandle);
223 } 220 }
224 DCHECK(!entry->is_dirty()); 221 DCHECK(!entry->is_dirty());
225 } 222 }
226 } 223 }
227 224
228 DirOpenResult Directory::OpenImpl( 225 DirOpenResult Directory::OpenImpl(
229 const string& name, 226 const string& name,
230 DirectoryChangeDelegate* delegate, 227 DirectoryChangeDelegate* delegate,
231 const syncer::WeakHandle<TransactionObserver>& 228 const WeakHandle<TransactionObserver>&
232 transaction_observer) { 229 transaction_observer) {
233 230
234 KernelLoadInfo info; 231 KernelLoadInfo info;
235 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) 232 // Temporary indices before kernel_ initialized in case Load fails. We 0(1)
236 // swap these later. 233 // swap these later.
237 MetahandlesIndex metas_bucket; 234 MetahandlesIndex metas_bucket;
238 DirOpenResult result = store_->Load(&metas_bucket, &info); 235 DirOpenResult result = store_->Load(&metas_bucket, &info);
239 if (OPENED != result) 236 if (OPENED != result)
240 return result; 237 return result;
241 238
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 num_erased = kernel_->parent_id_child_index->erase(entry); 613 num_erased = kernel_->parent_id_child_index->erase(entry);
617 DCHECK_EQ(entry->ref(IS_DEL), !num_erased); 614 DCHECK_EQ(entry->ref(IS_DEL), !num_erased);
618 kernel_->metahandles_index->erase(it++); 615 kernel_->metahandles_index->erase(it++);
619 delete entry; 616 delete entry;
620 } else { 617 } else {
621 ++it; 618 ++it;
622 } 619 }
623 } 620 }
624 621
625 // Ensure meta tracking for these data types reflects the deleted state. 622 // Ensure meta tracking for these data types reflects the deleted state.
626 for (syncer::ModelTypeSet::Iterator it = types.First(); 623 for (ModelTypeSet::Iterator it = types.First();
627 it.Good(); it.Inc()) { 624 it.Good(); it.Inc()) {
628 set_initial_sync_ended_for_type_unsafe(it.Get(), false); 625 set_initial_sync_ended_for_type_unsafe(it.Get(), false);
629 kernel_->persisted_info.reset_download_progress(it.Get()); 626 kernel_->persisted_info.reset_download_progress(it.Get());
630 } 627 }
631 } 628 }
632 } 629 }
633 return true; 630 return true;
634 } 631 }
635 632
636 void Directory::HandleSaveChangesFailure(const SaveChangesSnapshot& snapshot) { 633 void Directory::HandleSaveChangesFailure(const SaveChangesSnapshot& snapshot) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 void Directory::SetNotificationState(const std::string& notification_state) { 747 void Directory::SetNotificationState(const std::string& notification_state) {
751 ScopedKernelLock lock(this); 748 ScopedKernelLock lock(this);
752 SetNotificationStateUnsafe(notification_state); 749 SetNotificationStateUnsafe(notification_state);
753 } 750 }
754 751
755 string Directory::cache_guid() const { 752 string Directory::cache_guid() const {
756 // No need to lock since nothing ever writes to it after load. 753 // No need to lock since nothing ever writes to it after load.
757 return kernel_->cache_guid; 754 return kernel_->cache_guid;
758 } 755 }
759 756
760 syncer::Cryptographer* Directory::GetCryptographer( 757 Cryptographer* Directory::GetCryptographer(const BaseTransaction* trans) {
761 const BaseTransaction* trans) {
762 DCHECK_EQ(this, trans->directory()); 758 DCHECK_EQ(this, trans->directory());
763 return &cryptographer_; 759 return &cryptographer_;
764 } 760 }
765 761
766 void Directory::GetAllMetaHandles(BaseTransaction* trans, 762 void Directory::GetAllMetaHandles(BaseTransaction* trans,
767 MetahandleSet* result) { 763 MetahandleSet* result) {
768 result->clear(); 764 result->clear();
769 ScopedKernelLock lock(this); 765 ScopedKernelLock lock(this);
770 MetahandlesIndex::iterator i; 766 MetahandlesIndex::iterator i;
771 for (i = kernel_->metahandles_index->begin(); 767 for (i = kernel_->metahandles_index->begin();
(...skipping 20 matching lines...) Expand all
792 kernel_->unsynced_metahandles->end(), back_inserter(*result)); 788 kernel_->unsynced_metahandles->end(), back_inserter(*result));
793 } 789 }
794 790
795 int64 Directory::unsynced_entity_count() const { 791 int64 Directory::unsynced_entity_count() const {
796 ScopedKernelLock lock(this); 792 ScopedKernelLock lock(this);
797 return kernel_->unsynced_metahandles->size(); 793 return kernel_->unsynced_metahandles->size();
798 } 794 }
799 795
800 FullModelTypeSet Directory::GetServerTypesWithUnappliedUpdates( 796 FullModelTypeSet Directory::GetServerTypesWithUnappliedUpdates(
801 BaseTransaction* trans) const { 797 BaseTransaction* trans) const {
802 syncer::FullModelTypeSet server_types; 798 FullModelTypeSet server_types;
803 ScopedKernelLock lock(this); 799 ScopedKernelLock lock(this);
804 for (int i = UNSPECIFIED; i < MODEL_TYPE_COUNT; ++i) { 800 for (int i = UNSPECIFIED; i < MODEL_TYPE_COUNT; ++i) {
805 const ModelType type = ModelTypeFromInt(i); 801 const ModelType type = ModelTypeFromInt(i);
806 if (!kernel_->unapplied_update_metahandles[type].empty()) { 802 if (!kernel_->unapplied_update_metahandles[type].empty()) {
807 server_types.Put(type); 803 server_types.Put(type);
808 } 804 }
809 } 805 }
810 return server_types; 806 return server_types;
811 } 807 }
812 808
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 // There were no children in the linked list. 1245 // There were no children in the linked list.
1250 return NULL; 1246 return NULL;
1251 } 1247 }
1252 1248
1253 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1249 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1254 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1250 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1255 } 1251 }
1256 1252
1257 } // namespace syncable 1253 } // namespace syncable
1258 } // namespace syncer 1254 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory.h ('k') | sync/syncable/directory_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698