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

Side by Side Diff: remoting/host/security_key/security_key_message.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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/security_key_message.h" 5 #include "remoting/host/security_key/security_key_message.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Limit remote security key messages to 256KB. 17 // Limit remote security key messages to 256KB.
18 const uint32_t kMaxSecurityKeyMessageByteCount = 256 * 1024; 18 const uint32_t kMaxSecurityKeyMessageByteCount = 256 * 1024;
19 19
20 } // namespace 20 } // namespace
21 21
22 namespace remoting { 22 namespace remoting {
23 23
(...skipping 24 matching lines...) Expand all
48 case static_cast<int>(RemoteSecurityKeyMessageType::UNKNOWN_ERROR): 48 case static_cast<int>(RemoteSecurityKeyMessageType::UNKNOWN_ERROR):
49 case static_cast<int>(RemoteSecurityKeyMessageType::INVALID): 49 case static_cast<int>(RemoteSecurityKeyMessageType::INVALID):
50 return static_cast<RemoteSecurityKeyMessageType>(value); 50 return static_cast<RemoteSecurityKeyMessageType>(value);
51 51
52 default: 52 default:
53 LOG(ERROR) << "Unknown message type passed in: " << value; 53 LOG(ERROR) << "Unknown message type passed in: " << value;
54 return RemoteSecurityKeyMessageType::INVALID; 54 return RemoteSecurityKeyMessageType::INVALID;
55 } 55 }
56 } 56 }
57 57
58 scoped_ptr<SecurityKeyMessage> SecurityKeyMessage::CreateMessageForTest( 58 std::unique_ptr<SecurityKeyMessage> SecurityKeyMessage::CreateMessageForTest(
59 RemoteSecurityKeyMessageType type, 59 RemoteSecurityKeyMessageType type,
60 const std::string& payload) { 60 const std::string& payload) {
61 scoped_ptr<SecurityKeyMessage> message(new SecurityKeyMessage()); 61 std::unique_ptr<SecurityKeyMessage> message(new SecurityKeyMessage());
62 message->type_ = type; 62 message->type_ = type;
63 message->payload_ = payload; 63 message->payload_ = payload;
64 64
65 return message; 65 return message;
66 } 66 }
67 67
68 bool SecurityKeyMessage::ParseMessage(const std::string& message_data) { 68 bool SecurityKeyMessage::ParseMessage(const std::string& message_data) {
69 if (!IsValidMessageSize(message_data.size())) { 69 if (!IsValidMessageSize(message_data.size())) {
70 return false; 70 return false;
71 } 71 }
72 72
73 // The first char of the message is the message type. 73 // The first char of the message is the message type.
74 type_ = MessageTypeFromValue(message_data[0]); 74 type_ = MessageTypeFromValue(message_data[0]);
75 if (type_ == RemoteSecurityKeyMessageType::INVALID) { 75 if (type_ == RemoteSecurityKeyMessageType::INVALID) {
76 return false; 76 return false;
77 } 77 }
78 78
79 payload_.clear(); 79 payload_.clear();
80 if (message_data.size() > kMessageTypeSizeBytes) { 80 if (message_data.size() > kMessageTypeSizeBytes) {
81 payload_ = message_data.substr(1); 81 payload_ = message_data.substr(1);
82 } 82 }
83 83
84 return true; 84 return true;
85 } 85 }
86 86
87 } // namespace remoting 87 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/security_key/security_key_message.h ('k') | remoting/host/server_log_entry_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698