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/run_loop.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 26 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
27 #include "chrome/browser/browsing_data/browsing_data_remover.h" | |
28 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | |
29 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 27 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
30 #include "chrome/browser/net/predictor.h" | 28 #include "chrome/browser/net/predictor.h" |
31 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
34 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
35 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
36 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
37 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
| 36 #include "content/public/browser/browsing_data_remover.h" |
38 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
39 #include "content/public/test/browser_test_utils.h" | 38 #include "content/public/test/browser_test_utils.h" |
40 #include "content/public/test/test_utils.h" | 39 #include "content/public/test/test_utils.h" |
41 #include "net/base/host_port_pair.h" | 40 #include "net/base/host_port_pair.h" |
42 #include "net/base/ip_endpoint.h" | 41 #include "net/base/ip_endpoint.h" |
43 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
44 #include "net/dns/host_resolver_proc.h" | 43 #include "net/dns/host_resolver_proc.h" |
45 #include "net/dns/mock_host_resolver.h" | 44 #include "net/dns/mock_host_resolver.h" |
46 #include "net/http/http_transaction_factory.h" | 45 #include "net/http/http_transaction_factory.h" |
47 #include "net/socket/stream_socket.h" | 46 #include "net/socket/stream_socket.h" |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1402 |
1404 // The pref should persist after startup. | 1403 // The pref should persist after startup. |
1405 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, | 1404 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
1406 &cleared_startup_list); | 1405 &cleared_startup_list); |
1407 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, | 1406 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
1408 &cleared_referral_list); | 1407 &cleared_referral_list); |
1409 EXPECT_THAT(cleared_referral_list, HasSubstr(referring_url_.host())); | 1408 EXPECT_THAT(cleared_referral_list, HasSubstr(referring_url_.host())); |
1410 EXPECT_THAT(cleared_referral_list, HasSubstr(target_url_.host())); | 1409 EXPECT_THAT(cleared_referral_list, HasSubstr(target_url_.host())); |
1411 | 1410 |
1412 // Clear cache which should clear all prefs. | 1411 // Clear cache which should clear all prefs. |
1413 BrowsingDataRemover* remover = | 1412 content::BrowsingDataRemover* remover = |
1414 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 1413 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); |
1415 remover->Remove(base::Time(), base::Time::Max(), | 1414 remover->Remove(base::Time(), base::Time::Max(), |
1416 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY, | 1415 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY, |
1417 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); | 1416 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); |
1418 | 1417 |
1419 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, | 1418 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
1420 &cleared_startup_list); | 1419 &cleared_startup_list); |
1421 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, | 1420 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
1422 &cleared_referral_list); | 1421 &cleared_referral_list); |
1423 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(referring_url_.host()))); | 1422 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(referring_url_.host()))); |
1424 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(target_url_.host()))); | 1423 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(target_url_.host()))); |
1425 } | 1424 } |
1426 | 1425 |
1427 // The predictor should not evict recently used (navigated to) referrers. | 1426 // The predictor should not evict recently used (navigated to) referrers. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 // Second navigation to content with an img. | 1565 // Second navigation to content with an img. |
1567 std::string img_content = | 1566 std::string img_content = |
1568 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1567 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
1569 NavigateToDataURLWithContent(img_content); | 1568 NavigateToDataURLWithContent(img_content); |
1570 connection_listener_->WaitUntilFirstConnectionRead(); | 1569 connection_listener_->WaitUntilFirstConnectionRead(); |
1571 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1570 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
1572 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1571 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
1573 } | 1572 } |
1574 | 1573 |
1575 } // namespace chrome_browser_net | 1574 } // namespace chrome_browser_net |
OLD | NEW |