| OLD | NEW |
| 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> |
| 11 | 11 |
| 12 #include "base/base64.h" | 12 #include "base/base64.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/json/json_string_value_serializer.h" | 16 #include "base/json/json_string_value_serializer.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/run_loop.h" |
| 20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 21 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/net/predictor.h" | 26 #include "chrome/browser/net/predictor.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, | 833 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, |
| 833 ShutdownWhenResolutionIsPendingTest) { | 834 ShutdownWhenResolutionIsPendingTest) { |
| 834 GURL delayed_url("http://delay.google.com:80"); | 835 GURL delayed_url("http://delay.google.com:80"); |
| 835 std::vector<GURL> names{delayed_url}; | 836 std::vector<GURL> names{delayed_url}; |
| 836 | 837 |
| 837 // Flood with delayed requests, then wait. | 838 // Flood with delayed requests, then wait. |
| 838 FloodResolveRequestsOnUIThread(names); | 839 FloodResolveRequestsOnUIThread(names); |
| 839 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 840 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 840 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 841 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 841 base::TimeDelta::FromMilliseconds(500)); | 842 base::TimeDelta::FromMilliseconds(500)); |
| 842 base::MessageLoop::current()->Run(); | 843 base::RunLoop().Run(); |
| 843 | 844 |
| 844 ExpectUrlRequestedFromPredictor(delayed_url); | 845 ExpectUrlRequestedFromPredictor(delayed_url); |
| 845 EXPECT_FALSE(observer()->HasHostBeenLookedUp(delayed_url)); | 846 EXPECT_FALSE(observer()->HasHostBeenLookedUp(delayed_url)); |
| 846 } | 847 } |
| 847 | 848 |
| 848 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, SimplePreconnectOne) { | 849 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, SimplePreconnectOne) { |
| 849 predictor()->PreconnectUrl( | 850 predictor()->PreconnectUrl( |
| 850 embedded_test_server()->base_url(), GURL(), | 851 embedded_test_server()->base_url(), GURL(), |
| 851 UrlInfo::ResolutionMotivation::EARLY_LOAD_MOTIVATED, | 852 UrlInfo::ResolutionMotivation::EARLY_LOAD_MOTIVATED, |
| 852 false /* allow credentials */, 1); | 853 false /* allow credentials */, 1); |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 // Second navigation to content with an img. | 1503 // Second navigation to content with an img. |
| 1503 std::string img_content = | 1504 std::string img_content = |
| 1504 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1505 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
| 1505 NavigateToDataURLWithContent(img_content); | 1506 NavigateToDataURLWithContent(img_content); |
| 1506 connection_listener_->WaitUntilFirstConnectionRead(); | 1507 connection_listener_->WaitUntilFirstConnectionRead(); |
| 1507 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1508 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
| 1508 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1509 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
| 1509 } | 1510 } |
| 1510 | 1511 |
| 1511 } // namespace chrome_browser_net | 1512 } // namespace chrome_browser_net |
| OLD | NEW |