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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 609923004: Cleanup usage of scoped_ptr<> in remoting for C++11 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/it2me/it2me_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 output_read_file_.Close(); 254 output_read_file_.Close();
255 } 255 }
256 256
257 scoped_ptr<base::DictionaryValue> 257 scoped_ptr<base::DictionaryValue>
258 It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() { 258 It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
259 uint32 length; 259 uint32 length;
260 int read_result = output_read_file_.ReadAtCurrentPos( 260 int read_result = output_read_file_.ReadAtCurrentPos(
261 reinterpret_cast<char*>(&length), sizeof(length)); 261 reinterpret_cast<char*>(&length), sizeof(length));
262 if (read_result != sizeof(length)) { 262 if (read_result != sizeof(length)) {
263 // The output pipe has been closed, return an empty message. 263 // The output pipe has been closed, return an empty message.
264 return scoped_ptr<base::DictionaryValue>(); 264 return nullptr;
265 } 265 }
266 266
267 std::string message_json(length, '\0'); 267 std::string message_json(length, '\0');
268 read_result = output_read_file_.ReadAtCurrentPos( 268 read_result = output_read_file_.ReadAtCurrentPos(
269 string_as_array(&message_json), length); 269 string_as_array(&message_json), length);
270 if (read_result != static_cast<int>(length)) { 270 if (read_result != static_cast<int>(length)) {
271 LOG(ERROR) << "Message size (" << read_result 271 LOG(ERROR) << "Message size (" << read_result
272 << ") doesn't match the header (" << length << ")."; 272 << ") doesn't match the header (" << length << ").";
273 return scoped_ptr<base::DictionaryValue>(); 273 return nullptr;
274 } 274 }
275 275
276 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json)); 276 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json));
277 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { 277 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
278 LOG(ERROR) << "Malformed message:" << message_json; 278 LOG(ERROR) << "Malformed message:" << message_json;
279 return scoped_ptr<base::DictionaryValue>(); 279 return nullptr;
280 } 280 }
281 281
282 return scoped_ptr<base::DictionaryValue>( 282 return scoped_ptr<base::DictionaryValue>(
283 static_cast<base::DictionaryValue*>(message.release())); 283 static_cast<base::DictionaryValue*>(message.release()));
284 } 284 }
285 285
286 void It2MeNativeMessagingHostTest::WriteMessageToInputPipe( 286 void It2MeNativeMessagingHostTest::WriteMessageToInputPipe(
287 const base::Value& message) { 287 const base::Value& message) {
288 std::string message_json; 288 std::string message_json;
289 base::JSONWriter::Write(&message, &message_json); 289 base::JSONWriter::Write(&message, &message_json);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 547
548 // Verify rejection if type is unrecognized. 548 // Verify rejection if type is unrecognized.
549 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { 549 TEST_F(It2MeNativeMessagingHostTest, InvalidType) {
550 base::DictionaryValue message; 550 base::DictionaryValue message;
551 message.SetString("type", "xxx"); 551 message.SetString("type", "xxx");
552 TestBadRequest(message, true); 552 TestBadRequest(message, true);
553 } 553 }
554 554
555 } // namespace remoting 555 } // namespace remoting
556 556
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698