Chromium Code Reviews

Side by Side Diff: services/service_manager/public/cpp/lib/connector_impl.h

Issue 2804373002: Eliminate Connector::Connect(), Connection, etc. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 #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 <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "services/service_manager/public/cpp/connector.h" 13 #include "services/service_manager/public/cpp/connector.h"
14 #include "services/service_manager/public/interfaces/connector.mojom.h" 14 #include "services/service_manager/public/interfaces/connector.mojom.h"
15 15
16 namespace service_manager { 16 namespace service_manager {
17 17
18 class ConnectorImpl : public Connector { 18 class ConnectorImpl : public Connector {
19 public: 19 public:
20 explicit ConnectorImpl(mojom::ConnectorPtrInfo unbound_state); 20 explicit ConnectorImpl(mojom::ConnectorPtrInfo unbound_state);
21 explicit ConnectorImpl(mojom::ConnectorPtr connector); 21 explicit ConnectorImpl(mojom::ConnectorPtr connector);
22 ~ConnectorImpl() override; 22 ~ConnectorImpl() override;
23 23
24 private: 24 private:
25 void OnConnectionError(); 25 void OnConnectionError();
26 26
27 // Connector: 27 // Connector:
28 void StartService(const Identity& identity) override;
29 void StartService(const std::string& name) override;
28 void StartService(const Identity& identity, 30 void StartService(const Identity& identity,
29 mojom::ServicePtr service, 31 mojom::ServicePtr service,
30 mojom::PIDReceiverRequest pid_receiver_request) override; 32 mojom::PIDReceiverRequest pid_receiver_request) override;
31 std::unique_ptr<Connection> Connect(const std::string& name) override;
32 std::unique_ptr<Connection> Connect(const Identity& target) override;
33 void BindInterface(const Identity& target, 33 void BindInterface(const Identity& target,
34 const std::string& interface_name, 34 const std::string& interface_name,
35 mojo::ScopedMessagePipeHandle interface_pipe) override; 35 mojo::ScopedMessagePipeHandle interface_pipe) override;
36 std::unique_ptr<Connector> Clone() override; 36 std::unique_ptr<Connector> Clone() override;
37 void BindConnectorRequest(mojom::ConnectorRequest request) override; 37 void BindConnectorRequest(mojom::ConnectorRequest request) override;
38 base::WeakPtr<Connector> GetWeakPtr() override; 38 base::WeakPtr<Connector> GetWeakPtr() override;
39 void OverrideBinderForTesting(const std::string& service_name, 39 void OverrideBinderForTesting(const std::string& service_name,
40 const std::string& interface_name, 40 const std::string& interface_name,
41 const TestApi::Binder& binder) override; 41 const TestApi::Binder& binder) override;
42 void ClearBinderOverrides() override; 42 void ClearBinderOverrides() override;
43 void SetStartServiceCallback(const StartServiceCallback& callback) override;
44 void ResetStartServiceCallback() override;
43 45
44 bool BindConnectorIfNecessary(); 46 bool BindConnectorIfNecessary();
45 47
48 // Callback passed to mojom methods StartService()/BindInterface().
49 void StartServiceCallback(mojom::ConnectResult result,
50 const Identity& user_id);
51
46 using BinderOverrideMap = std::map<std::string, TestApi::Binder>; 52 using BinderOverrideMap = std::map<std::string, TestApi::Binder>;
47 53
48 mojom::ConnectorPtrInfo unbound_state_; 54 mojom::ConnectorPtrInfo unbound_state_;
49 mojom::ConnectorPtr connector_; 55 mojom::ConnectorPtr connector_;
50 56
51 base::ThreadChecker thread_checker_; 57 base::ThreadChecker thread_checker_;
52 58
53 std::map<std::string, BinderOverrideMap> local_binder_overrides_; 59 std::map<std::string, BinderOverrideMap> local_binder_overrides_;
60 Connector::StartServiceCallback start_service_callback_;
54 61
55 base::WeakPtrFactory<Connector> weak_factory_; 62 base::WeakPtrFactory<ConnectorImpl> weak_factory_;
56 63
57 DISALLOW_COPY_AND_ASSIGN(ConnectorImpl); 64 DISALLOW_COPY_AND_ASSIGN(ConnectorImpl);
58 }; 65 };
59 66
60 } // namespace service_manager 67 } // namespace service_manager
61 68
62 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_ 69 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTOR_IMPL_H_
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/lib/connection_impl.cc ('k') | services/service_manager/public/cpp/lib/connector_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine