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

Side by Side Diff: chrome/browser/net/sdch_browsertest.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH
6 // results 6 // results
7 7
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 // Get the data from the server. Return value is success/failure of the 315 // Get the data from the server. Return value is success/failure of the
316 // data operation, |*sdch_encoding_used| indicates whether or not the 316 // data operation, |*sdch_encoding_used| indicates whether or not the
317 // data was retrieved with sdch encoding. 317 // data was retrieved with sdch encoding.
318 // This is done through FetchUrl(), so the various helper functions 318 // This is done through FetchUrl(), so the various helper functions
319 // will have valid status if it returns successfully. 319 // will have valid status if it returns successfully.
320 bool GetDataDetailed(net::URLRequestContextGetter* getter, 320 bool GetDataDetailed(net::URLRequestContextGetter* getter,
321 bool* sdch_encoding_used) { 321 bool* sdch_encoding_used) {
322 FetchUrlDetailed( 322 FetchUrlDetailed(
323 GURL(base::StringPrintf( 323 GURL(base::StringPrintf(
324 "http://%s:%d%s", kTestHost, test_server_port(), kDataURLPath)), 324 "http://%s:%u%s", kTestHost, test_server_port(), kDataURLPath)),
325 getter); 325 getter);
326 EXPECT_EQ(net::URLRequestStatus::SUCCESS, FetcherStatus().status()) 326 EXPECT_EQ(net::URLRequestStatus::SUCCESS, FetcherStatus().status())
327 << "Error code is " << FetcherStatus().error(); 327 << "Error code is " << FetcherStatus().error();
328 EXPECT_EQ(200, FetcherResponseCode()); 328 EXPECT_EQ(200, FetcherResponseCode());
329 EXPECT_EQ(kSampleData, FetcherResponseContents()); 329 EXPECT_EQ(kSampleData, FetcherResponseContents());
330 330
331 if (net::URLRequestStatus::SUCCESS != FetcherStatus().status() || 331 if (net::URLRequestStatus::SUCCESS != FetcherStatus().status() ||
332 200 != FetcherResponseCode()) { 332 200 != FetcherResponseCode()) {
333 *sdch_encoding_used = false; 333 *sdch_encoding_used = false;
334 return false; 334 return false;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 content::BrowserThread::PostTask( 448 content::BrowserThread::PostTask(
449 content::BrowserThread::IO, FROM_HERE, 449 content::BrowserThread::IO, FROM_HERE,
450 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector, 450 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector,
451 base::Unretained(&response_handler_), 451 base::Unretained(&response_handler_),
452 num_requests, 452 num_requests,
453 run_loop.QuitClosure(), 453 run_loop.QuitClosure(),
454 result)); 454 result));
455 run_loop.Run(); 455 run_loop.Run();
456 } 456 }
457 457
458 int test_server_port() { return test_server_.port(); } 458 uint16 test_server_port() { return test_server_.port(); }
459 459
460 void SetSdchCacheability(bool cache_sdch_response) { 460 void SetSdchCacheability(bool cache_sdch_response) {
461 base::RunLoop run_loop; 461 base::RunLoop run_loop;
462 content::BrowserThread::PostTaskAndReply( 462 content::BrowserThread::PostTaskAndReply(
463 content::BrowserThread::IO, FROM_HERE, 463 content::BrowserThread::IO, FROM_HERE,
464 base::Bind(&SdchResponseHandler::set_cache_sdch_response, 464 base::Bind(&SdchResponseHandler::set_cache_sdch_response,
465 base::Unretained(&response_handler_), 465 base::Unretained(&response_handler_),
466 cache_sdch_response), 466 cache_sdch_response),
467 run_loop.QuitClosure()); 467 run_loop.QuitClosure());
468 run_loop.Run(); 468 run_loop.Run();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 ASSERT_TRUE(SetupIncognitoBrowser()); 690 ASSERT_TRUE(SetupIncognitoBrowser());
691 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); 691 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser()));
692 692
693 // Data fetches on main browser should not be SDCH encoded. 693 // Data fetches on main browser should not be SDCH encoded.
694 bool sdch_encoding_used = true; 694 bool sdch_encoding_used = true;
695 ASSERT_TRUE(GetData(&sdch_encoding_used)); 695 ASSERT_TRUE(GetData(&sdch_encoding_used));
696 EXPECT_FALSE(sdch_encoding_used); 696 EXPECT_FALSE(sdch_encoding_used);
697 } 697 }
698 698
699 } // namespace 699 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/dns_probe_test_util.cc ('k') | chrome/browser/profiles/host_zoom_map_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698