| Index: remoting/host/security_key/fake_remote_security_key_message_writer.cc
|
| diff --git a/remoting/host/security_key/fake_remote_security_key_message_writer.cc b/remoting/host/security_key/fake_remote_security_key_message_writer.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ccfd05bc0629fe56d64bb34f977a9ec366fff1e7
|
| --- /dev/null
|
| +++ b/remoting/host/security_key/fake_remote_security_key_message_writer.cc
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "remoting/host/security_key/fake_remote_security_key_message_writer.h"
|
| +
|
| +#include <string>
|
| +#include <utility>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/location.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| +#include "remoting/host/security_key/security_key_message.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +FakeRemoteSecurityKeyMessageWriter::FakeRemoteSecurityKeyMessageWriter(
|
| + const base::Closure& write_callback)
|
| + : write_callback_(write_callback), weak_factory_(this) {
|
| + DCHECK(!write_callback_.is_null());
|
| +}
|
| +
|
| +FakeRemoteSecurityKeyMessageWriter::~FakeRemoteSecurityKeyMessageWriter() {}
|
| +
|
| +base::WeakPtr<FakeRemoteSecurityKeyMessageWriter>
|
| +FakeRemoteSecurityKeyMessageWriter::AsWeakPtr() {
|
| + return weak_factory_.GetWeakPtr();
|
| +}
|
| +
|
| +bool FakeRemoteSecurityKeyMessageWriter::WriteMessage(
|
| + RemoteSecurityKeyMessageType message_type) {
|
| + last_message_type_ = message_type;
|
| + last_message_payload_.clear();
|
| +
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, write_callback_);
|
| +
|
| + return write_request_succeeded_;
|
| +}
|
| +
|
| +bool FakeRemoteSecurityKeyMessageWriter::WriteMessageWithPayload(
|
| + RemoteSecurityKeyMessageType message_type,
|
| + const std::string& message_payload) {
|
| + last_message_type_ = message_type;
|
| + last_message_payload_ = message_payload;
|
| +
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, write_callback_);
|
| +
|
| + return write_request_succeeded_;
|
| +}
|
| +
|
| +} // namespace remoting
|
|
|