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