summaryrefslogtreecommitdiffstats
path: root/components/leveldb/leveldb_app.h
blob: d1cd6840ab8e12731039ea296b7b6fbc42e512bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_LEVELDB_LEVELDB_APP_H_
#define COMPONENTS_LEVELDB_LEVELDB_APP_H_

#include "components/leveldb/public/interfaces/leveldb.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
#include "mojo/shell/public/cpp/interface_factory.h"
#include "mojo/shell/public/cpp/shell_client.h"

namespace leveldb {

class LevelDBApp : public mojo::ShellClient,
                   public mojo::InterfaceFactory<LevelDBService> {
 public:
  LevelDBApp();
  ~LevelDBApp() override;

 private:
  // |ShellClient| override:
  void Initialize(mojo::Shell* shell,
                  const std::string& url,
                  uint32_t id,
                  uint32_t user_id) override;
  bool AcceptConnection(mojo::Connection* connection) override;

  // TODO(erg): What do we have to do on shell error?
  // bool OnShellConnectionError() override;

  // |InterfaceFactory<LevelDBService>| implementation:
  void Create(mojo::Connection* connection,
              mojo::InterfaceRequest<LevelDBService> request) override;

  mojo::TracingImpl tracing_;
  scoped_ptr<LevelDBService> service_;
  mojo::BindingSet<LevelDBService> bindings_;

  DISALLOW_COPY_AND_ASSIGN(LevelDBApp);
};

}  // namespace leveldb

#endif  // COMPONENTS_LEVELDB_LEVELDB_APP_H_