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

Side by Side Diff: remoting/host/security_key/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 unified diff | Download patch
OLDNEW
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/remote_security_key_message_writer.h" 5 #include "remoting/host/security_key/security_key_message_writer.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "remoting/host/security_key/security_key_message.h" 11 #include "remoting/host/security_key/security_key_message.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 RemoteSecurityKeyMessageWriter::RemoteSecurityKeyMessageWriter( 15 SecurityKeyMessageWriter::SecurityKeyMessageWriter(base::File output_file)
16 base::File output_file)
17 : output_stream_(std::move(output_file)) {} 16 : output_stream_(std::move(output_file)) {}
18 17
19 RemoteSecurityKeyMessageWriter::~RemoteSecurityKeyMessageWriter() {} 18 SecurityKeyMessageWriter::~SecurityKeyMessageWriter() {}
20 19
21 bool RemoteSecurityKeyMessageWriter::WriteMessage( 20 bool SecurityKeyMessageWriter::WriteMessage(
22 RemoteSecurityKeyMessageType message_type) { 21 SecurityKeyMessageType message_type) {
23 return WriteMessageWithPayload(message_type, std::string()); 22 return WriteMessageWithPayload(message_type, std::string());
24 } 23 }
25 24
26 bool RemoteSecurityKeyMessageWriter::WriteMessageWithPayload( 25 bool SecurityKeyMessageWriter::WriteMessageWithPayload(
27 RemoteSecurityKeyMessageType message_type, 26 SecurityKeyMessageType message_type,
28 const std::string& message_payload) { 27 const std::string& message_payload) {
29 if (write_failed_ || !output_stream_.IsValid()) { 28 if (write_failed_ || !output_stream_.IsValid()) {
30 return false; 29 return false;
31 } 30 }
32 31
33 int message_payload_size_bytes = message_payload.size(); 32 int message_payload_size_bytes = message_payload.size();
34 uint32_t total_message_size_bytes = 33 uint32_t total_message_size_bytes =
35 SecurityKeyMessage::kMessageTypeSizeBytes + message_payload_size_bytes; 34 SecurityKeyMessage::kMessageTypeSizeBytes + message_payload_size_bytes;
36 CHECK(SecurityKeyMessage::IsValidMessageSize(total_message_size_bytes)); 35 CHECK(SecurityKeyMessage::IsValidMessageSize(total_message_size_bytes));
37 36
(...skipping 17 matching lines...) Expand all
55 if (!WriteBytesToOutput(message_payload.data(), 54 if (!WriteBytesToOutput(message_payload.data(),
56 message_payload_size_bytes)) { 55 message_payload_size_bytes)) {
57 LOG(ERROR) << "Failed to send message payload."; 56 LOG(ERROR) << "Failed to send message payload.";
58 return false; 57 return false;
59 } 58 }
60 } 59 }
61 60
62 return true; 61 return true;
63 } 62 }
64 63
65 bool RemoteSecurityKeyMessageWriter::WriteBytesToOutput(const char* message, 64 bool SecurityKeyMessageWriter::WriteBytesToOutput(const char* message,
66 int bytes_to_write) { 65 int bytes_to_write) {
67 DCHECK(message); 66 DCHECK(message);
68 DCHECK_GT(bytes_to_write, 0); 67 DCHECK_GT(bytes_to_write, 0);
69 68
70 int result = output_stream_.WriteAtCurrentPos(message, bytes_to_write); 69 int result = output_stream_.WriteAtCurrentPos(message, bytes_to_write);
71 if (result != bytes_to_write) { 70 if (result != bytes_to_write) {
72 LOG(ERROR) << "Failed to write all bytes to output stream. bytes written: " 71 LOG(ERROR) << "Failed to write all bytes to output stream. bytes written: "
73 << result << ", file error: " 72 << result << ", file error: "
74 << base::File::ErrorToString(output_stream_.error_details()); 73 << base::File::ErrorToString(output_stream_.error_details());
75 write_failed_ = true; 74 write_failed_ = true;
76 return false; 75 return false;
77 } 76 }
78 77
79 return true; 78 return true;
80 } 79 }
81 80
82 } // namespace remoting 81 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698