OLD | NEW |
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 <time.h> | 5 #include <time.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // cached internally by |host_resolver_|. | 78 // cached internally by |host_resolver_|. |
79 net::RuleBasedHostResolverProc* rules = host_resolver_->rules(); | 79 net::RuleBasedHostResolverProc* rules = host_resolver_->rules(); |
80 rules->AddRuleWithLatency("www.google.com", "127.0.0.1", 50); | 80 rules->AddRuleWithLatency("www.google.com", "127.0.0.1", 50); |
81 rules->AddRuleWithLatency("gmail.google.com.com", "127.0.0.1", 70); | 81 rules->AddRuleWithLatency("gmail.google.com.com", "127.0.0.1", 70); |
82 rules->AddRuleWithLatency("mail.google.com", "127.0.0.1", 44); | 82 rules->AddRuleWithLatency("mail.google.com", "127.0.0.1", 44); |
83 rules->AddRuleWithLatency("gmail.com", "127.0.0.1", 63); | 83 rules->AddRuleWithLatency("gmail.com", "127.0.0.1", 63); |
84 } | 84 } |
85 | 85 |
86 void WaitForResolution(Predictor* predictor, const UrlList& hosts) { | 86 void WaitForResolution(Predictor* predictor, const UrlList& hosts) { |
87 HelperTimer* timer = new HelperTimer(); | 87 HelperTimer* timer = new HelperTimer(); |
88 timer->Start(FROM_HERE, TimeDelta::FromMilliseconds(100), | 88 timer->Start(TimeDelta::FromMilliseconds(100), |
89 new WaitForResolutionHelper(predictor, hosts, timer), | 89 new WaitForResolutionHelper(predictor, hosts, timer), |
90 &WaitForResolutionHelper::Run); | 90 &WaitForResolutionHelper::Run); |
91 MessageLoop::current()->Run(); | 91 MessageLoop::current()->Run(); |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 // IMPORTANT: do not move this below |host_resolver_|; the host resolver | 95 // IMPORTANT: do not move this below |host_resolver_|; the host resolver |
96 // must not outlive the message loop, otherwise bad things can happen | 96 // must not outlive the message loop, otherwise bad things can happen |
97 // (like posting to a deleted message loop). | 97 // (like posting to a deleted message loop). |
98 MessageLoop loop_; | 98 MessageLoop loop_; |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 EXPECT_EQ(2U, referral_list.GetSize()); | 618 EXPECT_EQ(2U, referral_list.GetSize()); |
619 | 619 |
620 predictor->DiscardAllResults(); | 620 predictor->DiscardAllResults(); |
621 predictor->SerializeReferrers(&referral_list); | 621 predictor->SerializeReferrers(&referral_list); |
622 EXPECT_EQ(1U, referral_list.GetSize()); | 622 EXPECT_EQ(1U, referral_list.GetSize()); |
623 | 623 |
624 predictor->Shutdown(); | 624 predictor->Shutdown(); |
625 } | 625 } |
626 | 626 |
627 } // namespace chrome_browser_net | 627 } // namespace chrome_browser_net |
OLD | NEW |