OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CONNECTION_IMPL_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ |
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
15 #include "services/service_manager/public/cpp/capabilities.h" | 15 #include "services/service_manager/public/cpp/capabilities.h" |
16 #include "services/service_manager/public/cpp/connection.h" | 16 #include "services/service_manager/public/cpp/connection.h" |
17 #include "services/service_manager/public/cpp/identity.h" | 17 #include "services/service_manager/public/cpp/identity.h" |
18 #include "services/service_manager/public/interfaces/connector.mojom.h" | 18 #include "services/service_manager/public/interfaces/connector.mojom.h" |
19 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" | 19 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" |
20 | 20 |
21 namespace shell { | 21 namespace service_manager { |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
24 // A ConnectionImpl represents each half of a connection between two | 24 // A ConnectionImpl represents each half of a connection between two |
25 // applications, allowing customization of which interfaces are published to the | 25 // applications, allowing customization of which interfaces are published to the |
26 // other. | 26 // other. |
27 class ConnectionImpl : public Connection { | 27 class ConnectionImpl : public Connection { |
28 public: | 28 public: |
29 ConnectionImpl(); | 29 ConnectionImpl(); |
30 ConnectionImpl(const Identity& remote, State initial_state); | 30 ConnectionImpl(const Identity& remote, State initial_state); |
31 ~ConnectionImpl() override; | 31 ~ConnectionImpl() override; |
32 | 32 |
33 // Sets the remote provider, transferring ownership to the ConnectionImpl. | 33 // Sets the remote provider, transferring ownership to the ConnectionImpl. |
34 void SetRemoteInterfaces( | 34 void SetRemoteInterfaces( |
35 std::unique_ptr<InterfaceProvider> remote_interfaces); | 35 std::unique_ptr<InterfaceProvider> remote_interfaces); |
36 | 36 |
37 // Sets the remote provider, without transferring ownership. | 37 // Sets the remote provider, without transferring ownership. |
38 void set_remote_interfaces(InterfaceProvider* remote_interfaces) { | 38 void set_remote_interfaces(InterfaceProvider* remote_interfaces) { |
39 remote_interfaces_ = remote_interfaces; | 39 remote_interfaces_ = remote_interfaces; |
40 } | 40 } |
41 | 41 |
42 shell::mojom::Connector::ConnectCallback GetConnectCallback(); | 42 service_manager::mojom::Connector::ConnectCallback GetConnectCallback(); |
43 | 43 |
44 private: | 44 private: |
45 // Connection: | 45 // Connection: |
46 const Identity& GetRemoteIdentity() const override; | 46 const Identity& GetRemoteIdentity() const override; |
47 void SetConnectionLostClosure(const base::Closure& handler) override; | 47 void SetConnectionLostClosure(const base::Closure& handler) override; |
48 shell::mojom::ConnectResult GetResult() const override; | 48 service_manager::mojom::ConnectResult GetResult() const override; |
49 bool IsPending() const override; | 49 bool IsPending() const override; |
50 void AddConnectionCompletedClosure(const base::Closure& callback) override; | 50 void AddConnectionCompletedClosure(const base::Closure& callback) override; |
51 InterfaceProvider* GetRemoteInterfaces() override; | 51 InterfaceProvider* GetRemoteInterfaces() override; |
52 base::WeakPtr<Connection> GetWeakPtr() override; | 52 base::WeakPtr<Connection> GetWeakPtr() override; |
53 | 53 |
54 void OnConnectionCompleted(shell::mojom::ConnectResult result, | 54 void OnConnectionCompleted(service_manager::mojom::ConnectResult result, |
55 const std::string& target_user_id); | 55 const std::string& target_user_id); |
56 | 56 |
57 Identity remote_; | 57 Identity remote_; |
58 | 58 |
59 State state_; | 59 State state_; |
60 shell::mojom::ConnectResult result_ = shell::mojom::ConnectResult::SUCCEEDED; | 60 service_manager::mojom::ConnectResult result_ = |
| 61 service_manager::mojom::ConnectResult::SUCCEEDED; |
61 std::vector<base::Closure> connection_completed_callbacks_; | 62 std::vector<base::Closure> connection_completed_callbacks_; |
62 | 63 |
63 InterfaceProvider* remote_interfaces_ = nullptr; | 64 InterfaceProvider* remote_interfaces_ = nullptr; |
64 | 65 |
65 std::unique_ptr<InterfaceProvider> remote_interfaces_owner_; | 66 std::unique_ptr<InterfaceProvider> remote_interfaces_owner_; |
66 | 67 |
67 base::WeakPtrFactory<ConnectionImpl> weak_factory_; | 68 base::WeakPtrFactory<ConnectionImpl> weak_factory_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(ConnectionImpl); | 70 DISALLOW_COPY_AND_ASSIGN(ConnectionImpl); |
70 }; | 71 }; |
71 | 72 |
72 } // namespace internal | 73 } // namespace internal |
73 } // namespace shell | 74 } // namespace service_manager |
74 | 75 |
75 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ | 76 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ |
OLD | NEW |