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

Side by Side Diff: chrome/browser/local_discovery/privet_url_fetcher.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
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | chrome/test/chromedriver/chrome/mobile_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/local_discovery/privet_url_fetcher.h" 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return; 296 return;
297 } 297 }
298 298
299 std::string response_str; 299 std::string response_str;
300 if (!source->GetResponseAsString(&response_str)) { 300 if (!source->GetResponseAsString(&response_str)) {
301 delegate_->OnError(this, URL_FETCH_ERROR); 301 delegate_->OnError(this, URL_FETCH_ERROR);
302 return; 302 return;
303 } 303 }
304 304
305 base::JSONReader json_reader(base::JSON_ALLOW_TRAILING_COMMAS); 305 base::JSONReader json_reader(base::JSON_ALLOW_TRAILING_COMMAS);
306 scoped_ptr<base::Value> value; 306 scoped_ptr<base::Value> value = json_reader.ReadToValue(response_str);
307
308 value.reset(json_reader.ReadToValue(response_str));
309
310 if (!value) { 307 if (!value) {
311 delegate_->OnError(this, JSON_PARSE_ERROR); 308 delegate_->OnError(this, JSON_PARSE_ERROR);
312 return; 309 return;
313 } 310 }
314 311
315 const base::DictionaryValue* dictionary_value = NULL; 312 const base::DictionaryValue* dictionary_value = NULL;
316 313
317 if (!value->GetAsDictionary(&dictionary_value)) { 314 if (!value->GetAsDictionary(&dictionary_value)) {
318 delegate_->OnError(this, JSON_PARSE_ERROR); 315 delegate_->OnError(this, JSON_PARSE_ERROR);
319 return; 316 return;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 371 }
375 372
376 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { 373 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) {
377 return (error == kPrivetErrorDeviceBusy) || 374 return (error == kPrivetErrorDeviceBusy) ||
378 (error == kPrivetV3ErrorDeviceBusy) || 375 (error == kPrivetV3ErrorDeviceBusy) ||
379 (error == kPrivetErrorPendingUserAction) || 376 (error == kPrivetErrorPendingUserAction) ||
380 (error == kPrivetErrorPrinterBusy); 377 (error == kPrivetErrorPrinterBusy);
381 } 378 }
382 379
383 } // namespace local_discovery 380 } // namespace local_discovery
OLDNEW
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | chrome/test/chromedriver/chrome/mobile_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698