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

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

Issue 1708253004: mojo: Get mojo:leveldb and mojo:filesystem compiled into content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Probable fix to the build flake. 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/env_mojo.h" 7 #include "components/leveldb/leveldb_service_impl.h"
8 #include "components/leveldb/leveldb_database_impl.h"
9 #include "components/leveldb/util.h"
10 #include "mojo/shell/public/cpp/connection.h" 8 #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"
16 9
17 namespace leveldb { 10 namespace leveldb {
18 11
19 LevelDBApp::LevelDBApp() {} 12 LevelDBApp::LevelDBApp() {}
20 13
21 LevelDBApp::~LevelDBApp() {} 14 LevelDBApp::~LevelDBApp() {}
22 15
23 void LevelDBApp::Initialize(mojo::Shell* shell, 16 void LevelDBApp::Initialize(mojo::Shell* shell,
24 const std::string& url, 17 const std::string& url,
25 uint32_t id) { 18 uint32_t id) {
26 tracing_.Initialize(shell, url); 19 tracing_.Initialize(shell, url);
27 thread_ = new LevelDBFileThread; 20 service_.reset(new LevelDBServiceImpl);
28 } 21 }
29 22
30 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) { 23 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) {
31 connection->AddInterface<LevelDBService>(this); 24 connection->AddInterface<LevelDBService>(this);
32 return true; 25 return true;
33 } 26 }
34 27
35 void LevelDBApp::Create(mojo::Connection* connection, 28 void LevelDBApp::Create(mojo::Connection* connection,
36 mojo::InterfaceRequest<LevelDBService> request) { 29 mojo::InterfaceRequest<LevelDBService> request) {
37 bindings_.AddBinding(this, std::move(request)); 30 bindings_.AddBinding(service_.get(), 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));
72 } 31 }
73 32
74 } // namespace leveldb 33 } // 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