Commit 1827db15 authored by sorin's avatar sorin Committed by Commit bot

Mechanical change of base::Time to base::TimeTicks in the component updater.

The call sites where the time is used to compute time deltas within the
lifetime of the Chrome browser process are affected.

BUG=646619

Review-Url: https://codereview.chromium.org/2336913003
Cr-Commit-Position: refs/heads/master@{#418959}
parent 93d76ce0
...@@ -267,7 +267,8 @@ bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) { ...@@ -267,7 +267,8 @@ bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) {
// Check if the request is too soon. // Check if the request is too soon.
const auto* component_state(GetComponentState(id)); const auto* component_state(GetComponentState(id));
if (component_state) { if (component_state) {
base::TimeDelta delta = base::Time::Now() - component_state->last_check; base::TimeDelta delta =
base::TimeTicks::Now() - component_state->last_check;
if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay())) if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
return false; return false;
} }
......
...@@ -66,7 +66,7 @@ void ActionUpdateCheck::Run(UpdateContext* update_context, Callback callback) { ...@@ -66,7 +66,7 @@ void ActionUpdateCheck::Run(UpdateContext* update_context, Callback callback) {
item->id = GetCrxComponentID(crx_component); item->id = GetCrxComponentID(crx_component);
item->component = crx_component; item->component = crx_component;
item->last_check = base::Time::Now(); item->last_check = base::TimeTicks::Now();
item->crx_urls.clear(); item->crx_urls.clear();
item->crx_diffurls.clear(); item->crx_diffurls.clear();
item->previous_version = crx_component.version; item->previous_version = crx_component.version;
......
...@@ -460,7 +460,7 @@ void BackgroundDownloader::DoStartDownload(const GURL& url) { ...@@ -460,7 +460,7 @@ void BackgroundDownloader::DoStartDownload(const GURL& url) {
void BackgroundDownloader::BeginDownload(const GURL& url) { void BackgroundDownloader::BeginDownload(const GURL& url) {
DCHECK(task_runner()->RunsTasksOnCurrentThread()); DCHECK(task_runner()->RunsTasksOnCurrentThread());
download_start_time_ = base::Time::Now(); download_start_time_ = base::TimeTicks::Now();
job_stuck_begin_time_ = download_start_time_; job_stuck_begin_time_ = download_start_time_;
HRESULT hr = BeginDownloadHelper(url); HRESULT hr = BeginDownloadHelper(url);
...@@ -573,7 +573,7 @@ void BackgroundDownloader::EndDownload(HRESULT error) { ...@@ -573,7 +573,7 @@ void BackgroundDownloader::EndDownload(HRESULT error) {
DCHECK(!TimerIsRunning()); DCHECK(!TimerIsRunning());
const base::Time download_end_time(base::Time::Now()); const base::TimeTicks download_end_time(base::TimeTicks::Now());
const base::TimeDelta download_time = const base::TimeDelta download_time =
download_end_time >= download_start_time_ download_end_time >= download_start_time_
? download_end_time - download_start_time_ ? download_end_time - download_start_time_
...@@ -691,7 +691,7 @@ bool BackgroundDownloader::OnStateQueued() { ...@@ -691,7 +691,7 @@ bool BackgroundDownloader::OnStateQueued() {
bool BackgroundDownloader::OnStateTransferring() { bool BackgroundDownloader::OnStateTransferring() {
// Resets the baseline for detecting a stuck job since the job is transferring // Resets the baseline for detecting a stuck job since the job is transferring
// data and it is making progress. // data and it is making progress.
job_stuck_begin_time_ = base::Time::Now(); job_stuck_begin_time_ = base::TimeTicks::Now();
int64_t downloaded_bytes = -1; int64_t downloaded_bytes = -1;
int64_t total_bytes = -1; int64_t total_bytes = -1;
...@@ -800,7 +800,7 @@ HRESULT BackgroundDownloader::InitializeNewJob( ...@@ -800,7 +800,7 @@ HRESULT BackgroundDownloader::InitializeNewJob(
bool BackgroundDownloader::IsStuck() { bool BackgroundDownloader::IsStuck() {
const base::TimeDelta job_stuck_timeout( const base::TimeDelta job_stuck_timeout(
base::TimeDelta::FromMinutes(kJobStuckTimeoutMin)); base::TimeDelta::FromMinutes(kJobStuckTimeoutMin));
return job_stuck_begin_time_ + job_stuck_timeout < base::Time::Now(); return job_stuck_begin_time_ + job_stuck_timeout < base::TimeTicks::Now();
} }
HRESULT BackgroundDownloader::CompleteJob() { HRESULT BackgroundDownloader::CompleteJob() {
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <windows.h> #include <windows.h>
#include <bits.h> #include <bits.h>
#include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -134,10 +136,10 @@ class BackgroundDownloader : public CrxDownloader { ...@@ -134,10 +136,10 @@ class BackgroundDownloader : public CrxDownloader {
base::win::ScopedComPtr<IBackgroundCopyJob> job_; base::win::ScopedComPtr<IBackgroundCopyJob> job_;
// Contains the time when the download of the current url has started. // Contains the time when the download of the current url has started.
base::Time download_start_time_; base::TimeTicks download_start_time_;
// Contains the time when the BITS job is last seen making progress. // Contains the time when the BITS job is last seen making progress.
base::Time job_stuck_begin_time_; base::TimeTicks job_stuck_begin_time_;
// Contains the path of the downloaded file if the download was successful. // Contains the path of the downloaded file if the download was successful.
base::FilePath response_; base::FilePath response_;
......
...@@ -80,7 +80,7 @@ struct CrxUpdateItem { ...@@ -80,7 +80,7 @@ struct CrxUpdateItem {
CrxComponent component; CrxComponent component;
// Time when an update check for this CRX has happened. // Time when an update check for this CRX has happened.
base::Time last_check; base::TimeTicks last_check;
// Time when the update of this CRX has begun. // Time when the update of this CRX has begun.
base::TimeTicks update_begin; base::TimeTicks update_begin;
......
...@@ -128,8 +128,9 @@ void UpdateEngine::UpdateComplete(UpdateContext* update_context, int error) { ...@@ -128,8 +128,9 @@ void UpdateEngine::UpdateComplete(UpdateContext* update_context, int error) {
if (throttle_sec >= 0) if (throttle_sec >= 0)
throttle_updates_until_ = throttle_updates_until_ =
throttle_sec throttle_sec
? base::Time::Now() + base::TimeDelta::FromSeconds(throttle_sec) ? base::TimeTicks::Now() +
: base::Time(); base::TimeDelta::FromSeconds(throttle_sec)
: base::TimeTicks();
auto callback = update_context->callback; auto callback = update_context->callback;
...@@ -143,7 +144,7 @@ bool UpdateEngine::IsThrottled(bool is_foreground) const { ...@@ -143,7 +144,7 @@ bool UpdateEngine::IsThrottled(bool is_foreground) const {
if (is_foreground || throttle_updates_until_.is_null()) if (is_foreground || throttle_updates_until_.is_null())
return false; return false;
const auto now(base::Time::Now()); const auto now(base::TimeTicks::Now());
// Throttle the calls in the interval (t - 1 day, t) to limit the effect of // Throttle the calls in the interval (t - 1 day, t) to limit the effect of
// unset clocks or clock drift. // unset clocks or clock drift.
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "components/update_client/update_client.h" #include "components/update_client/update_client.h"
namespace base { namespace base {
class TimeTicks;
class SequencedTaskRunner; class SequencedTaskRunner;
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
} // namespace base } // namespace base
...@@ -89,7 +90,7 @@ class UpdateEngine { ...@@ -89,7 +90,7 @@ class UpdateEngine {
// effect of rejecting the update call if the update call occurs before // effect of rejecting the update call if the update call occurs before
// a certain time, which is negotiated with the server as part of the // a certain time, which is negotiated with the server as part of the
// update protocol. See the comments for X-Retry-After header. // update protocol. See the comments for X-Retry-After header.
base::Time throttle_updates_until_; base::TimeTicks throttle_updates_until_;
DISALLOW_COPY_AND_ASSIGN(UpdateEngine); DISALLOW_COPY_AND_ASSIGN(UpdateEngine);
}; };
......
...@@ -46,7 +46,7 @@ void UrlFetcherDownloader::DoStartDownload(const GURL& url) { ...@@ -46,7 +46,7 @@ void UrlFetcherDownloader::DoStartDownload(const GURL& url) {
VLOG(1) << "Starting background download: " << url.spec(); VLOG(1) << "Starting background download: " << url.spec();
url_fetcher_->Start(); url_fetcher_->Start();
download_start_time_ = base::Time::Now(); download_start_time_ = base::TimeTicks::Now();
downloaded_bytes_ = -1; downloaded_bytes_ = -1;
total_bytes_ = -1; total_bytes_ = -1;
...@@ -55,7 +55,7 @@ void UrlFetcherDownloader::DoStartDownload(const GURL& url) { ...@@ -55,7 +55,7 @@ void UrlFetcherDownloader::DoStartDownload(const GURL& url) {
void UrlFetcherDownloader::OnURLFetchComplete(const net::URLFetcher* source) { void UrlFetcherDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
const base::Time download_end_time(base::Time::Now()); const base::TimeTicks download_end_time(base::TimeTicks::Now());
const base::TimeDelta download_time = const base::TimeDelta download_time =
download_end_time >= download_start_time_ download_end_time >= download_start_time_
? download_end_time - download_start_time_ ? download_end_time - download_start_time_
......
...@@ -50,7 +50,7 @@ class UrlFetcherDownloader : public CrxDownloader, ...@@ -50,7 +50,7 @@ class UrlFetcherDownloader : public CrxDownloader,
std::unique_ptr<net::URLFetcher> url_fetcher_; std::unique_ptr<net::URLFetcher> url_fetcher_;
net::URLRequestContextGetter* context_getter_; net::URLRequestContextGetter* context_getter_;
base::Time download_start_time_; base::TimeTicks download_start_time_;
int64_t downloaded_bytes_; int64_t downloaded_bytes_;
int64_t total_bytes_; int64_t total_bytes_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment