| 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 #include "remoting/host/security_key/fake_security_key_ipc_server.h" | 5 #include "remoting/host/security_key/fake_security_key_ipc_server.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" |
| 16 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
| 17 #include "remoting/host/chromoting_messages.h" | 17 #include "remoting/host/chromoting_messages.h" |
| 18 #include "remoting/host/security_key/security_key_auth_handler.h" | 18 #include "remoting/host/security_key/security_key_auth_handler.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace remoting { | 21 namespace remoting { |
| 22 | 22 |
| 23 FakeSecurityKeyIpcServer::FakeSecurityKeyIpcServer( | 23 FakeSecurityKeyIpcServer::FakeSecurityKeyIpcServer( |
| 24 int connection_id, | 24 int connection_id, |
| 25 uint32_t peer_session_id, | 25 ClientSessionDetails* client_session_details, |
| 26 base::TimeDelta initial_connect_timeout, | 26 base::TimeDelta initial_connect_timeout, |
| 27 const SecurityKeyAuthHandler::SendMessageCallback& send_message_callback, | 27 const SecurityKeyAuthHandler::SendMessageCallback& send_message_callback, |
| 28 const base::Closure& channel_closed_callback) | 28 const base::Closure& channel_closed_callback) |
| 29 : connection_id_(connection_id), | 29 : connection_id_(connection_id), |
| 30 send_message_callback_(send_message_callback), | 30 send_message_callback_(send_message_callback), |
| 31 channel_closed_callback_(channel_closed_callback), | 31 channel_closed_callback_(channel_closed_callback), |
| 32 weak_factory_(this) {} | 32 weak_factory_(this) {} |
| 33 | 33 |
| 34 FakeSecurityKeyIpcServer::~FakeSecurityKeyIpcServer() {} | 34 FakeSecurityKeyIpcServer::~FakeSecurityKeyIpcServer() {} |
| 35 | 35 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 FakeSecurityKeyIpcServerFactory::FakeSecurityKeyIpcServerFactory() { | 91 FakeSecurityKeyIpcServerFactory::FakeSecurityKeyIpcServerFactory() { |
| 92 SecurityKeyIpcServer::SetFactoryForTest(this); | 92 SecurityKeyIpcServer::SetFactoryForTest(this); |
| 93 } | 93 } |
| 94 | 94 |
| 95 FakeSecurityKeyIpcServerFactory::~FakeSecurityKeyIpcServerFactory() { | 95 FakeSecurityKeyIpcServerFactory::~FakeSecurityKeyIpcServerFactory() { |
| 96 SecurityKeyIpcServer::SetFactoryForTest(nullptr); | 96 SecurityKeyIpcServer::SetFactoryForTest(nullptr); |
| 97 } | 97 } |
| 98 | 98 |
| 99 std::unique_ptr<SecurityKeyIpcServer> FakeSecurityKeyIpcServerFactory::Create( | 99 std::unique_ptr<SecurityKeyIpcServer> FakeSecurityKeyIpcServerFactory::Create( |
| 100 int connection_id, | 100 int connection_id, |
| 101 uint32_t peer_session_id, | 101 ClientSessionDetails* client_session_details, |
| 102 base::TimeDelta initial_connect_timeout, | 102 base::TimeDelta initial_connect_timeout, |
| 103 const SecurityKeyAuthHandler::SendMessageCallback& send_message_callback, | 103 const SecurityKeyAuthHandler::SendMessageCallback& send_message_callback, |
| 104 const base::Closure& done_callback) { | 104 const base::Closure& done_callback) { |
| 105 std::unique_ptr<FakeSecurityKeyIpcServer> fake_ipc_server( | 105 std::unique_ptr<FakeSecurityKeyIpcServer> fake_ipc_server( |
| 106 new FakeSecurityKeyIpcServer(connection_id, peer_session_id, | 106 new FakeSecurityKeyIpcServer(connection_id, client_session_details, |
| 107 initial_connect_timeout, | 107 initial_connect_timeout, |
| 108 send_message_callback, done_callback)); | 108 send_message_callback, done_callback)); |
| 109 | 109 |
| 110 ipc_server_map_[connection_id] = fake_ipc_server->AsWeakPtr(); | 110 ipc_server_map_[connection_id] = fake_ipc_server->AsWeakPtr(); |
| 111 | 111 |
| 112 return base::WrapUnique(fake_ipc_server.release()); | 112 return base::WrapUnique(fake_ipc_server.release()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 base::WeakPtr<FakeSecurityKeyIpcServer> | 115 base::WeakPtr<FakeSecurityKeyIpcServer> |
| 116 FakeSecurityKeyIpcServerFactory::GetIpcServerObject(int connection_id) { | 116 FakeSecurityKeyIpcServerFactory::GetIpcServerObject(int connection_id) { |
| 117 return ipc_server_map_[connection_id]; | 117 return ipc_server_map_[connection_id]; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace remoting | 120 } // namespace remoting |
| OLD | NEW |