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