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 #include "components/precache/content/precache_manager.h" | 5 #include "components/precache/content/precache_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 bool PrecacheManager::IsPrecaching() const { | 170 bool PrecacheManager::IsPrecaching() const { |
171 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 171 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
172 return is_precaching_; | 172 return is_precaching_; |
173 } | 173 } |
174 | 174 |
175 void PrecacheManager::RecordStatsForFetch(const GURL& url, | 175 void PrecacheManager::RecordStatsForFetch(const GURL& url, |
176 const GURL& referrer, | 176 const GURL& referrer, |
177 const base::TimeDelta& latency, | 177 const base::TimeDelta& latency, |
178 const base::Time& fetch_time, | 178 const base::Time& fetch_time, |
179 int64 size, | 179 int64_t size, |
180 bool was_cached) { | 180 bool was_cached) { |
181 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 181 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
182 | 182 |
183 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { | 183 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { |
184 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. | 184 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. |
185 return; | 185 return; |
186 } | 186 } |
187 | 187 |
188 if (!history_service_) | 188 if (!history_service_) |
189 return; | 189 return; |
190 | 190 |
191 history_service_->HostRankIfAvailable( | 191 history_service_->HostRankIfAvailable( |
192 referrer, | 192 referrer, |
193 base::Bind(&PrecacheManager::RecordStatsForFetchInternal, AsWeakPtr(), | 193 base::Bind(&PrecacheManager::RecordStatsForFetchInternal, AsWeakPtr(), |
194 url, latency, fetch_time, size, was_cached)); | 194 url, latency, fetch_time, size, was_cached)); |
195 } | 195 } |
196 | 196 |
197 void PrecacheManager::RecordStatsForFetchInternal( | 197 void PrecacheManager::RecordStatsForFetchInternal( |
198 const GURL& url, | 198 const GURL& url, |
199 const base::TimeDelta& latency, | 199 const base::TimeDelta& latency, |
200 const base::Time& fetch_time, | 200 const base::Time& fetch_time, |
201 int64 size, | 201 int64_t size, |
202 bool was_cached, | 202 bool was_cached, |
203 int host_rank) { | 203 int host_rank) { |
204 if (is_precaching_) { | 204 if (is_precaching_) { |
205 // Assume that precache is responsible for all requests made while | 205 // Assume that precache is responsible for all requests made while |
206 // precaching is currently in progress. | 206 // precaching is currently in progress. |
207 // TODO(sclittle): Make PrecacheFetcher explicitly mark precache-motivated | 207 // TODO(sclittle): Make PrecacheFetcher explicitly mark precache-motivated |
208 // fetches, and use that to determine whether or not a fetch was motivated | 208 // fetches, and use that to determine whether or not a fetch was motivated |
209 // by precaching. | 209 // by precaching. |
210 BrowserThread::PostTask( | 210 BrowserThread::PostTask( |
211 BrowserThread::DB, FROM_HERE, | 211 BrowserThread::DB, FROM_HERE, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 this)); | 278 this)); |
279 precache_fetcher_->Start(); | 279 precache_fetcher_->Start(); |
280 } | 280 } |
281 | 281 |
282 void PrecacheManager::OnHostsReceivedThenDone( | 282 void PrecacheManager::OnHostsReceivedThenDone( |
283 const history::TopHostsList& host_counts) { | 283 const history::TopHostsList& host_counts) { |
284 OnDone(); | 284 OnDone(); |
285 } | 285 } |
286 | 286 |
287 } // namespace precache | 287 } // namespace precache |
OLD | NEW |