OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/string_util.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
16 #include "chrome/browser/net/predictor_api.h" | 16 #include "chrome/browser/net/predictor_api.h" |
17 #include "chrome/browser/net/url_info.h" | 17 #include "chrome/browser/net/url_info.h" |
18 #include "chrome/common/net/predictor_common.h" | 18 #include "chrome/common/net/predictor_common.h" |
19 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
20 #include "net/base/mock_host_resolver.h" | 20 #include "net/base/mock_host_resolver.h" |
21 #include "net/base/winsock_init.h" | 21 #include "net/base/winsock_init.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 host_resolver_->rules()->AddSimulatedFailure("*.notfound"); | 228 host_resolver_->rules()->AddSimulatedFailure("*.notfound"); |
229 | 229 |
230 scoped_refptr<Predictor> testing_master = new Predictor( | 230 scoped_refptr<Predictor> testing_master = new Predictor( |
231 host_resolver_, | 231 host_resolver_, |
232 default_max_queueing_delay_, | 232 default_max_queueing_delay_, |
233 PredictorInit::kMaxPrefetchConcurrentLookups, | 233 PredictorInit::kMaxPrefetchConcurrentLookups, |
234 false); | 234 false); |
235 | 235 |
236 UrlList names; | 236 UrlList names; |
237 for (int i = 0; i < 100; i++) | 237 for (int i = 0; i < 100; i++) |
238 names.push_back(GURL("http://host" + IntToString(i) + ".notfound:80")); | 238 names.push_back(GURL("http://host" + base::IntToString(i) + ".notfound:80"))
; |
239 | 239 |
240 // Try to flood the predictor with many concurrent requests. | 240 // Try to flood the predictor with many concurrent requests. |
241 for (int i = 0; i < 10; i++) | 241 for (int i = 0; i < 10; i++) |
242 testing_master->ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED); | 242 testing_master->ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED); |
243 | 243 |
244 WaitForResolution(testing_master, names); | 244 WaitForResolution(testing_master, names); |
245 | 245 |
246 MessageLoop::current()->RunAllPending(); | 246 MessageLoop::current()->RunAllPending(); |
247 | 247 |
248 EXPECT_LE(testing_master->peak_pending_lookups(), names.size()); | 248 EXPECT_LE(testing_master->peak_pending_lookups(), names.size()); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 EXPECT_EQ(queue.Pop(), low2); | 533 EXPECT_EQ(queue.Pop(), low2); |
534 EXPECT_EQ(queue.Pop(), low3); | 534 EXPECT_EQ(queue.Pop(), low3); |
535 EXPECT_EQ(queue.Pop(), low4); | 535 EXPECT_EQ(queue.Pop(), low4); |
536 EXPECT_EQ(queue.Pop(), low5); | 536 EXPECT_EQ(queue.Pop(), low5); |
537 EXPECT_EQ(queue.Pop(), low4); | 537 EXPECT_EQ(queue.Pop(), low4); |
538 | 538 |
539 EXPECT_TRUE(queue.IsEmpty()); | 539 EXPECT_TRUE(queue.IsEmpty()); |
540 } | 540 } |
541 | 541 |
542 } // namespace chrome_browser_net | 542 } // namespace chrome_browser_net |
OLD | NEW |