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