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

Side by Side Diff: content/browser/geolocation/network_location_request.cc

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/geolocation/network_location_request.h" 5 #include "content/browser/geolocation/network_location_request.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Parse the response, ignoring comments. 304 // Parse the response, ignoring comments.
305 std::string error_msg; 305 std::string error_msg;
306 scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError( 306 scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError(
307 response_body, false, NULL, &error_msg)); 307 response_body, false, NULL, &error_msg));
308 if (response_value == NULL) { 308 if (response_value == NULL) {
309 LOG(WARNING) << "ParseServerResponse() : JSONReader failed : " 309 LOG(WARNING) << "ParseServerResponse() : JSONReader failed : "
310 << error_msg; 310 << error_msg;
311 return false; 311 return false;
312 } 312 }
313 313
314 if (!response_value->IsType(Value::TYPE_DICTIONARY)) { 314 if (!response_value->IsDictionary()) {
315 VLOG(1) << "ParseServerResponse() : Unexpected resopnse type " 315 VLOG(1) << "ParseServerResponse() : Unexpected resopnse type "
316 << response_value->GetType(); 316 << response_value->GetType();
317 return false; 317 return false;
318 } 318 }
319 const DictionaryValue* response_object = 319 const DictionaryValue* response_object =
320 static_cast<DictionaryValue*>(response_value.get()); 320 static_cast<DictionaryValue*>(response_value.get());
321 321
322 // Get the access token, if any. 322 // Get the access token, if any.
323 response_object->GetString(kAccessTokenString, access_token); 323 response_object->GetString(kAccessTokenString, access_token);
324 324
325 // Get the location 325 // Get the location
326 Value* location_value = NULL; 326 Value* location_value = NULL;
327 if (!response_object->Get(kLocationString, &location_value)) { 327 if (!response_object->Get(kLocationString, &location_value)) {
328 VLOG(1) << "ParseServerResponse() : Missing location attribute."; 328 VLOG(1) << "ParseServerResponse() : Missing location attribute.";
329 // GLS returns a response with no location property to represent 329 // GLS returns a response with no location property to represent
330 // no fix available; return true to indicate successful parse. 330 // no fix available; return true to indicate successful parse.
331 return true; 331 return true;
332 } 332 }
333 DCHECK(location_value); 333 DCHECK(location_value);
334 334
335 if (!location_value->IsType(Value::TYPE_DICTIONARY)) { 335 if (!location_value->IsDictionary()) {
336 if (!location_value->IsType(Value::TYPE_NULL)) { 336 if (!location_value->IsNull()) {
337 VLOG(1) << "ParseServerResponse() : Unexpected location type " 337 VLOG(1) << "ParseServerResponse() : Unexpected location type "
338 << location_value->GetType(); 338 << location_value->GetType();
339 // If the network provider was unable to provide a position fix, it should 339 // If the network provider was unable to provide a position fix, it should
340 // return a HTTP 200, with "location" : null. Otherwise it's an error. 340 // return a HTTP 200, with "location" : null. Otherwise it's an error.
341 return false; 341 return false;
342 } 342 }
343 return true; // Successfully parsed response containing no fix. 343 return true; // Successfully parsed response containing no fix.
344 } 344 }
345 DictionaryValue* location_object = 345 DictionaryValue* location_object =
346 static_cast<DictionaryValue*>(location_value); 346 static_cast<DictionaryValue*>(location_value);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 gateway_data.router_data.begin(); 444 gateway_data.router_data.begin();
445 iter != gateway_data.router_data.end(); 445 iter != gateway_data.router_data.end();
446 iter++) { 446 iter++) {
447 DictionaryValue* gateway = new DictionaryValue; 447 DictionaryValue* gateway = new DictionaryValue;
448 AddString("mac_address", iter->mac_address, gateway); 448 AddString("mac_address", iter->mac_address, gateway);
449 gateways->Append(gateway); 449 gateways->Append(gateway);
450 } 450 }
451 body_object->Set("gateways", gateways); 451 body_object->Set("gateways", gateways);
452 } 452 }
453 } // namespace 453 } // namespace
OLDNEW
« no previous file with comments | « content/browser/debugger/devtools_netlog_observer.cc ('k') | content/browser/gpu/gpu_blacklist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698