OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 14 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 16 #include "chrome/browser/browsing_data/chrome_browsing_data_types.h" |
16 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 17 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
17 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | 18 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" |
18 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" | 19 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
25 #include "net/base/host_port_pair.h" | 26 #include "net/base/host_port_pair.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 } | 439 } |
439 } | 440 } |
440 | 441 |
441 void ClearResources() { resources_.clear(); } | 442 void ClearResources() { resources_.clear(); } |
442 | 443 |
443 void ClearCache() { | 444 void ClearCache() { |
444 BrowsingDataRemover* remover = | 445 BrowsingDataRemover* remover = |
445 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 446 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); |
446 BrowsingDataRemoverObserver observer(remover); | 447 BrowsingDataRemoverObserver observer(remover); |
447 remover->RemoveAndReply(base::Time(), base::Time::Max(), | 448 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
448 BrowsingDataRemover::REMOVE_CACHE, | 449 {&kBrowsingDataTypeCache}, |
449 BrowsingDataHelper::UNPROTECTED_WEB, &observer); | 450 BrowsingDataHelper::UNPROTECTED_WEB, &observer); |
450 observer.Wait(); | 451 observer.Wait(); |
451 | 452 |
452 for (auto& kv : resources_) | 453 for (auto& kv : resources_) |
453 kv.second.request.was_cached = false; | 454 kv.second.request.was_cached = false; |
454 } | 455 } |
455 | 456 |
456 // Shortcut for convenience. | 457 // Shortcut for convenience. |
457 GURL GetURL(const std::string& path) const { | 458 GURL GetURL(const std::string& path) const { |
458 return embedded_test_server()->GetURL(path); | 459 return embedded_test_server()->GetURL(path); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 TryToPrefetchURL(initial_url); | 894 TryToPrefetchURL(initial_url); |
894 NavigateToURLAndCheckSubresources(initial_url); | 895 NavigateToURLAndCheckSubresources(initial_url); |
895 ClearCache(); | 896 ClearCache(); |
896 // But the predictor database contains all subresources for the endpoint url | 897 // But the predictor database contains all subresources for the endpoint url |
897 // so this prefetch works. | 898 // so this prefetch works. |
898 PrefetchURL(GetURL(kHtmlSubresourcesPath)); | 899 PrefetchURL(GetURL(kHtmlSubresourcesPath)); |
899 NavigateToURLAndCheckSubresourcesAllCached(GetURL(kHtmlSubresourcesPath)); | 900 NavigateToURLAndCheckSubresourcesAllCached(GetURL(kHtmlSubresourcesPath)); |
900 } | 901 } |
901 | 902 |
902 } // namespace predictors | 903 } // namespace predictors |
OLD | NEW |