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