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 #ifndef MASH_INIT_INIT_H_ | 5 #ifndef MASH_INIT_INIT_H_ |
6 #define MASH_INIT_INIT_H_ | 6 #define MASH_INIT_INIT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "mash/init/public/interfaces/init.mojom.h" | 13 #include "mash/init/public/interfaces/init.mojom.h" |
14 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
15 #include "services/service_manager/public/cpp/connector.h" | 15 #include "services/service_manager/public/cpp/connector.h" |
16 #include "services/service_manager/public/cpp/interface_factory.h" | 16 #include "services/service_manager/public/cpp/interface_factory.h" |
17 #include "services/service_manager/public/cpp/service.h" | 17 #include "services/service_manager/public/cpp/service.h" |
18 | 18 |
19 namespace service_manager { | 19 namespace service_manager { |
20 class Connection; | 20 class Connection; |
| 21 class ServiceContext; |
21 } | 22 } |
22 | 23 |
23 namespace mash { | 24 namespace mash { |
24 namespace init { | 25 namespace init { |
25 | 26 |
26 class Init : public service_manager::Service, | 27 class Init : public service_manager::Service, |
27 public service_manager::InterfaceFactory<mojom::Init>, | 28 public service_manager::InterfaceFactory<mojom::Init>, |
28 public mojom::Init { | 29 public mojom::Init { |
29 public: | 30 public: |
30 Init(); | 31 Init(); |
31 ~Init() override; | 32 ~Init() override; |
32 | 33 |
33 private: | 34 private: |
34 // service_manager::Service: | 35 // service_manager::Service: |
35 void OnStart() override; | 36 void OnStart(service_manager::ServiceContext* context) override; |
36 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 37 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
37 service_manager::InterfaceRegistry* registry) override; | 38 service_manager::InterfaceRegistry* registry) override; |
38 | 39 |
39 // service_manager::InterfaceFactory<mojom::Login>: | 40 // service_manager::InterfaceFactory<mojom::Login>: |
40 void Create(const service_manager::Identity& remote_identity, | 41 void Create(const service_manager::Identity& remote_identity, |
41 mojom::InitRequest request) override; | 42 mojom::InitRequest request) override; |
42 | 43 |
43 // mojom::Init: | 44 // mojom::Init: |
44 void StartService(const std::string& name, | 45 void StartService(const std::string& name, |
45 const std::string& user_id) override; | 46 const std::string& user_id) override; |
46 void StopServicesForUser(const std::string& user_id) override; | 47 void StopServicesForUser(const std::string& user_id) override; |
47 | 48 |
48 void UserServiceQuit(const std::string& user_id); | 49 void UserServiceQuit(const std::string& user_id); |
49 | 50 |
50 void StartTracing(); | 51 void StartTracing(); |
51 void StartLogin(); | 52 void StartLogin(); |
52 | 53 |
| 54 service_manager::ServiceContext* context_ = nullptr; |
| 55 |
53 std::unique_ptr<service_manager::Connection> login_connection_; | 56 std::unique_ptr<service_manager::Connection> login_connection_; |
54 mojo::BindingSet<mojom::Init> init_bindings_; | 57 mojo::BindingSet<mojom::Init> init_bindings_; |
55 std::map<std::string, std::unique_ptr<service_manager::Connection>> | 58 std::map<std::string, std::unique_ptr<service_manager::Connection>> |
56 user_services_; | 59 user_services_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(Init); | 61 DISALLOW_COPY_AND_ASSIGN(Init); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace init | 64 } // namespace init |
62 } // namespace mash | 65 } // namespace mash |
63 | 66 |
64 #endif // MASH_INIT_INIT_H_ | 67 #endif // MASH_INIT_INIT_H_ |
OLD | NEW |