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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 void Directory::SetNotificationState(const std::string& notification_state) { | 711 void Directory::SetNotificationState(const std::string& notification_state) { |
710 ScopedKernelLock lock(this); | 712 ScopedKernelLock lock(this); |
711 SetNotificationStateUnsafe(notification_state); | 713 SetNotificationStateUnsafe(notification_state); |
712 } | 714 } |
713 | 715 |
714 string Directory::cache_guid() const { | 716 string Directory::cache_guid() const { |
715 // No need to lock since nothing ever writes to it after load. | 717 // No need to lock since nothing ever writes to it after load. |
716 return kernel_->cache_guid; | 718 return kernel_->cache_guid; |
717 } | 719 } |
718 | 720 |
| 721 NigoriHandler* Directory::GetNigoriHandler() { |
| 722 return nigori_handler_; |
| 723 } |
| 724 |
719 Cryptographer* Directory::GetCryptographer(const BaseTransaction* trans) { | 725 Cryptographer* Directory::GetCryptographer(const BaseTransaction* trans) { |
720 DCHECK_EQ(this, trans->directory()); | 726 DCHECK_EQ(this, trans->directory()); |
721 return &cryptographer_; | 727 return cryptographer_; |
722 } | 728 } |
723 | 729 |
724 void Directory::GetAllMetaHandles(BaseTransaction* trans, | 730 void Directory::GetAllMetaHandles(BaseTransaction* trans, |
725 MetahandleSet* result) { | 731 MetahandleSet* result) { |
726 result->clear(); | 732 result->clear(); |
727 ScopedKernelLock lock(this); | 733 ScopedKernelLock lock(this); |
728 MetahandlesIndex::iterator i; | 734 MetahandlesIndex::iterator i; |
729 for (i = kernel_->metahandles_index->begin(); | 735 for (i = kernel_->metahandles_index->begin(); |
730 i != kernel_->metahandles_index->end(); | 736 i != kernel_->metahandles_index->end(); |
731 ++i) { | 737 ++i) { |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 // There were no children in the linked list. | 1213 // There were no children in the linked list. |
1208 return NULL; | 1214 return NULL; |
1209 } | 1215 } |
1210 | 1216 |
1211 ScopedKernelLock::ScopedKernelLock(const Directory* dir) | 1217 ScopedKernelLock::ScopedKernelLock(const Directory* dir) |
1212 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { | 1218 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { |
1213 } | 1219 } |
1214 | 1220 |
1215 } // namespace syncable | 1221 } // namespace syncable |
1216 } // namespace syncer | 1222 } // namespace syncer |
OLD | NEW |