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/optional.h" | |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" |
21 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
22 #include "components/precache/core/precache_database.h" | 23 #include "components/precache/core/precache_database.h" |
23 #include "components/precache/core/precache_switches.h" | 24 #include "components/precache/core/precache_switches.h" |
24 #include "components/precache/core/proto/unfinished_work.pb.h" | 25 #include "components/precache/core/proto/unfinished_work.pb.h" |
25 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
26 #include "components/sync/driver/sync_service.h" | 27 #include "components/sync/driver/sync_service.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 | 266 |
266 void PrecacheManager::OnGetUnfinishedWorkDone( | 267 void PrecacheManager::OnGetUnfinishedWorkDone( |
267 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work) { | 268 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work) { |
268 // Reset progress on a prefetch that has taken too long to complete. | 269 // Reset progress on a prefetch that has taken too long to complete. |
269 if (unfinished_work->has_start_time() && | 270 if (unfinished_work->has_start_time() && |
270 base::Time::Now() - | 271 base::Time::Now() - |
271 base::Time::FromInternalValue(unfinished_work->start_time()) > | 272 base::Time::FromInternalValue(unfinished_work->start_time()) > |
272 base::TimeDelta::FromHours(6)) { | 273 base::TimeDelta::FromHours(6)) { |
273 PrecacheFetcher::RecordCompletionStatistics( | 274 PrecacheFetcher::RecordCompletionStatistics( |
274 *unfinished_work, unfinished_work->top_host_size(), | 275 *unfinished_work, unfinished_work->top_host_size(), |
275 unfinished_work->resource_size()); | 276 unfinished_work->resource_size(), base::nullopt); |
jamartin
2017/02/22 22:54:07
When does this case happen? When we haven't precac
twifkak
2017/02/23 23:28:41
Yes. The problem is that the weights aren't in the
| |
276 unfinished_work.reset(new PrecacheUnfinishedWork); | 277 unfinished_work.reset(new PrecacheUnfinishedWork); |
277 } | 278 } |
278 // If this prefetch is new, set the start time. | 279 // If this prefetch is new, set the start time. |
279 if (!unfinished_work->has_start_time()) | 280 if (!unfinished_work->has_start_time()) |
280 unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); | 281 unfinished_work->set_start_time(base::Time::Now().ToInternalValue()); |
281 unfinished_work_ = std::move(unfinished_work); | 282 unfinished_work_ = std::move(unfinished_work); |
282 bool needs_top_hosts = unfinished_work_->top_host_size() == 0; | 283 bool needs_top_hosts = unfinished_work_->top_host_size() == 0; |
283 | 284 |
284 if (IsInExperimentGroup()) { | 285 if (IsInExperimentGroup()) { |
285 BrowserThread::PostTask( | 286 BrowserThread::PostTask( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 this)); | 496 this)); |
496 precache_fetcher_->Start(); | 497 precache_fetcher_->Start(); |
497 } | 498 } |
498 | 499 |
499 void PrecacheManager::OnHostsReceivedThenDone( | 500 void PrecacheManager::OnHostsReceivedThenDone( |
500 const history::TopHostsList& host_counts) { | 501 const history::TopHostsList& host_counts) { |
501 OnDone(); | 502 OnDone(); |
502 } | 503 } |
503 | 504 |
504 } // namespace precache | 505 } // namespace precache |
OLD | NEW |