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/security_key_message_reader.h" | 5 #include "remoting/host/security_key/security_key_message_reader.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 if (!SecurityKeyMessage::IsValidMessageSize(total_message_size_bytes)) { | 82 if (!SecurityKeyMessage::IsValidMessageSize(total_message_size_bytes)) { |
83 LOG(ERROR) << "Message size too large: " << total_message_size_bytes; | 83 LOG(ERROR) << "Message size too large: " << total_message_size_bytes; |
84 NotifyError(); | 84 NotifyError(); |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 std::string message_data(total_message_size_bytes, '\0'); | 88 std::string message_data(total_message_size_bytes, '\0'); |
89 read_result = read_stream_.ReadAtCurrentPos(string_as_array(&message_data), | 89 read_result = read_stream_.ReadAtCurrentPos( |
90 total_message_size_bytes); | 90 base::string_as_array(&message_data), total_message_size_bytes); |
91 // The static cast is safe as we know the value is smaller than max int. | 91 // The static cast is safe as we know the value is smaller than max int. |
92 if (read_result != static_cast<int>(total_message_size_bytes)) { | 92 if (read_result != static_cast<int>(total_message_size_bytes)) { |
93 LOG(ERROR) << "Failed to read message: " << read_result; | 93 LOG(ERROR) << "Failed to read message: " << read_result; |
94 NotifyError(); | 94 NotifyError(); |
95 return; | 95 return; |
96 } | 96 } |
97 | 97 |
98 std::unique_ptr<SecurityKeyMessage> message(new SecurityKeyMessage()); | 98 std::unique_ptr<SecurityKeyMessage> message(new SecurityKeyMessage()); |
99 if (!message->ParseMessage(message_data)) { | 99 if (!message->ParseMessage(message_data)) { |
100 LOG(ERROR) << "Invalid message data received."; | 100 LOG(ERROR) << "Invalid message data received."; |
(...skipping 22 matching lines...) Expand all Loading... |
123 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 123 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
124 message_callback_.Run(std::move(message)); | 124 message_callback_.Run(std::move(message)); |
125 } | 125 } |
126 | 126 |
127 void SecurityKeyMessageReader::InvokeErrorCallback() { | 127 void SecurityKeyMessageReader::InvokeErrorCallback() { |
128 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 128 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
129 error_callback_.Run(); | 129 error_callback_.Run(); |
130 } | 130 } |
131 | 131 |
132 } // namespace remoting | 132 } // namespace remoting |
OLD | NEW |