| OLD | NEW |
| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 delete dirty_metahandles; | 129 delete dirty_metahandles; |
| 130 delete metahandles_to_purge; | 130 delete metahandles_to_purge; |
| 131 delete parent_id_child_index; | 131 delete parent_id_child_index; |
| 132 delete client_tag_index; | 132 delete client_tag_index; |
| 133 delete ids_index; | 133 delete ids_index; |
| 134 STLDeleteElements(metahandles_index); | 134 STLDeleteElements(metahandles_index); |
| 135 delete metahandles_index; | 135 delete metahandles_index; |
| 136 } | 136 } |
| 137 | 137 |
| 138 Directory::Directory( | 138 Directory::Directory( |
| 139 Encryptor* encryptor, | 139 DirectoryBackingStore* store, |
| 140 UnrecoverableErrorHandler* unrecoverable_error_handler, | 140 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 141 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | 141 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, |
| 142 DirectoryBackingStore* store) | 142 NigoriHandler* nigori_handler, |
| 143 : cryptographer_(encryptor), | 143 Cryptographer* cryptographer) |
| 144 kernel_(NULL), | 144 : kernel_(NULL), |
| 145 store_(store), | 145 store_(store), |
| 146 unrecoverable_error_handler_(unrecoverable_error_handler), | 146 unrecoverable_error_handler_(unrecoverable_error_handler), |
| 147 report_unrecoverable_error_function_( | 147 report_unrecoverable_error_function_( |
| 148 report_unrecoverable_error_function), | 148 report_unrecoverable_error_function), |
| 149 unrecoverable_error_set_(false), | 149 unrecoverable_error_set_(false), |
| 150 nigori_handler_(nigori_handler), |
| 151 cryptographer_(cryptographer), |
| 150 invariant_check_level_(VERIFY_CHANGES) { | 152 invariant_check_level_(VERIFY_CHANGES) { |
| 151 } | 153 } |
| 152 | 154 |
| 153 Directory::~Directory() { | 155 Directory::~Directory() { |
| 154 Close(); | 156 Close(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 DirOpenResult Directory::Open( | 159 DirOpenResult Directory::Open( |
| 158 const string& name, | 160 const string& name, |
| 159 DirectoryChangeDelegate* delegate, | 161 DirectoryChangeDelegate* delegate, |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 void Directory::SetNotificationState(const std::string& notification_state) { | 719 void Directory::SetNotificationState(const std::string& notification_state) { |
| 718 ScopedKernelLock lock(this); | 720 ScopedKernelLock lock(this); |
| 719 SetNotificationStateUnsafe(notification_state); | 721 SetNotificationStateUnsafe(notification_state); |
| 720 } | 722 } |
| 721 | 723 |
| 722 string Directory::cache_guid() const { | 724 string Directory::cache_guid() const { |
| 723 // No need to lock since nothing ever writes to it after load. | 725 // No need to lock since nothing ever writes to it after load. |
| 724 return kernel_->cache_guid; | 726 return kernel_->cache_guid; |
| 725 } | 727 } |
| 726 | 728 |
| 729 NigoriHandler* Directory::GetNigoriHandler() { |
| 730 return nigori_handler_; |
| 731 } |
| 732 |
| 727 Cryptographer* Directory::GetCryptographer(const BaseTransaction* trans) { | 733 Cryptographer* Directory::GetCryptographer(const BaseTransaction* trans) { |
| 728 DCHECK_EQ(this, trans->directory()); | 734 DCHECK_EQ(this, trans->directory()); |
| 729 return &cryptographer_; | 735 return cryptographer_; |
| 730 } | 736 } |
| 731 | 737 |
| 732 void Directory::GetAllMetaHandles(BaseTransaction* trans, | 738 void Directory::GetAllMetaHandles(BaseTransaction* trans, |
| 733 MetahandleSet* result) { | 739 MetahandleSet* result) { |
| 734 result->clear(); | 740 result->clear(); |
| 735 ScopedKernelLock lock(this); | 741 ScopedKernelLock lock(this); |
| 736 MetahandlesIndex::iterator i; | 742 MetahandlesIndex::iterator i; |
| 737 for (i = kernel_->metahandles_index->begin(); | 743 for (i = kernel_->metahandles_index->begin(); |
| 738 i != kernel_->metahandles_index->end(); | 744 i != kernel_->metahandles_index->end(); |
| 739 ++i) { | 745 ++i) { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 // There were no children in the linked list. | 1221 // There were no children in the linked list. |
| 1216 return NULL; | 1222 return NULL; |
| 1217 } | 1223 } |
| 1218 | 1224 |
| 1219 ScopedKernelLock::ScopedKernelLock(const Directory* dir) | 1225 ScopedKernelLock::ScopedKernelLock(const Directory* dir) |
| 1220 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { | 1226 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { |
| 1221 } | 1227 } |
| 1222 | 1228 |
| 1223 } // namespace syncable | 1229 } // namespace syncable |
| 1224 } // namespace syncer | 1230 } // namespace syncer |
| OLD | NEW |