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

Side by Side Diff: chrome/test/chromedriver/chrome/mobile_device.cc

Issue 1124223012: Change JSONReader::ReadToValue to return a scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromedriver Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/test/chromedriver/chrome/mobile_device.h" 9 #include "chrome/test/chromedriver/chrome/mobile_device.h"
10 #include "chrome/test/chromedriver/chrome/mobile_device_list.h" 10 #include "chrome/test/chromedriver/chrome/mobile_device_list.h"
11 #include "chrome/test/chromedriver/chrome/status.h" 11 #include "chrome/test/chromedriver/chrome/status.h"
12 12
13 MobileDevice::MobileDevice() {} 13 MobileDevice::MobileDevice() {}
14 MobileDevice::~MobileDevice() {} 14 MobileDevice::~MobileDevice() {}
15 15
16 Status FindMobileDevice(std::string device_name, 16 Status FindMobileDevice(std::string device_name,
17 scoped_ptr<MobileDevice>* mobile_device) { 17 scoped_ptr<MobileDevice>* mobile_device) {
18 base::JSONReader json_reader(base::JSON_ALLOW_TRAILING_COMMAS); 18 base::JSONReader json_reader(base::JSON_ALLOW_TRAILING_COMMAS);
19 scoped_ptr<base::Value> devices_value; 19 scoped_ptr<base::Value> devices_value =
20 devices_value.reset(json_reader.ReadToValue(kMobileDevices)); 20 json_reader.ReadToValue(kMobileDevices);
21 if (!devices_value.get()) 21 if (!devices_value.get())
22 return Status(kUnknownError, 22 return Status(kUnknownError,
23 "could not parse mobile device list because " + 23 "could not parse mobile device list because " +
24 json_reader.GetErrorMessage()); 24 json_reader.GetErrorMessage());
25 25
26 base::ListValue* mobile_devices; 26 base::ListValue* mobile_devices;
27 if (!devices_value->GetAsList(&mobile_devices)) 27 if (!devices_value->GetAsList(&mobile_devices))
28 return Status(kUnknownError, "malformed device metrics list"); 28 return Status(kUnknownError, "malformed device metrics list");
29 29
30 for (base::ListValue::iterator it = mobile_devices->begin(); 30 for (base::ListValue::iterator it = mobile_devices->begin();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 tmp_mobile_device->device_metrics.reset( 79 tmp_mobile_device->device_metrics.reset(
80 new DeviceMetrics(width, height, device_scale_factor, touch, mobile)); 80 new DeviceMetrics(width, height, device_scale_factor, touch, mobile));
81 81
82 *mobile_device = tmp_mobile_device.Pass(); 82 *mobile_device = tmp_mobile_device.Pass();
83 return Status(kOk); 83 return Status(kOk);
84 } 84 }
85 } 85 }
86 86
87 return Status(kUnknownError, "must be a valid device"); 87 return Status(kUnknownError, "must be a valid device");
88 } 88 }
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_url_fetcher.cc ('k') | chrome/test/chromedriver/chrome/network_conditions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698