Index: chrome/browser/predictors/resource_prefetch_predictor.h |
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.h b/chrome/browser/predictors/resource_prefetch_predictor.h |
index 2cd3c950895ace6aabeb4aa0cf8d2067fa9263e0..2264618daf0809e36bff54bf02fb3edd96686dad 100644 |
--- a/chrome/browser/predictors/resource_prefetch_predictor.h |
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h |
@@ -23,6 +23,7 @@ |
#include "chrome/browser/predictors/resource_prefetch_common.h" |
#include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
#include "chrome/browser/predictors/resource_prefetcher.h" |
+#include "chrome/browser/predictors/resource_prefetcher_manager.h" |
#include "components/history/core/browser/history_db_task.h" |
#include "components/history/core/browser/history_service_observer.h" |
#include "components/history/core/browser/history_types.h" |
@@ -244,7 +245,7 @@ class ResourcePrefetchPredictor |
std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats); |
// Returns true if prefetching data exists for the |main_frame_url|. |
- virtual bool IsUrlPrefetchable(const GURL& main_frame_url); |
+ virtual bool IsUrlPrefetchable(const GURL& main_frame_url) const; |
// Returns true iff |resource| has sufficient confidence level and required |
// number of hits. |
@@ -260,9 +261,9 @@ class ResourcePrefetchPredictor |
void SetObserverForTesting(TestObserver* observer); |
private: |
- // Starts prefetching if it is enabled for |origin| and prefetching data |
- // exists for the |main_frame_url| either at the URL or at the host level. |
- void StartPrefetching(const GURL& main_frame_url, HintOrigin origin); |
+ // Starts prefetching if it is enabled and prefetching data exists for the |
+ // |main_frame_url| either at the URL or at the host level. |
+ void StartPrefetching(const GURL& main_frame_url); |
// Stops prefetching that may be in progress corresponding to |
// |main_frame_url|. |
@@ -309,6 +310,8 @@ class ResourcePrefetchPredictor |
TestPrefetchingDurationHistogram); |
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
TestRecordFirstContentfulPaint); |
+ FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
+ TestCanPrefetchUrlForOrigin); |
alexilin
2017/05/30 15:06:00
Does this test still exist?
Benoit L
2017/05/31 14:34:42
Done.
|
enum InitializationState { |
NOT_INITIALIZED = 0, |
@@ -342,7 +345,6 @@ class ResourcePrefetchPredictor |
// Functions called on different network events pertaining to the loading of |
// main frame resource or sub resources. |
void OnMainFrameRequest(const URLRequestSummary& request); |
- void OnMainFrameResponse(const URLRequestSummary& response); |
void OnMainFrameRedirect(const URLRequestSummary& response); |
void OnSubresourceResponse(const URLRequestSummary& response); |
void OnSubresourceRedirect(const URLRequestSummary& response); |
@@ -395,7 +397,7 @@ class ResourcePrefetchPredictor |
// database has been read. |
void OnHistoryAndCacheLoaded(); |
- // Cleanup inflight_navigations_, inflight_prefetches_, and prefetcher_stats_. |
+ // Cleanup inflight_navigations_, and prefetcher_stats_. |
void CleanupAbandonedNavigations(const NavigationID& navigation_id); |
// Deletes all URLs from the predictor database, the caches and removes all |
@@ -473,6 +475,12 @@ class ResourcePrefetchPredictor |
tables_ = tables; |
} |
+ // For testing. |
+ void set_mock_resource_prefetcher_manager( |
+ scoped_refptr<ResourcePrefetcherManager> prefetch_manager) { |
+ prefetch_manager_ = prefetch_manager; |
+ } |
+ |
Profile* const profile_; |
TestObserver* observer_; |
const LoadingPredictorConfig config_; |
@@ -489,7 +497,6 @@ class ResourcePrefetchPredictor |
std::unique_ptr<ManifestDataMap> manifest_table_cache_; |
std::unique_ptr<OriginDataMap> origin_table_cache_; |
- std::map<GURL, base::TimeTicks> inflight_prefetches_; |
NavigationMap inflight_navigations_; |
std::map<GURL, std::unique_ptr<ResourcePrefetcher::PrefetcherStats>> |