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 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1400 |
1402 // The pref should persist after startup. | 1401 // The pref should persist after startup. |
1403 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, | 1402 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
1404 &cleared_startup_list); | 1403 &cleared_startup_list); |
1405 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, | 1404 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
1406 &cleared_referral_list); | 1405 &cleared_referral_list); |
1407 EXPECT_THAT(cleared_referral_list, HasSubstr(referring_url_.host())); | 1406 EXPECT_THAT(cleared_referral_list, HasSubstr(referring_url_.host())); |
1408 EXPECT_THAT(cleared_referral_list, HasSubstr(target_url_.host())); | 1407 EXPECT_THAT(cleared_referral_list, HasSubstr(target_url_.host())); |
1409 | 1408 |
1410 // Clear cache which should clear all prefs. | 1409 // Clear cache which should clear all prefs. |
1411 BrowsingDataRemover* remover = | 1410 content::BrowsingDataRemover* remover = |
1412 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 1411 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); |
1413 remover->Remove(base::Time(), base::Time::Max(), | 1412 remover->Remove(base::Time(), base::Time::Max(), |
1414 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY, | 1413 ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY, |
1415 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); | 1414 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); |
1416 | 1415 |
1417 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, | 1416 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
1418 &cleared_startup_list); | 1417 &cleared_startup_list); |
1419 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, | 1418 GetListFromPrefsAsString(prefs::kDnsPrefetchingHostReferralList, |
1420 &cleared_referral_list); | 1419 &cleared_referral_list); |
1421 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(referring_url_.host()))); | 1420 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(referring_url_.host()))); |
1422 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(target_url_.host()))); | 1421 EXPECT_THAT(cleared_referral_list, Not(HasSubstr(target_url_.host()))); |
1423 } | 1422 } |
1424 | 1423 |
1425 // The predictor should not evict recently used (navigated to) referrers. | 1424 // The predictor should not evict recently used (navigated to) referrers. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 // Second navigation to content with an img. | 1563 // Second navigation to content with an img. |
1565 std::string img_content = | 1564 std::string img_content = |
1566 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1565 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
1567 NavigateToDataURLWithContent(img_content); | 1566 NavigateToDataURLWithContent(img_content); |
1568 connection_listener_->WaitUntilFirstConnectionRead(); | 1567 connection_listener_->WaitUntilFirstConnectionRead(); |
1569 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1568 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
1570 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1569 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
1571 } | 1570 } |
1572 | 1571 |
1573 } // namespace chrome_browser_net | 1572 } // namespace chrome_browser_net |
OLD | NEW |