OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ | |
6 #define MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <set> | |
11 #include <string> | |
12 | |
13 #include "mojo/public/cpp/bindings/binding.h" | |
14 #include "mojo/shell/public/cpp/capabilities.h" | |
15 #include "mojo/shell/public/cpp/connection.h" | |
16 #include "mojo/shell/public/cpp/identity.h" | |
17 #include "mojo/shell/public/interfaces/connector.mojom.h" | |
18 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" | |
19 | |
20 namespace mojo { | |
21 namespace internal { | |
22 | |
23 // A ConnectionImpl represents each half of a connection between two | |
24 // applications, allowing customization of which interfaces are published to the | |
25 // other. | |
26 class ConnectionImpl : public Connection { | |
27 public: | |
28 ConnectionImpl(); | |
29 // |allowed_interfaces| are the set of interfaces that the shell has allowed | |
30 // an application to expose to another application. If this set contains only | |
31 // the string value "*" all interfaces may be exposed. | |
32 ConnectionImpl(const std::string& connection_name, | |
33 const Identity& remote, | |
34 uint32_t remote_id, | |
35 shell::mojom::InterfaceProviderPtr remote_interfaces, | |
36 shell::mojom::InterfaceProviderRequest local_interfaces, | |
37 const CapabilityRequest& capability_request, | |
38 State initial_state); | |
39 ~ConnectionImpl() override; | |
40 | |
41 shell::mojom::Connector::ConnectCallback GetConnectCallback(); | |
42 | |
43 private: | |
44 // Connection: | |
45 bool HasCapabilityClass(const std::string& class_name) const override; | |
46 const std::string& GetConnectionName() override; | |
47 const Identity& GetRemoteIdentity() const override; | |
48 void SetConnectionLostClosure(const Closure& handler) override; | |
49 shell::mojom::ConnectResult GetResult() const override; | |
50 bool IsPending() const override; | |
51 uint32_t GetRemoteInstanceID() const override; | |
52 void AddConnectionCompletedClosure(const Closure& callback) override; | |
53 bool AllowsInterface(const std::string& interface_name) const override; | |
54 shell::mojom::InterfaceProvider* GetRemoteInterfaces() override; | |
55 InterfaceRegistry* GetLocalRegistry() override; | |
56 base::WeakPtr<Connection> GetWeakPtr() override; | |
57 | |
58 void OnConnectionCompleted(shell::mojom::ConnectResult result, | |
59 const std::string& target_user_id, | |
60 uint32_t target_application_id); | |
61 | |
62 const std::string connection_name_; | |
63 Identity remote_; | |
64 uint32_t remote_id_ = shell::mojom::kInvalidInstanceID; | |
65 | |
66 State state_; | |
67 shell::mojom::ConnectResult result_ = shell::mojom::ConnectResult::SUCCEEDED; | |
68 std::vector<Closure> connection_completed_callbacks_; | |
69 | |
70 InterfaceRegistry local_registry_; | |
71 shell::mojom::InterfaceProviderPtr remote_interfaces_; | |
72 | |
73 const CapabilityRequest capability_request_; | |
74 const bool allow_all_interfaces_; | |
75 | |
76 base::WeakPtrFactory<ConnectionImpl> weak_factory_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(ConnectionImpl); | |
79 }; | |
80 | |
81 } // namespace internal | |
82 } // namespace mojo | |
83 | |
84 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ | |
OLD | NEW |