OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |