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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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.cc » ('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"
11 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 11 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
12 #include "sync/syncable/base_transaction.h" 12 #include "sync/syncable/base_transaction.h"
13 #include "sync/syncable/entry.h" 13 #include "sync/syncable/entry.h"
14 #include "sync/syncable/entry_kernel.h" 14 #include "sync/syncable/entry_kernel.h"
15 #include "sync/syncable/in_memory_directory_backing_store.h" 15 #include "sync/syncable/in_memory_directory_backing_store.h"
16 #include "sync/syncable/on_disk_directory_backing_store.h" 16 #include "sync/syncable/on_disk_directory_backing_store.h"
17 #include "sync/syncable/read_transaction.h" 17 #include "sync/syncable/read_transaction.h"
18 #include "sync/syncable/scoped_index_updater.h" 18 #include "sync/syncable/scoped_index_updater.h"
19 #include "sync/syncable/syncable-inl.h" 19 #include "sync/syncable/syncable-inl.h"
20 #include "sync/syncable/syncable_changes_version.h" 20 #include "sync/syncable/syncable_changes_version.h"
21 #include "sync/syncable/syncable_util.h" 21 #include "sync/syncable/syncable_util.h"
22 #include "sync/syncable/write_transaction.h" 22 #include "sync/syncable/write_transaction.h"
23 23
24 using csync::Encryptor; 24 using syncer::Encryptor;
25 using csync::ReportUnrecoverableErrorFunction; 25 using syncer::ReportUnrecoverableErrorFunction;
26 using csync::UnrecoverableErrorHandler; 26 using syncer::UnrecoverableErrorHandler;
27 using std::string; 27 using std::string;
28 28
29 namespace syncable { 29 namespace syncable {
30 30
31 namespace { 31 namespace {
32 // Max number of milliseconds to spend checking syncable entry invariants 32 // Max number of milliseconds to spend checking syncable entry invariants
33 const int kInvariantCheckMaxMs = 50; 33 const int kInvariantCheckMaxMs = 50;
34 34
35 // Helper function to add an item to the index, if it ought to be added. 35 // Helper function to add an item to the index, if it ought to be added.
36 template<typename Indexer> 36 template<typename Indexer>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return !a->ref(IS_DEL) && !a->ref(ID).IsRoot(); 106 return !a->ref(IS_DEL) && !a->ref(ID).IsRoot();
107 } 107 }
108 108
109 // static 109 // static
110 const FilePath::CharType Directory::kSyncDatabaseFilename[] = 110 const FilePath::CharType Directory::kSyncDatabaseFilename[] =
111 FILE_PATH_LITERAL("SyncData.sqlite3"); 111 FILE_PATH_LITERAL("SyncData.sqlite3");
112 112
113 void Directory::InitKernelForTest( 113 void Directory::InitKernelForTest(
114 const std::string& name, 114 const std::string& name,
115 DirectoryChangeDelegate* delegate, 115 DirectoryChangeDelegate* delegate,
116 const csync::WeakHandle<TransactionObserver>& 116 const syncer::WeakHandle<TransactionObserver>&
117 transaction_observer) { 117 transaction_observer) {
118 DCHECK(!kernel_); 118 DCHECK(!kernel_);
119 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer); 119 kernel_ = new Kernel(name, KernelLoadInfo(), delegate, transaction_observer);
120 } 120 }
121 121
122 Directory::PersistedKernelInfo::PersistedKernelInfo() 122 Directory::PersistedKernelInfo::PersistedKernelInfo()
123 : next_id(0) { 123 : next_id(0) {
124 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 124 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
125 reset_download_progress(ModelTypeFromInt(i)); 125 reset_download_progress(ModelTypeFromInt(i));
126 } 126 }
(...skipping 11 matching lines...) Expand all
138 138
139 Directory::SaveChangesSnapshot::SaveChangesSnapshot() 139 Directory::SaveChangesSnapshot::SaveChangesSnapshot()
140 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { 140 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) {
141 } 141 }
142 142
143 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} 143 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {}
144 144
145 Directory::Kernel::Kernel( 145 Directory::Kernel::Kernel(
146 const std::string& name, 146 const std::string& name,
147 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate, 147 const KernelLoadInfo& info, DirectoryChangeDelegate* delegate,
148 const csync::WeakHandle<TransactionObserver>& 148 const syncer::WeakHandle<TransactionObserver>&
149 transaction_observer) 149 transaction_observer)
150 : next_write_transaction_id(0), 150 : next_write_transaction_id(0),
151 name(name), 151 name(name),
152 metahandles_index(new Directory::MetahandlesIndex), 152 metahandles_index(new Directory::MetahandlesIndex),
153 ids_index(new Directory::IdsIndex), 153 ids_index(new Directory::IdsIndex),
154 parent_id_child_index(new Directory::ParentIdChildIndex), 154 parent_id_child_index(new Directory::ParentIdChildIndex),
155 client_tag_index(new Directory::ClientTagIndex), 155 client_tag_index(new Directory::ClientTagIndex),
156 unsynced_metahandles(new MetahandleSet), 156 unsynced_metahandles(new MetahandleSet),
157 dirty_metahandles(new MetahandleSet), 157 dirty_metahandles(new MetahandleSet),
158 metahandles_to_purge(new MetahandleSet), 158 metahandles_to_purge(new MetahandleSet),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 unrecoverable_error_set_(false) { 191 unrecoverable_error_set_(false) {
192 } 192 }
193 193
194 Directory::~Directory() { 194 Directory::~Directory() {
195 Close(); 195 Close();
196 } 196 }
197 197
198 DirOpenResult Directory::Open( 198 DirOpenResult Directory::Open(
199 const string& name, 199 const string& name,
200 DirectoryChangeDelegate* delegate, 200 DirectoryChangeDelegate* delegate,
201 const csync::WeakHandle<TransactionObserver>& 201 const syncer::WeakHandle<TransactionObserver>&
202 transaction_observer) { 202 transaction_observer) {
203 TRACE_EVENT0("sync", "SyncDatabaseOpen"); 203 TRACE_EVENT0("sync", "SyncDatabaseOpen");
204 204
205 const DirOpenResult result = 205 const DirOpenResult result =
206 OpenImpl(name, delegate, transaction_observer); 206 OpenImpl(name, delegate, transaction_observer);
207 207
208 if (OPENED != result) 208 if (OPENED != result)
209 Close(); 209 Close();
210 return result; 210 return result;
211 } 211 }
(...skipping 13 matching lines...) Expand all
225 const ModelType type = entry->GetServerModelType(); 225 const ModelType type = entry->GetServerModelType();
226 kernel_->unapplied_update_metahandles[type].insert(metahandle); 226 kernel_->unapplied_update_metahandles[type].insert(metahandle);
227 } 227 }
228 DCHECK(!entry->is_dirty()); 228 DCHECK(!entry->is_dirty());
229 } 229 }
230 } 230 }
231 231
232 DirOpenResult Directory::OpenImpl( 232 DirOpenResult Directory::OpenImpl(
233 const string& name, 233 const string& name,
234 DirectoryChangeDelegate* delegate, 234 DirectoryChangeDelegate* delegate,
235 const csync::WeakHandle<TransactionObserver>& 235 const syncer::WeakHandle<TransactionObserver>&
236 transaction_observer) { 236 transaction_observer) {
237 237
238 KernelLoadInfo info; 238 KernelLoadInfo info;
239 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) 239 // Temporary indices before kernel_ initialized in case Load fails. We 0(1)
240 // swap these later. 240 // swap these later.
241 MetahandlesIndex metas_bucket; 241 MetahandlesIndex metas_bucket;
242 DirOpenResult result = store_->Load(&metas_bucket, &info); 242 DirOpenResult result = store_->Load(&metas_bucket, &info);
243 if (OPENED != result) 243 if (OPENED != result)
244 return result; 244 return result;
245 245
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 void Directory::SetNotificationState(const std::string& notification_state) { 753 void Directory::SetNotificationState(const std::string& notification_state) {
754 ScopedKernelLock lock(this); 754 ScopedKernelLock lock(this);
755 SetNotificationStateUnsafe(notification_state); 755 SetNotificationStateUnsafe(notification_state);
756 } 756 }
757 757
758 string Directory::cache_guid() const { 758 string Directory::cache_guid() const {
759 // No need to lock since nothing ever writes to it after load. 759 // No need to lock since nothing ever writes to it after load.
760 return kernel_->cache_guid; 760 return kernel_->cache_guid;
761 } 761 }
762 762
763 csync::Cryptographer* Directory::GetCryptographer( 763 syncer::Cryptographer* Directory::GetCryptographer(
764 const BaseTransaction* trans) { 764 const BaseTransaction* trans) {
765 DCHECK_EQ(this, trans->directory()); 765 DCHECK_EQ(this, trans->directory());
766 return &cryptographer_; 766 return &cryptographer_;
767 } 767 }
768 768
769 void Directory::GetAllMetaHandles(BaseTransaction* trans, 769 void Directory::GetAllMetaHandles(BaseTransaction* trans,
770 MetahandleSet* result) { 770 MetahandleSet* result) {
771 result->clear(); 771 result->clear();
772 ScopedKernelLock lock(this); 772 ScopedKernelLock lock(this);
773 MetahandlesIndex::iterator i; 773 MetahandlesIndex::iterator i;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1312 }
1313 // There were no children in the linked list. 1313 // There were no children in the linked list.
1314 return NULL; 1314 return NULL;
1315 } 1315 }
1316 1316
1317 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1317 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1318 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1318 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1319 } 1319 }
1320 1320
1321 } 1321 }
OLDNEW
« no previous file with comments | « sync/syncable/directory.h ('k') | sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698