Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: components/leveldb/leveldb_app.cc

Issue 1720603002: Revert of mojo: Get mojo:leveldb and mojo:filesystem compiled into content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/leveldb/leveldb_app.h ('k') | components/leveldb/leveldb_service_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_app.h"
6 6
7 #include "components/leveldb/leveldb_service_impl.h" 7 #include "components/leveldb/env_mojo.h"
8 #include "components/leveldb/leveldb_database_impl.h"
9 #include "components/leveldb/util.h"
8 #include "mojo/shell/public/cpp/connection.h" 10 #include "mojo/shell/public/cpp/connection.h"
11 #include "third_party/leveldatabase/env_chromium.h"
12 #include "third_party/leveldatabase/src/include/leveldb/db.h"
13 #include "third_party/leveldatabase/src/include/leveldb/env.h"
14 #include "third_party/leveldatabase/src/include/leveldb/filter_policy.h"
15 #include "third_party/leveldatabase/src/include/leveldb/slice.h"
9 16
10 namespace leveldb { 17 namespace leveldb {
11 18
12 LevelDBApp::LevelDBApp() {} 19 LevelDBApp::LevelDBApp() {}
13 20
14 LevelDBApp::~LevelDBApp() {} 21 LevelDBApp::~LevelDBApp() {}
15 22
16 void LevelDBApp::Initialize(mojo::Shell* shell, 23 void LevelDBApp::Initialize(mojo::Shell* shell,
17 const std::string& url, 24 const std::string& url,
18 uint32_t id) { 25 uint32_t id) {
19 tracing_.Initialize(shell, url); 26 tracing_.Initialize(shell, url);
20 service_.reset(new LevelDBServiceImpl); 27 thread_ = new LevelDBFileThread;
21 } 28 }
22 29
23 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) { 30 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) {
24 connection->AddInterface<LevelDBService>(this); 31 connection->AddInterface<LevelDBService>(this);
25 return true; 32 return true;
26 } 33 }
27 34
28 void LevelDBApp::Create(mojo::Connection* connection, 35 void LevelDBApp::Create(mojo::Connection* connection,
29 mojo::InterfaceRequest<LevelDBService> request) { 36 mojo::InterfaceRequest<LevelDBService> request) {
30 bindings_.AddBinding(service_.get(), std::move(request)); 37 bindings_.AddBinding(this, std::move(request));
38 }
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.
45 leveldb::Options options;
46 options.create_if_missing = true;
47 options.paranoid_checks = true;
48 // TODO(erg): Do we need a filter policy?
49 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
50 options.compression = leveldb::kSnappyCompression;
51
52 // 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
54 options.max_open_files = 80;
55
56 // Register our directory with the file thread.
57 LevelDBFileThread::OpaqueDir* dir =
58 thread_->RegisterDirectory(std::move(directory));
59
60 scoped_ptr<MojoEnv> env_mojo(new MojoEnv(thread_, dir));
61 options.env = env_mojo.get();
62
63 leveldb::DB* db = nullptr;
64 leveldb::Status s = leveldb::DB::Open(options, dbname.To<std::string>(), &db);
65
66 if (s.ok()) {
67 new LevelDBDatabaseImpl(std::move(database), std::move(env_mojo),
68 scoped_ptr<leveldb::DB>(db));
69 }
70
71 callback.Run(LeveldbStatusToError(s));
31 } 72 }
32 73
33 } // namespace leveldb 74 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/leveldb/leveldb_app.h ('k') | components/leveldb/leveldb_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698