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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/metrics/user_metrics.h" |
| 18 #include "base/metrics/user_metrics_action.h" |
17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
21 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
22 #include "components/precache/core/precache_database.h" | 24 #include "components/precache/core/precache_database.h" |
23 #include "components/precache/core/precache_switches.h" | 25 #include "components/precache/core/precache_switches.h" |
24 #include "components/precache/core/proto/precache.pb.h" | 26 #include "components/precache/core/proto/precache.pb.h" |
25 #include "components/precache/core/proto/unfinished_work.pb.h" | 27 #include "components/precache/core/proto/unfinished_work.pb.h" |
26 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 *unfinished_work, unfinished_work->top_host_size(), | 279 *unfinished_work, unfinished_work->top_host_size(), |
278 unfinished_work->resource_size()); | 280 unfinished_work->resource_size()); |
279 unfinished_work.reset(new PrecacheUnfinishedWork); | 281 unfinished_work.reset(new PrecacheUnfinishedWork); |
280 } | 282 } |
281 // If this prefetch is new, set the start time. | 283 // If this prefetch is new, set the start time. |
282 if (!unfinished_work->has_start_time()) | 284 if (!unfinished_work->has_start_time()) |
283 unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); | 285 unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); |
284 unfinished_work_ = std::move(unfinished_work); | 286 unfinished_work_ = std::move(unfinished_work); |
285 bool needs_top_hosts = unfinished_work_->top_host_size() == 0; | 287 bool needs_top_hosts = unfinished_work_->top_host_size() == 0; |
286 | 288 |
| 289 base::RecordAction(base::UserMetricsAction("Precache.Fetch.Begin")); |
| 290 |
287 if (IsInExperimentGroup()) { | 291 if (IsInExperimentGroup()) { |
288 BrowserThread::PostTask( | 292 BrowserThread::PostTask( |
289 BrowserThread::DB, FROM_HERE, | 293 BrowserThread::DB, FROM_HERE, |
290 base::Bind(&PrecacheDatabase::DeleteExpiredPrecacheHistory, | 294 base::Bind(&PrecacheDatabase::DeleteExpiredPrecacheHistory, |
291 base::Unretained(precache_database_.get()), | 295 base::Unretained(precache_database_.get()), |
292 base::Time::Now())); | 296 base::Time::Now())); |
293 | 297 |
294 // Request NumTopHosts() top hosts. Note that PrecacheFetcher is further | 298 // Request NumTopHosts() top hosts. Note that PrecacheFetcher is further |
295 // bound by the value of PrecacheConfigurationSettings.top_sites_count, as | 299 // bound by the value of PrecacheConfigurationSettings.top_sites_count, as |
296 // retrieved from the server. | 300 // retrieved from the server. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 this)); | 505 this)); |
502 precache_fetcher_->Start(); | 506 precache_fetcher_->Start(); |
503 } | 507 } |
504 | 508 |
505 void PrecacheManager::OnHostsReceivedThenDone( | 509 void PrecacheManager::OnHostsReceivedThenDone( |
506 const history::TopHostsList& host_counts) { | 510 const history::TopHostsList& host_counts) { |
507 OnDone(); | 511 OnDone(); |
508 } | 512 } |
509 | 513 |
510 } // namespace precache | 514 } // namespace precache |
OLD | NEW |