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 SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ |
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <memory> | 9 #include <memory> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
12 #include "services/service_manager/public/cpp/connector.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
13 #include "services/service_manager/public/interfaces/connector.mojom.h" | 14 #include "services/service_manager/public/interfaces/connector.mojom.h" |
14 | 15 |
15 namespace service_manager { | 16 namespace service_manager { |
16 | 17 |
17 class ConnectorImpl : public Connector { | 18 class ConnectorImpl : public Connector { |
18 public: | 19 public: |
19 explicit ConnectorImpl(mojom::ConnectorPtrInfo unbound_state); | 20 explicit ConnectorImpl(mojom::ConnectorPtrInfo unbound_state); |
20 explicit ConnectorImpl(mojom::ConnectorPtr connector); | 21 explicit ConnectorImpl(mojom::ConnectorPtr connector); |
21 ~ConnectorImpl() override; | 22 ~ConnectorImpl() override; |
22 | 23 |
23 private: | 24 private: |
24 void OnConnectionError(); | 25 void OnConnectionError(); |
25 | 26 |
26 // Connector: | 27 // Connector: |
27 void StartService(const Identity& identity, | 28 void StartService(const Identity& identity, |
28 mojom::ServicePtr service, | 29 mojom::ServicePtr service, |
29 mojom::PIDReceiverRequest pid_receiver_request) override; | 30 mojom::PIDReceiverRequest pid_receiver_request) override; |
30 std::unique_ptr<Connection> Connect(const std::string& name) override; | 31 std::unique_ptr<Connection> Connect(const std::string& name) override; |
31 std::unique_ptr<Connection> Connect(const Identity& target) override; | 32 std::unique_ptr<Connection> Connect(const Identity& target) override; |
32 void BindInterface(const Identity& target, | 33 void BindInterface(const Identity& target, |
33 const std::string& interface_name, | 34 const std::string& interface_name, |
34 mojo::ScopedMessagePipeHandle interface_pipe) override; | 35 mojo::ScopedMessagePipeHandle interface_pipe) override; |
35 std::unique_ptr<Connector> Clone() override; | 36 std::unique_ptr<Connector> Clone() override; |
36 void BindConnectorRequest(mojom::ConnectorRequest request) override; | 37 void BindConnectorRequest(mojom::ConnectorRequest request) override; |
| 38 base::WeakPtr<Connector> GetWeakPtr() override; |
| 39 void OverrideBinderForTesting(const std::string& interface_name, |
| 40 const TestApi::Binder& binder) override; |
| 41 void ClearBinderOverrides() override; |
37 | 42 |
38 bool BindConnectorIfNecessary(); | 43 bool BindConnectorIfNecessary(); |
39 | 44 |
40 mojom::ConnectorPtrInfo unbound_state_; | 45 mojom::ConnectorPtrInfo unbound_state_; |
41 mojom::ConnectorPtr connector_; | 46 mojom::ConnectorPtr connector_; |
42 | 47 |
43 base::ThreadChecker thread_checker_; | 48 base::ThreadChecker thread_checker_; |
44 | 49 |
| 50 std::map<std::string, TestApi::Binder> local_binder_overrides_; |
| 51 |
| 52 base::WeakPtrFactory<Connector> weak_factory_; |
| 53 |
45 DISALLOW_COPY_AND_ASSIGN(ConnectorImpl); | 54 DISALLOW_COPY_AND_ASSIGN(ConnectorImpl); |
46 }; | 55 }; |
47 | 56 |
48 } // namespace service_manager | 57 } // namespace service_manager |
49 | 58 |
50 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ | 59 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ |
OLD | NEW |