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

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

Issue 10913221: Fix memory leak in network_location_provider_unittest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial upload. Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 // Check to see that the api key is being appended for the default 267 // Check to see that the api key is being appended for the default
268 // network provider url. 268 // network provider url.
269 bool is_default_url = UrlWithoutQuery(request_url) == 269 bool is_default_url = UrlWithoutQuery(request_url) ==
270 UrlWithoutQuery(GeolocationArbitrator::DefaultNetworkProviderURL()); 270 UrlWithoutQuery(GeolocationArbitrator::DefaultNetworkProviderURL());
271 EXPECT_EQ(is_default_url, !request_url.query().empty()); 271 EXPECT_EQ(is_default_url, !request_url.query().empty());
272 272
273 const std::string& upload_data = request.upload_data(); 273 const std::string& upload_data = request.upload_data();
274 ASSERT_FALSE(upload_data.empty()); 274 ASSERT_FALSE(upload_data.empty());
275 std::string json_parse_error_msg; 275 std::string json_parse_error_msg;
276 base::Value* parsed_json = base::JSONReader::ReadAndReturnError( 276 scoped_ptr<base::Value> parsed_json(
277 upload_data, 277 base::JSONReader::ReadAndReturnError(
278 base::JSON_PARSE_RFC, 278 upload_data,
279 NULL, 279 base::JSON_PARSE_RFC,
280 &json_parse_error_msg); 280 NULL,
281 &json_parse_error_msg));
281 EXPECT_TRUE(json_parse_error_msg.empty()); 282 EXPECT_TRUE(json_parse_error_msg.empty());
282 ASSERT_TRUE(parsed_json != NULL); 283 ASSERT_TRUE(parsed_json.get() != NULL);
283 284
284 const base::DictionaryValue* request_json; 285 const base::DictionaryValue* request_json;
285 ASSERT_TRUE(parsed_json->GetAsDictionary(&request_json)); 286 ASSERT_TRUE(parsed_json->GetAsDictionary(&request_json));
286 287
287 if (!is_default_url) { 288 if (!is_default_url) {
288 if (expected_access_token.empty()) 289 if (expected_access_token.empty())
289 ASSERT_FALSE(request_json->HasKey(kAccessTokenString)); 290 ASSERT_FALSE(request_json->HasKey(kAccessTokenString));
290 else { 291 else {
291 std::string access_token; 292 std::string access_token;
292 EXPECT_TRUE(request_json->GetString(kAccessTokenString, &access_token)); 293 EXPECT_TRUE(request_json->GetString(kAccessTokenString, &access_token));
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1))); 578 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(1)));
578 } else { 579 } else {
579 const int evicted = i - kCacheSize; 580 const int evicted = i - kCacheSize;
580 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted))); 581 EXPECT_FALSE(cache.FindPosition(CreateReferenceWifiScanData(evicted)));
581 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1))); 582 EXPECT_TRUE(cache.FindPosition(CreateReferenceWifiScanData(evicted + 1)));
582 } 583 }
583 } 584 }
584 } 585 }
585 586
586 } // namespace 587 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698