OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/leveldb_wrapper_impl.h" | 5 #include "content/browser/leveldb_wrapper_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/common/common_type_converters.h" | 8 #include "mojo/common/common_type_converters.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 LevelDBWrapperImpl::LevelDBWrapperImpl( | 12 LevelDBWrapperImpl::LevelDBWrapperImpl( |
13 leveldb::LevelDBDatabase* database, | |
14 const std::string& prefix, | 13 const std::string& prefix, |
15 size_t max_size, | 14 size_t max_size, |
16 const base::Closure& no_bindings_callback) | 15 const base::Closure& no_bindings_callback) |
17 : prefix_(prefix), | 16 : prefix_(prefix), |
18 no_bindings_callback_(no_bindings_callback), | 17 no_bindings_callback_(no_bindings_callback), |
19 database_(database), | |
20 bytes_used_(0), | 18 bytes_used_(0), |
21 max_size_(max_size) { | 19 max_size_(max_size) { |
22 bindings_.set_connection_error_handler(base::Bind( | 20 bindings_.set_connection_error_handler(base::Bind( |
23 &LevelDBWrapperImpl::OnConnectionError, base::Unretained(this))); | 21 &LevelDBWrapperImpl::OnConnectionError, base::Unretained(this))); |
24 } | 22 } |
25 | 23 |
26 void LevelDBWrapperImpl::Bind(mojom::LevelDBWrapperRequest request) { | 24 void LevelDBWrapperImpl::Bind(mojom::LevelDBWrapperRequest request) { |
27 bindings_.AddBinding(this, std::move(request)); | 25 bindings_.AddBinding(this, std::move(request)); |
28 } | 26 } |
29 | 27 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 132 } |
135 | 133 |
136 void LevelDBWrapperImpl::OnConnectionError() { | 134 void LevelDBWrapperImpl::OnConnectionError() { |
137 if (!bindings_.empty()) | 135 if (!bindings_.empty()) |
138 return; | 136 return; |
139 | 137 |
140 no_bindings_callback_.Run(); | 138 no_bindings_callback_.Run(); |
141 } | 139 } |
142 | 140 |
143 } // namespace content | 141 } // namespace content |
OLD | NEW |