Commit 640f80fd authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Use TimeTicks instead of Time for measuring elapsed time

TimeTicks is preferred for measuring time, when time isn't being measured
across restarts. These were the only two cases I found under
components/offline_pages that could be converted to TimeTicks.

Change-Id: I627698de121cdda5d7853e0d92f7032ade524a40
Reviewed-on: https://chromium-review.googlesource.com/c/1364080
Commit-Queue: Dan H <harringtond@google.com>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615604}
parent 675c6892
......@@ -13,9 +13,7 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h"
#include "components/offline_pages/core/client_namespace_constants.h"
#include "components/offline_pages/core/offline_clock.h"
#include "components/offline_pages/core/offline_page_item.h"
#include "components/offline_pages/core/offline_store_types.h"
#include "components/offline_pages/core/offline_store_utils.h"
......@@ -413,7 +411,7 @@ void OfflinePageMetadataStore::InitializeInternal(
if (!last_closing_time_.is_null()) {
ReportStoreEvent(OfflinePagesStoreEvent::kReopened);
UMA_HISTOGRAM_CUSTOM_TIMES("OfflinePages.SQLStorage.TimeFromCloseToOpen",
OfflineClock()->Now() - last_closing_time_,
base::TimeTicks::Now() - last_closing_time_,
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromMinutes(10),
50 /* buckets */);
......@@ -468,7 +466,7 @@ void OfflinePageMetadataStore::CloseInternal() {
}
TRACE_EVENT_ASYNC_STEP_PAST0("offline_pages", "Metadata Store", this, "Open");
last_closing_time_ = OfflineClock()->Now();
last_closing_time_ = base::TimeTicks::Now();
ReportStoreEvent(OfflinePagesStoreEvent::kClosed);
state_ = StoreState::NOT_LOADED;
......
......@@ -227,7 +227,7 @@ class OfflinePageMetadataStore {
std::vector<base::OnceClosure> pending_commands_;
// Time of the last time the store was closed. Kept for metrics reporting.
base::Time last_closing_time_;
base::TimeTicks last_closing_time_;
base::WeakPtrFactory<OfflinePageMetadataStore> weak_ptr_factory_;
base::WeakPtrFactory<OfflinePageMetadataStore> closing_weak_ptr_factory_;
......
......@@ -115,7 +115,7 @@ void PrefetchStore::Initialize(base::OnceClosure pending_command) {
if (!last_closing_time_.is_null()) {
ReportStoreEvent(OfflinePagesStoreEvent::kReopened);
UMA_HISTOGRAM_CUSTOM_TIMES("OfflinePages.PrefetchStore.TimeFromCloseToOpen",
base::Time::Now() - last_closing_time_,
base::TimeTicks::Now() - last_closing_time_,
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromMinutes(10),
50 /* buckets */);
......@@ -167,7 +167,7 @@ void PrefetchStore::CloseInternal() {
}
TRACE_EVENT_ASYNC_STEP_PAST0("offline_pages", "Prefetch Store", this, "Open");
last_closing_time_ = base::Time::Now();
last_closing_time_ = base::TimeTicks::Now();
ReportStoreEvent(OfflinePagesStoreEvent::kClosed);
initialization_status_ = InitializationStatus::NOT_INITIALIZED;
......
......@@ -173,7 +173,7 @@ class PrefetchStore {
InitializationStatus initialization_status_;
// Time of the last time the store was closed. Kept for metrics reporting.
base::Time last_closing_time_;
base::TimeTicks last_closing_time_;
// Weak pointer to control the callback.
base::WeakPtrFactory<PrefetchStore> weak_ptr_factory_;
......
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