OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 5 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // preconditions, but will not be run if precaching is canceled. | 89 // preconditions, but will not be run if precaching is canceled. |
90 void StartPrecaching( | 90 void StartPrecaching( |
91 const PrecacheCompletionCallback& precache_completion_callback); | 91 const PrecacheCompletionCallback& precache_completion_callback); |
92 | 92 |
93 // Cancels precaching if it is in progress. | 93 // Cancels precaching if it is in progress. |
94 void CancelPrecaching(); | 94 void CancelPrecaching(); |
95 | 95 |
96 // Returns true if precaching is currently in progress, or false otherwise. | 96 // Returns true if precaching is currently in progress, or false otherwise. |
97 bool IsPrecaching() const; | 97 bool IsPrecaching() const; |
98 | 98 |
99 // Update precache-related metrics in response to a URL being fetched. | |
100 void RecordStatsForFetch(const GURL& url, | |
101 const GURL& referrer, | |
102 const base::TimeDelta& latency, | |
103 const base::Time& fetch_time, | |
104 int64_t size, | |
105 bool was_cached); | |
106 | |
107 // Posts a task to the DB thread to delete all history entries from the | 99 // Posts a task to the DB thread to delete all history entries from the |
108 // database. Does not wait for completion of this task. | 100 // database. Does not wait for completion of this task. |
109 void ClearHistory(); | 101 void ClearHistory(); |
110 | 102 |
| 103 // Update precache about an URL being fetched. Metrics related to precache are |
| 104 // updated and any ongoing precache will be cancelled if this is an user |
| 105 // initiated request. Should be called on UI thread. |
| 106 void UpdatePrecacheMetricsAndState(const GURL& url, |
| 107 const GURL& referrer, |
| 108 base::TimeDelta latency, |
| 109 const base::Time& fetch_time, |
| 110 int64_t size, |
| 111 bool was_cached, |
| 112 bool is_user_traffic); |
| 113 |
111 private: | 114 private: |
112 enum class AllowedType { | 115 enum class AllowedType { |
113 ALLOWED, | 116 ALLOWED, |
114 DISALLOWED, | 117 DISALLOWED, |
115 PENDING | 118 PENDING |
116 }; | 119 }; |
117 | 120 |
118 // From KeyedService. | 121 // From KeyedService. |
119 void Shutdown() override; | 122 void Shutdown() override; |
120 | 123 |
(...skipping 10 matching lines...) Expand all Loading... |
131 // Initializes and Starts a PrecacheFetcher with unfinished work. | 134 // Initializes and Starts a PrecacheFetcher with unfinished work. |
132 void InitializeAndStartFetcher(); | 135 void InitializeAndStartFetcher(); |
133 | 136 |
134 // From history::HistoryService::TopHosts. Used for the control group, which | 137 // From history::HistoryService::TopHosts. Used for the control group, which |
135 // gets the list of TopHosts for metrics purposes, but otherwise does nothing. | 138 // gets the list of TopHosts for metrics purposes, but otherwise does nothing. |
136 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts); | 139 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts); |
137 | 140 |
138 // Returns true if precaching is allowed for the browser context. | 141 // Returns true if precaching is allowed for the browser context. |
139 AllowedType PrecachingAllowed() const; | 142 AllowedType PrecachingAllowed() const; |
140 | 143 |
| 144 // Update precache-related metrics in response to a URL being fetched. |
| 145 void RecordStatsForFetch(const GURL& url, |
| 146 const GURL& referrer, |
| 147 const base::TimeDelta& latency, |
| 148 const base::Time& fetch_time, |
| 149 int64_t size, |
| 150 bool was_cached); |
| 151 |
141 // Update precache-related metrics in response to a URL being fetched. Called | 152 // Update precache-related metrics in response to a URL being fetched. Called |
142 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback. | 153 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback. |
143 void RecordStatsForFetchInternal(const GURL& url, | 154 void RecordStatsForFetchInternal(const GURL& url, |
144 const base::TimeDelta& latency, | 155 const base::TimeDelta& latency, |
145 const base::Time& fetch_time, | 156 const base::Time& fetch_time, |
146 int64_t size, | 157 int64_t size, |
147 bool was_cached, | 158 bool was_cached, |
148 int host_rank); | 159 int host_rank); |
149 | 160 |
150 // The browser context that owns this PrecacheManager. | 161 // The browser context that owns this PrecacheManager. |
(...skipping 24 matching lines...) Expand all Loading... |
175 | 186 |
176 // Work that hasn't yet finished. | 187 // Work that hasn't yet finished. |
177 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; | 188 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; |
178 | 189 |
179 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); | 190 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); |
180 }; | 191 }; |
181 | 192 |
182 } // namespace precache | 193 } // namespace precache |
183 | 194 |
184 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 195 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
OLD | NEW |