| 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_remote_security_key_ipc_client.h" | 5 #include "remoting/host/security_key/fake_remote_security_key_ipc_client.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 11 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 12 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
| 13 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 14 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
| 15 #include "remoting/host/chromoting_messages.h" | 16 #include "remoting/host/chromoting_messages.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 FakeRemoteSecurityKeyIpcClient::FakeRemoteSecurityKeyIpcClient( | 20 FakeRemoteSecurityKeyIpcClient::FakeRemoteSecurityKeyIpcClient( |
| 20 const base::Closure& channel_event_callback) | 21 const base::Closure& channel_event_callback) |
| 21 : channel_event_callback_(channel_event_callback) { | 22 : channel_event_callback_(channel_event_callback), weak_factory_(this) { |
| 22 DCHECK(!channel_event_callback_.is_null()); | 23 DCHECK(!channel_event_callback_.is_null()); |
| 23 } | 24 } |
| 24 | 25 |
| 25 FakeRemoteSecurityKeyIpcClient::~FakeRemoteSecurityKeyIpcClient() {} | 26 FakeRemoteSecurityKeyIpcClient::~FakeRemoteSecurityKeyIpcClient() {} |
| 26 | 27 |
| 28 base::WeakPtr<FakeRemoteSecurityKeyIpcClient> |
| 29 FakeRemoteSecurityKeyIpcClient::AsWeakPtr() { |
| 30 return weak_factory_.GetWeakPtr(); |
| 31 } |
| 32 |
| 27 bool FakeRemoteSecurityKeyIpcClient::WaitForSecurityKeyIpcServerChannel() { | 33 bool FakeRemoteSecurityKeyIpcClient::WaitForSecurityKeyIpcServerChannel() { |
| 28 return wait_for_ipc_channel_return_value_; | 34 return wait_for_ipc_channel_return_value_; |
| 29 } | 35 } |
| 30 | 36 |
| 31 void FakeRemoteSecurityKeyIpcClient::EstablishIpcConnection( | 37 void FakeRemoteSecurityKeyIpcClient::EstablishIpcConnection( |
| 32 const base::Closure& connection_ready_callback, | 38 const base::Closure& connection_ready_callback, |
| 33 const base::Closure& connection_error_callback) { | 39 const base::Closure& connection_error_callback) { |
| 34 if (establish_ipc_connection_should_succeed_) { | 40 if (establish_ipc_connection_should_succeed_) { |
| 35 connection_ready_callback.Run(); | 41 connection_ready_callback.Run(); |
| 36 } else { | 42 } else { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 channel_event_callback_.Run(); | 118 channel_event_callback_.Run(); |
| 113 } | 119 } |
| 114 | 120 |
| 115 void FakeRemoteSecurityKeyIpcClient::OnSecurityKeyResponse( | 121 void FakeRemoteSecurityKeyIpcClient::OnSecurityKeyResponse( |
| 116 const std::string& request_data) { | 122 const std::string& request_data) { |
| 117 last_message_received_ = request_data; | 123 last_message_received_ = request_data; |
| 118 channel_event_callback_.Run(); | 124 channel_event_callback_.Run(); |
| 119 } | 125 } |
| 120 | 126 |
| 121 } // namespace remoting | 127 } // namespace remoting |
| OLD | NEW |