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 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 LevelDBWrapperImpl::LevelDBWrapperImpl( | 11 LevelDBWrapperImpl::LevelDBWrapperImpl( |
12 const std::string& prefix, const base::Closure& no_bindings_callback) | 12 leveldb::LevelDBDatabase* database, |
13 : prefix_(prefix), no_bindings_callback_(no_bindings_callback) { | 13 const std::string& prefix, |
| 14 const base::Closure& no_bindings_callback) |
| 15 : prefix_(prefix), |
| 16 no_bindings_callback_(no_bindings_callback), |
| 17 database_(database) { |
14 bindings_.set_connection_error_handler(base::Bind( | 18 bindings_.set_connection_error_handler(base::Bind( |
15 &LevelDBWrapperImpl::OnConnectionError, base::Unretained(this))); | 19 &LevelDBWrapperImpl::OnConnectionError, base::Unretained(this))); |
16 } | 20 } |
17 | 21 |
18 void LevelDBWrapperImpl::Bind(mojo::InterfaceRequest<LevelDBWrapper> request) { | 22 void LevelDBWrapperImpl::Bind(mojo::InterfaceRequest<LevelDBWrapper> request) { |
19 bindings_.AddBinding(this, std::move(request)); | 23 bindings_.AddBinding(this, std::move(request)); |
20 } | 24 } |
21 | 25 |
22 LevelDBWrapperImpl::~LevelDBWrapperImpl() { | 26 LevelDBWrapperImpl::~LevelDBWrapperImpl() { |
23 } | 27 } |
24 | 28 |
25 void LevelDBWrapperImpl::Put(mojo::Array<uint8_t> key, | 29 void LevelDBWrapperImpl::Put(mojo::Array<uint8_t> key, |
26 mojo::Array<uint8_t> value, | 30 mojo::Array<uint8_t> value, |
27 const mojo::String& source, | 31 const mojo::String& source, |
28 const PutCallback& callback) { | 32 const PutCallback& callback) { |
| 33 NOTIMPLEMENTED(); |
| 34 callback.Run(leveldb::DatabaseError::NOT_SUPPORTED); |
29 } | 35 } |
30 | 36 |
31 void LevelDBWrapperImpl::Delete(mojo::Array<uint8_t> key, | 37 void LevelDBWrapperImpl::Delete(mojo::Array<uint8_t> key, |
32 const mojo::String& source, | 38 const mojo::String& source, |
33 const DeleteCallback& callback) { | 39 const DeleteCallback& callback) { |
| 40 NOTIMPLEMENTED(); |
| 41 callback.Run(leveldb::DatabaseError::NOT_SUPPORTED); |
34 } | 42 } |
35 | 43 |
36 void LevelDBWrapperImpl::DeleteAll(LevelDBObserverPtr observer, | 44 void LevelDBWrapperImpl::DeleteAll(LevelDBObserverPtr observer, |
37 const mojo::String& source, | 45 const mojo::String& source, |
38 const DeleteAllCallback& callback) { | 46 const DeleteAllCallback& callback) { |
39 // TODO(jam): store observer and call it when changes occur. | 47 // TODO(jam): store observer and call it when changes occur. |
| 48 NOTIMPLEMENTED(); |
| 49 callback.Run(leveldb::DatabaseError::NOT_SUPPORTED); |
40 } | 50 } |
41 | 51 |
42 void LevelDBWrapperImpl::Get(mojo::Array<uint8_t> key, | 52 void LevelDBWrapperImpl::Get(mojo::Array<uint8_t> key, |
43 const GetCallback& callback) { | 53 const GetCallback& callback) { |
| 54 NOTIMPLEMENTED(); |
| 55 callback.Run(leveldb::DatabaseError::NOT_SUPPORTED, |
| 56 mojo::Array<uint8_t>()); |
44 } | 57 } |
45 | 58 |
46 void LevelDBWrapperImpl::GetAll(LevelDBObserverPtr observer, | 59 void LevelDBWrapperImpl::GetAll(LevelDBObserverPtr observer, |
47 const GetAllCallback& callback) { | 60 const GetAllCallback& callback) { |
48 // TODO(jam): store observer and call it when changes occur. | 61 // TODO(jam): store observer and call it when changes occur. |
| 62 NOTIMPLEMENTED(); |
| 63 callback.Run(leveldb::DatabaseError::NOT_SUPPORTED, |
| 64 mojo::Array<KeyValuePtr>()); |
49 } | 65 } |
50 | 66 |
51 void LevelDBWrapperImpl::OnConnectionError() { | 67 void LevelDBWrapperImpl::OnConnectionError() { |
52 if (!bindings_.empty()) | 68 if (!bindings_.empty()) |
53 return; | 69 return; |
54 | 70 |
55 no_bindings_callback_.Run(); | 71 no_bindings_callback_.Run(); |
56 } | 72 } |
57 | 73 |
58 } // namespace content | 74 } // namespace content |
OLD | NEW |