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

Side by Side Diff: device/geolocation/network_location_request.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 | « dbus/values_util.cc ('k') | extensions/browser/api/cast_channel/cast_channel_api.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "device/geolocation/network_location_request.h" 5 #include "device/geolocation/network_location_request.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Parse the response, ignoring comments. 360 // Parse the response, ignoring comments.
361 std::string error_msg; 361 std::string error_msg;
362 std::unique_ptr<base::Value> response_value = 362 std::unique_ptr<base::Value> response_value =
363 base::JSONReader::ReadAndReturnError(response_body, base::JSON_PARSE_RFC, 363 base::JSONReader::ReadAndReturnError(response_body, base::JSON_PARSE_RFC,
364 NULL, &error_msg); 364 NULL, &error_msg);
365 if (response_value == NULL) { 365 if (response_value == NULL) {
366 LOG(WARNING) << "ParseServerResponse() : JSONReader failed : " << error_msg; 366 LOG(WARNING) << "ParseServerResponse() : JSONReader failed : " << error_msg;
367 return false; 367 return false;
368 } 368 }
369 369
370 if (!response_value->IsType(base::Value::TYPE_DICTIONARY)) { 370 if (!response_value->IsType(base::Value::Type::DICTIONARY)) {
371 VLOG(1) << "ParseServerResponse() : Unexpected response type " 371 VLOG(1) << "ParseServerResponse() : Unexpected response type "
372 << response_value->GetType(); 372 << response_value->GetType();
373 return false; 373 return false;
374 } 374 }
375 const base::DictionaryValue* response_object = 375 const base::DictionaryValue* response_object =
376 static_cast<base::DictionaryValue*>(response_value.get()); 376 static_cast<base::DictionaryValue*>(response_value.get());
377 377
378 // Get the access token, if any. 378 // Get the access token, if any.
379 response_object->GetString(kAccessTokenString, access_token); 379 response_object->GetString(kAccessTokenString, access_token);
380 380
381 // Get the location 381 // Get the location
382 const base::Value* location_value = NULL; 382 const base::Value* location_value = NULL;
383 if (!response_object->Get(kLocationString, &location_value)) { 383 if (!response_object->Get(kLocationString, &location_value)) {
384 VLOG(1) << "ParseServerResponse() : Missing location attribute."; 384 VLOG(1) << "ParseServerResponse() : Missing location attribute.";
385 // GLS returns a response with no location property to represent 385 // GLS returns a response with no location property to represent
386 // no fix available; return true to indicate successful parse. 386 // no fix available; return true to indicate successful parse.
387 return true; 387 return true;
388 } 388 }
389 DCHECK(location_value); 389 DCHECK(location_value);
390 390
391 if (!location_value->IsType(base::Value::TYPE_DICTIONARY)) { 391 if (!location_value->IsType(base::Value::Type::DICTIONARY)) {
392 if (!location_value->IsType(base::Value::TYPE_NULL)) { 392 if (!location_value->IsType(base::Value::Type::NONE)) {
393 VLOG(1) << "ParseServerResponse() : Unexpected location type " 393 VLOG(1) << "ParseServerResponse() : Unexpected location type "
394 << location_value->GetType(); 394 << location_value->GetType();
395 // If the network provider was unable to provide a position fix, it should 395 // If the network provider was unable to provide a position fix, it should
396 // return a HTTP 200, with "location" : null. Otherwise it's an error. 396 // return a HTTP 200, with "location" : null. Otherwise it's an error.
397 return false; 397 return false;
398 } 398 }
399 return true; // Successfully parsed response containing no fix. 399 return true; // Successfully parsed response containing no fix.
400 } 400 }
401 const base::DictionaryValue* location_object = 401 const base::DictionaryValue* location_object =
402 static_cast<const base::DictionaryValue*>(location_value); 402 static_cast<const base::DictionaryValue*>(location_value);
(...skipping 13 matching lines...) Expand all
416 416
417 // Other fields are optional. 417 // Other fields are optional.
418 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); 418 GetAsDouble(*response_object, kAccuracyString, &position->accuracy);
419 419
420 return true; 420 return true;
421 } 421 }
422 422
423 } // namespace 423 } // namespace
424 424
425 } // namespace device 425 } // namespace device
OLDNEW
« no previous file with comments | « dbus/values_util.cc ('k') | extensions/browser/api/cast_channel/cast_channel_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698