OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 transaction_observer(transaction_observer) { | 96 transaction_observer(transaction_observer) { |
97 DCHECK(delegate); | 97 DCHECK(delegate); |
98 DCHECK(transaction_observer.IsInitialized()); | 98 DCHECK(transaction_observer.IsInitialized()); |
99 } | 99 } |
100 | 100 |
101 Directory::Kernel::~Kernel() { | 101 Directory::Kernel::~Kernel() { |
102 STLDeleteContainerPairSecondPointers(metahandles_map.begin(), | 102 STLDeleteContainerPairSecondPointers(metahandles_map.begin(), |
103 metahandles_map.end()); | 103 metahandles_map.end()); |
104 } | 104 } |
105 | 105 |
106 Directory::Directory(DirectoryBackingStore* store, | 106 Directory::Directory( |
107 UnrecoverableErrorHandler* unrecoverable_error_handler, | 107 DirectoryBackingStore* store, |
108 const base::Closure& report_unrecoverable_error_function, | 108 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
109 NigoriHandler* nigori_handler, | 109 const base::Closure& report_unrecoverable_error_function, |
110 Cryptographer* cryptographer) | 110 NigoriHandler* nigori_handler, |
| 111 Cryptographer* cryptographer) |
111 : kernel_(NULL), | 112 : kernel_(NULL), |
112 store_(store), | 113 store_(store), |
113 unrecoverable_error_handler_(unrecoverable_error_handler), | 114 unrecoverable_error_handler_(unrecoverable_error_handler), |
114 report_unrecoverable_error_function_(report_unrecoverable_error_function), | 115 report_unrecoverable_error_function_(report_unrecoverable_error_function), |
115 unrecoverable_error_set_(false), | 116 unrecoverable_error_set_(false), |
116 nigori_handler_(nigori_handler), | 117 nigori_handler_(nigori_handler), |
117 cryptographer_(cryptographer), | 118 cryptographer_(cryptographer), |
118 invariant_check_level_(VERIFY_CHANGES), | 119 invariant_check_level_(VERIFY_CHANGES), |
119 weak_ptr_factory_(this) { | 120 weak_ptr_factory_(this) {} |
120 } | |
121 | 121 |
122 Directory::~Directory() { | 122 Directory::~Directory() { |
123 Close(); | 123 Close(); |
124 } | 124 } |
125 | 125 |
126 DirOpenResult Directory::Open( | 126 DirOpenResult Directory::Open( |
127 const string& name, | 127 const string& name, |
128 DirectoryChangeDelegate* delegate, | 128 DirectoryChangeDelegate* delegate, |
129 const WeakHandle<TransactionObserver>& transaction_observer) { | 129 const WeakHandle<TransactionObserver>& transaction_observer) { |
130 TRACE_EVENT0("sync", "SyncDatabaseOpen"); | 130 TRACE_EVENT0("sync", "SyncDatabaseOpen"); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 delete kernel_; | 224 delete kernel_; |
225 kernel_ = NULL; | 225 kernel_ = NULL; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 void Directory::OnUnrecoverableError(const BaseTransaction* trans, | 229 void Directory::OnUnrecoverableError(const BaseTransaction* trans, |
230 const tracked_objects::Location& location, | 230 const tracked_objects::Location& location, |
231 const std::string & message) { | 231 const std::string & message) { |
232 DCHECK(trans != NULL); | 232 DCHECK(trans != NULL); |
233 unrecoverable_error_set_ = true; | 233 unrecoverable_error_set_ = true; |
234 unrecoverable_error_handler_->OnUnrecoverableError(location, | 234 unrecoverable_error_handler_.Call( |
235 message); | 235 FROM_HERE, &UnrecoverableErrorHandler::OnUnrecoverableError, location, |
| 236 message); |
236 } | 237 } |
237 | 238 |
238 EntryKernel* Directory::GetEntryById(const Id& id) { | 239 EntryKernel* Directory::GetEntryById(const Id& id) { |
239 ScopedKernelLock lock(this); | 240 ScopedKernelLock lock(this); |
240 return GetEntryById(lock, id); | 241 return GetEntryById(lock, id); |
241 } | 242 } |
242 | 243 |
243 EntryKernel* Directory::GetEntryById(const ScopedKernelLock& lock, | 244 EntryKernel* Directory::GetEntryById(const ScopedKernelLock& lock, |
244 const Id& id) { | 245 const Id& id) { |
245 DCHECK(kernel_); | 246 DCHECK(kernel_); |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 Directory::Kernel* Directory::kernel() { | 1563 Directory::Kernel* Directory::kernel() { |
1563 return kernel_; | 1564 return kernel_; |
1564 } | 1565 } |
1565 | 1566 |
1566 const Directory::Kernel* Directory::kernel() const { | 1567 const Directory::Kernel* Directory::kernel() const { |
1567 return kernel_; | 1568 return kernel_; |
1568 } | 1569 } |
1569 | 1570 |
1570 } // namespace syncable | 1571 } // namespace syncable |
1571 } // namespace syncer | 1572 } // namespace syncer |
OLD | NEW |