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

Side by Side Diff: remoting/host/security_key/gnubby_extension_session.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/gnubby_extension_session.h" 5 #include "remoting/host/security_key/gnubby_extension_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool GnubbyExtensionSession::OnExtensionMessage( 77 bool GnubbyExtensionSession::OnExtensionMessage(
78 ClientSessionControl* client_session_control, 78 ClientSessionControl* client_session_control,
79 protocol::ClientStub* client_stub, 79 protocol::ClientStub* client_stub,
80 const protocol::ExtensionMessage& message) { 80 const protocol::ExtensionMessage& message) {
81 DCHECK(thread_checker_.CalledOnValidThread()); 81 DCHECK(thread_checker_.CalledOnValidThread());
82 82
83 if (message.type() != kExtensionMessageType) { 83 if (message.type() != kExtensionMessageType) {
84 return false; 84 return false;
85 } 85 }
86 86
87 scoped_ptr<base::Value> value = base::JSONReader::Read(message.data()); 87 std::unique_ptr<base::Value> value = base::JSONReader::Read(message.data());
88 base::DictionaryValue* client_message; 88 base::DictionaryValue* client_message;
89 if (!value || !value->GetAsDictionary(&client_message)) { 89 if (!value || !value->GetAsDictionary(&client_message)) {
90 LOG(WARNING) << "Failed to retrieve data from gnubby-auth message."; 90 LOG(WARNING) << "Failed to retrieve data from gnubby-auth message.";
91 return true; 91 return true;
92 } 92 }
93 93
94 std::string type; 94 std::string type;
95 if (!client_message->GetString(kMessageType, &type)) { 95 if (!client_message->GetString(kMessageType, &type)) {
96 LOG(WARNING) << "Invalid gnubby-auth message format."; 96 LOG(WARNING) << "Invalid gnubby-auth message format.";
97 return true; 97 return true;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void GnubbyExtensionSession::SendMessageToClient( 172 void GnubbyExtensionSession::SendMessageToClient(
173 int connection_id, 173 int connection_id,
174 const std::string& data) const { 174 const std::string& data) const {
175 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
176 DCHECK(client_stub_); 176 DCHECK(client_stub_);
177 177
178 base::DictionaryValue request; 178 base::DictionaryValue request;
179 request.SetString(kMessageType, kDataMessage); 179 request.SetString(kMessageType, kDataMessage);
180 request.SetInteger(kConnectionId, connection_id); 180 request.SetInteger(kConnectionId, connection_id);
181 181
182 scoped_ptr<base::ListValue> bytes(new base::ListValue()); 182 std::unique_ptr<base::ListValue> bytes(new base::ListValue());
183 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) { 183 for (std::string::const_iterator i = data.begin(); i != data.end(); ++i) {
184 bytes->AppendInteger(static_cast<unsigned char>(*i)); 184 bytes->AppendInteger(static_cast<unsigned char>(*i));
185 } 185 }
186 request.Set(kDataPayload, bytes.release()); 186 request.Set(kDataPayload, bytes.release());
187 187
188 std::string request_json; 188 std::string request_json;
189 CHECK(base::JSONWriter::Write(request, &request_json)); 189 CHECK(base::JSONWriter::Write(request, &request_json));
190 190
191 protocol::ExtensionMessage message; 191 protocol::ExtensionMessage message;
192 message.set_type(kExtensionMessageType); 192 message.set_type(kExtensionMessageType);
193 message.set_data(request_json); 193 message.set_data(request_json);
194 194
195 client_stub_->DeliverHostMessage(message); 195 client_stub_->DeliverHostMessage(message);
196 } 196 }
197 197
198 void GnubbyExtensionSession::SetGnubbyAuthHandlerForTesting( 198 void GnubbyExtensionSession::SetGnubbyAuthHandlerForTesting(
199 scoped_ptr<GnubbyAuthHandler> gnubby_auth_handler) { 199 std::unique_ptr<GnubbyAuthHandler> gnubby_auth_handler) {
200 DCHECK(gnubby_auth_handler); 200 DCHECK(gnubby_auth_handler);
201 201
202 gnubby_auth_handler_ = std::move(gnubby_auth_handler); 202 gnubby_auth_handler_ = std::move(gnubby_auth_handler);
203 gnubby_auth_handler_->SetSendMessageCallback(base::Bind( 203 gnubby_auth_handler_->SetSendMessageCallback(base::Bind(
204 &GnubbyExtensionSession::SendMessageToClient, base::Unretained(this))); 204 &GnubbyExtensionSession::SendMessageToClient, base::Unretained(this)));
205 } 205 }
206 206
207 } // namespace remoting 207 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/security_key/gnubby_extension_session.h ('k') | remoting/host/security_key/gnubby_extension_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698