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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) | 197 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) |
198 // swap these later. | 198 // swap these later. |
199 MetahandlesIndex metas_bucket; | 199 MetahandlesIndex metas_bucket; |
200 DirOpenResult result = store_->Load(&metas_bucket, &info); | 200 DirOpenResult result = store_->Load(&metas_bucket, &info); |
201 if (OPENED != result) | 201 if (OPENED != result) |
202 return result; | 202 return result; |
203 | 203 |
204 kernel_ = new Kernel(name, info, delegate, transaction_observer); | 204 kernel_ = new Kernel(name, info, delegate, transaction_observer); |
205 kernel_->metahandles_index->swap(metas_bucket); | 205 kernel_->metahandles_index->swap(metas_bucket); |
206 InitializeIndices(); | 206 InitializeIndices(); |
207 | |
208 // Write back the share info to reserve some space in 'next_id'. This will | |
209 // prevent local ID reuse in the case of an early crash. See the comments in | |
210 // TakeSnapshotForSaveChanges() or crbug.com/142987 for more information. | |
211 kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; | |
212 if (!SaveChanges()) { | |
213 result = FAILED_INITIAL_WRITE; | |
Nicolas Zea
2012/08/16 20:40:10
return FAILED_INITIAL_WRITE?
rlarocque
2012/08/17 18:02:07
Wow, that was a dumb mistake. Fixed.
Unfortunate
| |
214 } | |
215 | |
207 return OPENED; | 216 return OPENED; |
208 } | 217 } |
209 | 218 |
210 void Directory::Close() { | 219 void Directory::Close() { |
211 store_.reset(); | 220 store_.reset(); |
212 if (kernel_) { | 221 if (kernel_) { |
213 delete kernel_; | 222 delete kernel_; |
214 kernel_ = NULL; | 223 kernel_ = NULL; |
215 } | 224 } |
216 } | 225 } |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1207 // There were no children in the linked list. | 1216 // There were no children in the linked list. |
1208 return NULL; | 1217 return NULL; |
1209 } | 1218 } |
1210 | 1219 |
1211 ScopedKernelLock::ScopedKernelLock(const Directory* dir) | 1220 ScopedKernelLock::ScopedKernelLock(const Directory* dir) |
1212 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { | 1221 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { |
1213 } | 1222 } |
1214 | 1223 |
1215 } // namespace syncable | 1224 } // namespace syncable |
1216 } // namespace syncer | 1225 } // namespace syncer |
OLD | NEW |