Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: remoting/host/security_key/remote_security_key_message_writer.cc

Issue 2162083003: Renaming Gnubby and RemoteSecurityKey files/classes/members (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a GYP build error Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/security_key/remote_security_key_message_writer.cc
diff --git a/remoting/host/security_key/remote_security_key_message_writer.cc b/remoting/host/security_key/remote_security_key_message_writer.cc
deleted file mode 100644
index 4a9f75e15e6a8cee5eaac2e93adc1f718dd82c38..0000000000000000000000000000000000000000
--- a/remoting/host/security_key/remote_security_key_message_writer.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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/remote_security_key_message_writer.h"
-
-#include <cstdint>
-#include <string>
-#include <utility>
-
-#include "remoting/host/security_key/security_key_message.h"
-
-namespace remoting {
-
-RemoteSecurityKeyMessageWriter::RemoteSecurityKeyMessageWriter(
- base::File output_file)
- : output_stream_(std::move(output_file)) {}
-
-RemoteSecurityKeyMessageWriter::~RemoteSecurityKeyMessageWriter() {}
-
-bool RemoteSecurityKeyMessageWriter::WriteMessage(
- RemoteSecurityKeyMessageType message_type) {
- return WriteMessageWithPayload(message_type, std::string());
-}
-
-bool RemoteSecurityKeyMessageWriter::WriteMessageWithPayload(
- RemoteSecurityKeyMessageType message_type,
- const std::string& message_payload) {
- if (write_failed_ || !output_stream_.IsValid()) {
- return false;
- }
-
- int message_payload_size_bytes = message_payload.size();
- uint32_t total_message_size_bytes =
- SecurityKeyMessage::kMessageTypeSizeBytes + message_payload_size_bytes;
- CHECK(SecurityKeyMessage::IsValidMessageSize(total_message_size_bytes));
-
- // First we send the message header which is the length of the message_type
- // and message_payload in bytes.
- if (!WriteBytesToOutput(reinterpret_cast<char*>(&total_message_size_bytes),
- SecurityKeyMessage::kHeaderSizeBytes)) {
- LOG(ERROR) << "Failed to send message header.";
- return false;
- }
-
- // Next we send the message_type.
- if (!WriteBytesToOutput(reinterpret_cast<char*>(&message_type),
- SecurityKeyMessage::kMessageTypeSizeBytes)) {
- LOG(ERROR) << "Failed to send message type.";
- return false;
- }
-
- // Lastly, send the message data if appropriate.
- if (!message_payload.empty()) {
- if (!WriteBytesToOutput(message_payload.data(),
- message_payload_size_bytes)) {
- LOG(ERROR) << "Failed to send message payload.";
- return false;
- }
- }
-
- return true;
-}
-
-bool RemoteSecurityKeyMessageWriter::WriteBytesToOutput(const char* message,
- int bytes_to_write) {
- DCHECK(message);
- DCHECK_GT(bytes_to_write, 0);
-
- int result = output_stream_.WriteAtCurrentPos(message, bytes_to_write);
- if (result != bytes_to_write) {
- LOG(ERROR) << "Failed to write all bytes to output stream. bytes written: "
- << result << ", file error: "
- << base::File::ErrorToString(output_stream_.error_details());
- write_failed_ = true;
- return false;
- }
-
- return true;
-}
-
-} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698