| 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_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
| 7 | 7 |
| 8 #include "remoting/host/security_key/remote_security_key_ipc_server.h" | 8 #include "remoting/host/security_key/remote_security_key_ipc_server.h" |
| 9 | 9 |
| 10 #include <cstdint> |
| 10 #include <map> | 11 #include <map> |
| 11 #include <memory> | 12 #include <memory> |
| 12 #include <string> | 13 #include <string> |
| 13 | 14 |
| 14 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 17 #include "ipc/ipc_listener.h" | 18 #include "ipc/ipc_listener.h" |
| 18 | 19 |
| 19 namespace IPC { | 20 namespace IPC { |
| 20 class Channel; | 21 class Channel; |
| 21 class Message; | 22 class Message; |
| 22 } // IPC | 23 } // IPC |
| 23 | 24 |
| 24 namespace remoting { | 25 namespace remoting { |
| 25 | 26 |
| 26 // Used to send/receive security key messages for testing. It provides a | 27 // Used to send/receive security key messages for testing. It provides a |
| 27 // WeakPtr reference to itself which allows tests to verify its lifetime is | 28 // WeakPtr reference to itself which allows tests to verify its lifetime is |
| 28 // managed properly without interfering with it. | 29 // managed properly without interfering with it. |
| 29 class FakeRemoteSecurityKeyIpcServer : public RemoteSecurityKeyIpcServer, | 30 class FakeRemoteSecurityKeyIpcServer : public RemoteSecurityKeyIpcServer, |
| 30 public IPC::Listener { | 31 public IPC::Listener { |
| 31 public: | 32 public: |
| 32 FakeRemoteSecurityKeyIpcServer( | 33 FakeRemoteSecurityKeyIpcServer( |
| 33 int connection_id, | 34 int connection_id, |
| 35 uint32_t peer_session_id, |
| 34 base::TimeDelta initial_connect_timeout, | 36 base::TimeDelta initial_connect_timeout, |
| 35 const GnubbyAuthHandler::SendMessageCallback& send_message_callback, | 37 const GnubbyAuthHandler::SendMessageCallback& send_message_callback, |
| 36 const base::Closure& channel_closed_callback); | 38 const base::Closure& channel_closed_callback); |
| 37 ~FakeRemoteSecurityKeyIpcServer() override; | 39 ~FakeRemoteSecurityKeyIpcServer() override; |
| 38 | 40 |
| 39 // RemoteSecurityKeyIpcServer interface. | 41 // RemoteSecurityKeyIpcServer interface. |
| 40 bool CreateChannel(const std::string& channel_name, | 42 bool CreateChannel(const std::string& channel_name, |
| 41 base::TimeDelta request_timeout) override; | 43 base::TimeDelta request_timeout) override; |
| 42 bool SendResponse(const std::string& message_data) override; | 44 bool SendResponse(const std::string& message_data) override; |
| 43 | 45 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // verify the backing instance is destroyed at the appropriate time. | 106 // verify the backing instance is destroyed at the appropriate time. |
| 105 class FakeRemoteSecurityKeyIpcServerFactory | 107 class FakeRemoteSecurityKeyIpcServerFactory |
| 106 : public RemoteSecurityKeyIpcServerFactory { | 108 : public RemoteSecurityKeyIpcServerFactory { |
| 107 public: | 109 public: |
| 108 FakeRemoteSecurityKeyIpcServerFactory(); | 110 FakeRemoteSecurityKeyIpcServerFactory(); |
| 109 ~FakeRemoteSecurityKeyIpcServerFactory() override; | 111 ~FakeRemoteSecurityKeyIpcServerFactory() override; |
| 110 | 112 |
| 111 // RemoteSecurityKeyIpcServerFactory implementation. | 113 // RemoteSecurityKeyIpcServerFactory implementation. |
| 112 std::unique_ptr<RemoteSecurityKeyIpcServer> Create( | 114 std::unique_ptr<RemoteSecurityKeyIpcServer> Create( |
| 113 int connection_id, | 115 int connection_id, |
| 116 uint32_t peer_session_id, |
| 114 base::TimeDelta initial_connect_timeout, | 117 base::TimeDelta initial_connect_timeout, |
| 115 const GnubbyAuthHandler::SendMessageCallback& message_callback, | 118 const GnubbyAuthHandler::SendMessageCallback& message_callback, |
| 116 const base::Closure& done_callback) override; | 119 const base::Closure& done_callback) override; |
| 117 | 120 |
| 118 // Provide a WeakPtr reference to the FakeRemoteSecurityKeyIpcServer object | 121 // Provide a WeakPtr reference to the FakeRemoteSecurityKeyIpcServer object |
| 119 // created for the |connection_id| IPC channel. | 122 // created for the |connection_id| IPC channel. |
| 120 base::WeakPtr<FakeRemoteSecurityKeyIpcServer> GetIpcServerObject( | 123 base::WeakPtr<FakeRemoteSecurityKeyIpcServer> GetIpcServerObject( |
| 121 int connection_id); | 124 int connection_id); |
| 122 | 125 |
| 123 private: | 126 private: |
| 124 // Tracks each FakeRemoteSecurityKeyIpcServer instance created by this | 127 // Tracks each FakeRemoteSecurityKeyIpcServer instance created by this |
| 125 // factory which allows them to be retrieved and queried for tests. | 128 // factory which allows them to be retrieved and queried for tests. |
| 126 std::map<int, base::WeakPtr<FakeRemoteSecurityKeyIpcServer>> ipc_server_map_; | 129 std::map<int, base::WeakPtr<FakeRemoteSecurityKeyIpcServer>> ipc_server_map_; |
| 127 | 130 |
| 128 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServerFactory); | 131 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServerFactory); |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 } // namespace remoting | 134 } // namespace remoting |
| 132 | 135 |
| 133 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 136 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
| OLD | NEW |