| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 precache_fetcher_.reset(); | 207 precache_fetcher_.reset(); |
| 208 } | 208 } |
| 209 precache_completion_callback_.Reset(); | 209 precache_completion_callback_.Reset(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool PrecacheManager::IsPrecaching() const { | 212 bool PrecacheManager::IsPrecaching() const { |
| 213 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 214 return is_precaching_; | 214 return is_precaching_; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void PrecacheManager::UpdatePrecacheMetricsAndState( |
| 218 const GURL& url, |
| 219 const GURL& referrer, |
| 220 const base::TimeDelta& latency, |
| 221 const base::Time& fetch_time, |
| 222 int64_t size, |
| 223 bool was_cached, |
| 224 bool is_user_traffic) { |
| 225 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 226 |
| 227 RecordStatsForFetch(url, referrer, latency, fetch_time, size, was_cached); |
| 228 if (is_user_traffic && IsPrecaching()) |
| 229 CancelPrecaching(); |
| 230 } |
| 231 |
| 217 void PrecacheManager::RecordStatsForFetch(const GURL& url, | 232 void PrecacheManager::RecordStatsForFetch(const GURL& url, |
| 218 const GURL& referrer, | 233 const GURL& referrer, |
| 219 const base::TimeDelta& latency, | 234 const base::TimeDelta& latency, |
| 220 const base::Time& fetch_time, | 235 const base::Time& fetch_time, |
| 221 int64_t size, | 236 int64_t size, |
| 222 bool was_cached) { | 237 bool was_cached) { |
| 223 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 238 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 224 | 239 |
| 225 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { | 240 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { |
| 226 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. | 241 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 this)); | 343 this)); |
| 329 precache_fetcher_->Start(); | 344 precache_fetcher_->Start(); |
| 330 } | 345 } |
| 331 | 346 |
| 332 void PrecacheManager::OnHostsReceivedThenDone( | 347 void PrecacheManager::OnHostsReceivedThenDone( |
| 333 const history::TopHostsList& host_counts) { | 348 const history::TopHostsList& host_counts) { |
| 334 OnDone(); | 349 OnDone(); |
| 335 } | 350 } |
| 336 | 351 |
| 337 } // namespace precache | 352 } // namespace precache |
| OLD | NEW |