OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/security_key/fake_remote_security_key_message_writer.h" |
| 6 |
| 7 #include <string> |
| 8 #include <utility> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/location.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "remoting/host/security_key/security_key_message.h" |
| 16 |
| 17 namespace remoting { |
| 18 |
| 19 FakeRemoteSecurityKeyMessageWriter::FakeRemoteSecurityKeyMessageWriter( |
| 20 const base::Closure& write_callback) |
| 21 : write_callback_(write_callback), weak_factory_(this) { |
| 22 DCHECK(!write_callback_.is_null()); |
| 23 } |
| 24 |
| 25 FakeRemoteSecurityKeyMessageWriter::~FakeRemoteSecurityKeyMessageWriter() {} |
| 26 |
| 27 base::WeakPtr<FakeRemoteSecurityKeyMessageWriter> |
| 28 FakeRemoteSecurityKeyMessageWriter::AsWeakPtr() { |
| 29 return weak_factory_.GetWeakPtr(); |
| 30 } |
| 31 |
| 32 bool FakeRemoteSecurityKeyMessageWriter::WriteMessage( |
| 33 RemoteSecurityKeyMessageType message_type) { |
| 34 last_message_type_ = message_type; |
| 35 last_message_payload_.clear(); |
| 36 |
| 37 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, write_callback_); |
| 38 |
| 39 return write_request_succeeded_; |
| 40 } |
| 41 |
| 42 bool FakeRemoteSecurityKeyMessageWriter::WriteMessageWithPayload( |
| 43 RemoteSecurityKeyMessageType message_type, |
| 44 const std::string& message_payload) { |
| 45 last_message_type_ = message_type; |
| 46 last_message_payload_ = message_payload; |
| 47 |
| 48 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, write_callback_); |
| 49 |
| 50 return write_request_succeeded_; |
| 51 } |
| 52 |
| 53 } // namespace remoting |
OLD | NEW |