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 "components/leveldb/leveldb_app.h" | 5 #include "components/leveldb/leveldb_service_impl.h" |
6 | 6 |
7 #include "components/leveldb/env_mojo.h" | 7 #include "components/leveldb/env_mojo.h" |
8 #include "components/leveldb/leveldb_database_impl.h" | 8 #include "components/leveldb/leveldb_database_impl.h" |
9 #include "components/leveldb/util.h" | 9 #include "components/leveldb/util.h" |
10 #include "mojo/shell/public/cpp/connection.h" | |
11 #include "third_party/leveldatabase/env_chromium.h" | 10 #include "third_party/leveldatabase/env_chromium.h" |
12 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 11 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
13 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 12 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
14 #include "third_party/leveldatabase/src/include/leveldb/filter_policy.h" | 13 #include "third_party/leveldatabase/src/include/leveldb/filter_policy.h" |
15 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 14 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
16 | 15 |
17 namespace leveldb { | 16 namespace leveldb { |
18 | 17 |
19 LevelDBApp::LevelDBApp() {} | 18 LevelDBServiceImpl::LevelDBServiceImpl() |
20 | 19 : thread_(new LevelDBFileThread) { |
21 LevelDBApp::~LevelDBApp() {} | |
22 | |
23 void LevelDBApp::Initialize(mojo::Shell* shell, | |
24 const std::string& url, | |
25 uint32_t id) { | |
26 tracing_.Initialize(shell, url); | |
27 thread_ = new LevelDBFileThread; | |
28 } | 20 } |
29 | 21 |
30 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) { | 22 LevelDBServiceImpl::~LevelDBServiceImpl() {} |
31 connection->AddInterface<LevelDBService>(this); | |
32 return true; | |
33 } | |
34 | 23 |
35 void LevelDBApp::Create(mojo::Connection* connection, | 24 void LevelDBServiceImpl::Open(filesystem::DirectoryPtr directory, |
36 mojo::InterfaceRequest<LevelDBService> request) { | 25 const mojo::String& dbname, |
37 bindings_.AddBinding(this, std::move(request)); | 26 mojo::InterfaceRequest<LevelDBDatabase> database, |
38 } | 27 const OpenCallback& callback) { |
39 | |
40 void LevelDBApp::Open(filesystem::DirectoryPtr directory, | |
41 const mojo::String& dbname, | |
42 mojo::InterfaceRequest<LevelDBDatabase> database, | |
43 const OpenCallback& callback) { | |
44 // This is the place where we open a database. | 28 // This is the place where we open a database. |
45 leveldb::Options options; | 29 leveldb::Options options; |
46 options.create_if_missing = true; | 30 options.create_if_missing = true; |
47 options.paranoid_checks = true; | 31 options.paranoid_checks = true; |
48 // TODO(erg): Do we need a filter policy? | 32 // TODO(erg): Do we need a filter policy? |
49 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; | 33 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
50 options.compression = leveldb::kSnappyCompression; | 34 options.compression = leveldb::kSnappyCompression; |
51 | 35 |
52 // For info about the troubles we've run into with this parameter, see: | 36 // For info about the troubles we've run into with this parameter, see: |
53 // https://code.google.com/p/chromium/issues/detail?id=227313#c11 | 37 // https://code.google.com/p/chromium/issues/detail?id=227313#c11 |
(...skipping 11 matching lines...) Expand all Loading... |
65 | 49 |
66 if (s.ok()) { | 50 if (s.ok()) { |
67 new LevelDBDatabaseImpl(std::move(database), std::move(env_mojo), | 51 new LevelDBDatabaseImpl(std::move(database), std::move(env_mojo), |
68 scoped_ptr<leveldb::DB>(db)); | 52 scoped_ptr<leveldb::DB>(db)); |
69 } | 53 } |
70 | 54 |
71 callback.Run(LeveldbStatusToError(s)); | 55 callback.Run(LeveldbStatusToError(s)); |
72 } | 56 } |
73 | 57 |
74 } // namespace leveldb | 58 } // namespace leveldb |
OLD | NEW |