| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "mojo/edk/embedder/named_platform_handle.h" |
| 14 #include "remoting/host/security_key/security_key_auth_handler.h" | 15 #include "remoting/host/security_key/security_key_auth_handler.h" |
| 15 | 16 |
| 16 namespace remoting { | 17 namespace remoting { |
| 17 | 18 |
| 18 class ClientSessionDetails; | 19 class ClientSessionDetails; |
| 19 class SecurityKeyIpcServerFactory; | 20 class SecurityKeyIpcServerFactory; |
| 20 | 21 |
| 21 // Responsible for handing the server end of the IPC channel between the | 22 // Responsible for handing the server end of the IPC channel between the |
| 22 // network process (server) and the remote_security_key process (client). | 23 // network process (server) and the remote_security_key process (client). |
| 23 class SecurityKeyIpcServer { | 24 class SecurityKeyIpcServer { |
| 24 public: | 25 public: |
| 25 virtual ~SecurityKeyIpcServer() {} | 26 virtual ~SecurityKeyIpcServer() {} |
| 26 | 27 |
| 27 // Creates a new SecurityKeyIpcServer instance. | 28 // Creates a new SecurityKeyIpcServer instance. |
| 28 static std::unique_ptr<SecurityKeyIpcServer> Create( | 29 static std::unique_ptr<SecurityKeyIpcServer> Create( |
| 29 int connection_id, | 30 int connection_id, |
| 30 ClientSessionDetails* client_session_details, | 31 ClientSessionDetails* client_session_details, |
| 31 base::TimeDelta initial_connect_timeout, | 32 base::TimeDelta initial_connect_timeout, |
| 32 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, | 33 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, |
| 34 const base::Closure& connect_callback, |
| 33 const base::Closure& done_callback); | 35 const base::Closure& done_callback); |
| 34 | 36 |
| 35 // Used to set a Factory to generate fake/mock SecurityKeyIpcServer | 37 // Used to set a Factory to generate fake/mock SecurityKeyIpcServer |
| 36 // instances for testing. | 38 // instances for testing. |
| 37 static void SetFactoryForTest(SecurityKeyIpcServerFactory* factory); | 39 static void SetFactoryForTest(SecurityKeyIpcServerFactory* factory); |
| 38 | 40 |
| 39 // Creates and starts listening on an IPC channel with the given name. | 41 // Creates and starts listening on an IPC channel with the given name. |
| 40 virtual bool CreateChannel(const std::string& channel_name, | 42 virtual bool CreateChannel( |
| 41 base::TimeDelta request_timeout) = 0; | 43 const mojo::edk::NamedPlatformHandle& channel_handle, |
| 44 base::TimeDelta request_timeout) = 0; |
| 42 | 45 |
| 43 // Sends a security key response IPC message via the IPC channel. | 46 // Sends a security key response IPC message via the IPC channel. |
| 44 virtual bool SendResponse(const std::string& message_data) = 0; | 47 virtual bool SendResponse(const std::string& message_data) = 0; |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 // Used to allow for creating Fake/Mock SecurityKeyIpcServer for testing. | 50 // Used to allow for creating Fake/Mock SecurityKeyIpcServer for testing. |
| 48 class SecurityKeyIpcServerFactory { | 51 class SecurityKeyIpcServerFactory { |
| 49 public: | 52 public: |
| 50 virtual ~SecurityKeyIpcServerFactory() {} | 53 virtual ~SecurityKeyIpcServerFactory() {} |
| 51 | 54 |
| 52 virtual std::unique_ptr<SecurityKeyIpcServer> Create( | 55 virtual std::unique_ptr<SecurityKeyIpcServer> Create( |
| 53 int connection_id, | 56 int connection_id, |
| 54 ClientSessionDetails* client_session_details, | 57 ClientSessionDetails* client_session_details, |
| 55 base::TimeDelta connect_timeout, | 58 base::TimeDelta connect_timeout, |
| 56 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, | 59 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, |
| 60 const base::Closure& connect_callback, |
| 57 const base::Closure& done_callback) = 0; | 61 const base::Closure& done_callback) = 0; |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 } // namespace remoting | 64 } // namespace remoting |
| 61 | 65 |
| 62 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ | 66 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_H_ |
| OLD | NEW |