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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 return is_precaching_; | 349 return is_precaching_; |
350 } | 350 } |
351 | 351 |
352 void PrecacheManager::UpdatePrecacheMetricsAndState( | 352 void PrecacheManager::UpdatePrecacheMetricsAndState( |
353 const GURL& url, | 353 const GURL& url, |
354 const GURL& referrer, | 354 const GURL& referrer, |
355 const base::TimeDelta& latency, | 355 const base::TimeDelta& latency, |
356 const base::Time& fetch_time, | 356 const base::Time& fetch_time, |
357 const net::HttpResponseInfo& info, | 357 const net::HttpResponseInfo& info, |
358 int64_t size, | 358 int64_t size, |
359 bool is_user_traffic) { | 359 bool is_user_traffic, |
| 360 const base::Callback<void(base::Time)>& register_synthetic_trial) { |
360 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 361 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
361 | 362 |
362 RecordStatsForFetch(url, referrer, latency, fetch_time, info, size); | 363 BrowserThread::PostTaskAndReplyWithResult( |
| 364 BrowserThread::DB, FROM_HERE, |
| 365 base::Bind(&PrecacheDatabase::GetLastPrecacheTimestamp, |
| 366 base::Unretained(precache_database_.get())), |
| 367 base::Bind(&PrecacheManager::RecordStatsForFetch, AsWeakPtr(), url, |
| 368 referrer, latency, fetch_time, info, size, |
| 369 register_synthetic_trial)); |
| 370 |
363 if (is_user_traffic && IsPrecaching()) | 371 if (is_user_traffic && IsPrecaching()) |
364 CancelPrecaching(); | 372 CancelPrecaching(); |
365 } | 373 } |
366 | 374 |
367 void PrecacheManager::RecordStatsForFetch(const GURL& url, | 375 void PrecacheManager::RecordStatsForFetch( |
368 const GURL& referrer, | 376 const GURL& url, |
369 const base::TimeDelta& latency, | 377 const GURL& referrer, |
370 const base::Time& fetch_time, | 378 const base::TimeDelta& latency, |
371 const net::HttpResponseInfo& info, | 379 const base::Time& fetch_time, |
372 int64_t size) { | 380 const net::HttpResponseInfo& info, |
| 381 int64_t size, |
| 382 const base::Callback<void(base::Time)>& register_synthetic_trial, |
| 383 base::Time last_precache_time) { |
373 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 384 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
374 | 385 |
| 386 register_synthetic_trial.Run(last_precache_time); |
| 387 |
375 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { | 388 if (size == 0 || url.is_empty() || !url.SchemeIsHTTPOrHTTPS()) { |
376 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. | 389 // Ignore empty responses, empty URLs, or URLs that aren't HTTP or HTTPS. |
377 return; | 390 return; |
378 } | 391 } |
379 | 392 |
380 if (!history_service_) | 393 if (!history_service_) |
381 return; | 394 return; |
382 | 395 |
383 history_service_->HostRankIfAvailable( | 396 history_service_->HostRankIfAvailable( |
384 referrer, | 397 referrer, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 this)); | 495 this)); |
483 precache_fetcher_->Start(); | 496 precache_fetcher_->Start(); |
484 } | 497 } |
485 | 498 |
486 void PrecacheManager::OnHostsReceivedThenDone( | 499 void PrecacheManager::OnHostsReceivedThenDone( |
487 const history::TopHostsList& host_counts) { | 500 const history::TopHostsList& host_counts) { |
488 OnDone(); | 501 OnDone(); |
489 } | 502 } |
490 | 503 |
491 } // namespace precache | 504 } // namespace precache |
OLD | NEW |