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

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

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keeping up with the ToT Created 4 years, 9 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
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 "base/bind.h"
8 #include "base/message_loop/message_loop.h"
7 #include "components/leveldb/leveldb_service_impl.h" 9 #include "components/leveldb/leveldb_service_impl.h"
8 #include "mojo/shell/public/cpp/connection.h" 10 #include "mojo/shell/public/cpp/connection.h"
9 11
10 namespace leveldb { 12 namespace leveldb {
11 13
12 LevelDBApp::LevelDBApp() {} 14 scoped_ptr<mojo::ShellClient> CreateLevelDBApp() {
15 return make_scoped_ptr(new LevelDBApp);
16 }
17
18 LevelDBApp::LevelDBApp()
19 : outstanding_bindings_(0) {
20 bindings_.set_connection_error_handler(
21 base::Bind(&LevelDBApp::OnConnectionError, base::Unretained(this)));
22 }
13 23
14 LevelDBApp::~LevelDBApp() {} 24 LevelDBApp::~LevelDBApp() {}
15 25
26 void LevelDBApp::OnConnectionError() {
27 outstanding_bindings_--;
28 if (outstanding_bindings_ == 0)
29 base::MessageLoop::current()->QuitNow();
30 }
31
16 void LevelDBApp::Initialize(mojo::Connector* connector, 32 void LevelDBApp::Initialize(mojo::Connector* connector,
17 const std::string& url, 33 const std::string& url,
18 uint32_t id, 34 uint32_t id,
19 uint32_t user_id) { 35 uint32_t user_id) {
20 tracing_.Initialize(connector, url); 36 tracing_.Initialize(connector, url);
21 service_.reset(new LevelDBServiceImpl); 37 service_.reset(new LevelDBServiceImpl);
22 } 38 }
23 39
24 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) { 40 bool LevelDBApp::AcceptConnection(mojo::Connection* connection) {
25 connection->AddInterface<LevelDBService>(this); 41 connection->AddInterface<LevelDBService>(this);
26 return true; 42 return true;
27 } 43 }
28 44
29 void LevelDBApp::Create(mojo::Connection* connection, 45 void LevelDBApp::Create(mojo::Connection* connection,
30 mojo::InterfaceRequest<LevelDBService> request) { 46 mojo::InterfaceRequest<LevelDBService> request) {
47 outstanding_bindings_++;
31 bindings_.AddBinding(service_.get(), std::move(request)); 48 bindings_.AddBinding(service_.get(), std::move(request));
32 } 49 }
33 50
34 } // namespace leveldb 51 } // namespace leveldb
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698