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

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

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 DCHECK(!dns_run_loop_); 395 DCHECK(!dns_run_loop_);
396 waiting_on_dns_ = url; 396 waiting_on_dns_ = url;
397 dns_run_loop_ = &run_loop; 397 dns_run_loop_ = &run_loop;
398 CheckForWaitingLoop(); 398 CheckForWaitingLoop();
399 } 399 }
400 run_loop.Run(); 400 run_loop.Run();
401 } 401 }
402 402
403 bool HasHostBeenLookedUpLocked(const GURL& url) { 403 bool HasHostBeenLookedUpLocked(const GURL& url) {
404 lock_.AssertAcquired(); 404 lock_.AssertAcquired();
405 return ContainsKey(successful_dns_lookups_, url) || 405 return base::ContainsKey(successful_dns_lookups_, url) ||
406 ContainsKey(unsuccessful_dns_lookups_, url); 406 base::ContainsKey(unsuccessful_dns_lookups_, url);
407 } 407 }
408 408
409 bool HasHostBeenLookedUp(const GURL& url) { 409 bool HasHostBeenLookedUp(const GURL& url) {
410 base::AutoLock lock(lock_); 410 base::AutoLock lock(lock_);
411 return HasHostBeenLookedUpLocked(url); 411 return HasHostBeenLookedUpLocked(url);
412 } 412 }
413 413
414 void CheckForWaitingLoop() { 414 void CheckForWaitingLoop() {
415 lock_.AssertAcquired(); 415 lock_.AssertAcquired();
416 if (waiting_on_dns_.is_empty()) 416 if (waiting_on_dns_.is_empty())
(...skipping 10 matching lines...) Expand all
427 size_t TotalHostsLookedUp() { 427 size_t TotalHostsLookedUp() {
428 base::AutoLock lock(lock_); 428 base::AutoLock lock(lock_);
429 return successful_dns_lookups_.size() + unsuccessful_dns_lookups_.size(); 429 return successful_dns_lookups_.size() + unsuccessful_dns_lookups_.size();
430 } 430 }
431 431
432 // Note: this method expects the URL to have been looked up. 432 // Note: this method expects the URL to have been looked up.
433 bool HostFound(const GURL& url) { 433 bool HostFound(const GURL& url) {
434 base::AutoLock lock(lock_); 434 base::AutoLock lock(lock_);
435 EXPECT_TRUE(HasHostBeenLookedUpLocked(url)) << "Expected to have looked up " 435 EXPECT_TRUE(HasHostBeenLookedUpLocked(url)) << "Expected to have looked up "
436 << url.spec(); 436 << url.spec();
437 return ContainsKey(successful_dns_lookups_, url); 437 return base::ContainsKey(successful_dns_lookups_, url);
438 } 438 }
439 439
440 void set_task_runner( 440 void set_task_runner(
441 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { 441 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
442 task_runner_.swap(task_runner); 442 task_runner_.swap(task_runner);
443 } 443 }
444 444
445 // Optionally allows the object to observe preconnects / learning from other 445 // Optionally allows the object to observe preconnects / learning from other
446 // hosts. 446 // hosts.
447 void SetStrict(bool strict) { 447 void SetStrict(bool strict) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 // attached. 719 // attached.
720 void ExpectUrlRequestedFromPredictorOnUIThread(const GURL& url) { 720 void ExpectUrlRequestedFromPredictorOnUIThread(const GURL& url) {
721 DCHECK_CURRENTLY_ON(BrowserThread::UI); 721 DCHECK_CURRENTLY_ON(BrowserThread::UI);
722 BrowserThread::PostTask( 722 BrowserThread::PostTask(
723 BrowserThread::IO, FROM_HERE, 723 BrowserThread::IO, FROM_HERE,
724 base::Bind(&PredictorBrowserTest::ExpectUrlRequestedFromPredictor, 724 base::Bind(&PredictorBrowserTest::ExpectUrlRequestedFromPredictor,
725 base::Unretained(this), url)); 725 base::Unretained(this), url));
726 } 726 }
727 727
728 void ExpectUrlRequestedFromPredictor(const GURL& url) { 728 void ExpectUrlRequestedFromPredictor(const GURL& url) {
729 EXPECT_TRUE(ContainsKey(predictor()->results_, url)); 729 EXPECT_TRUE(base::ContainsKey(predictor()->results_, url));
730 } 730 }
731 731
732 void DiscardAllResultsOnUIThread() { 732 void DiscardAllResultsOnUIThread() {
733 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 733 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
734 base::Bind(&Predictor::DiscardAllResults, 734 base::Bind(&Predictor::DiscardAllResults,
735 base::Unretained(predictor()))); 735 base::Unretained(predictor())));
736 } 736 }
737 737
738 void ExpectValidPeakPendingLookupsOnUI(size_t num_names_requested) { 738 void ExpectValidPeakPendingLookupsOnUI(size_t num_names_requested) {
739 BrowserThread::PostTask( 739 BrowserThread::PostTask(
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 // Second navigation to content with an img. 1561 // Second navigation to content with an img.
1562 std::string img_content = 1562 std::string img_content =
1563 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; 1563 "<img src=\"" + preconnect_url.spec() + "test.gif\">";
1564 NavigateToDataURLWithContent(img_content); 1564 NavigateToDataURLWithContent(img_content);
1565 connection_listener_->WaitUntilFirstConnectionRead(); 1565 connection_listener_->WaitUntilFirstConnectionRead();
1566 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); 1566 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount());
1567 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); 1567 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
1568 } 1568 }
1569 1569
1570 } // namespace chrome_browser_net 1570 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/metrics/plugin_metrics_provider.cc ('k') | chrome/browser/notifications/message_center_notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698