Commit 14bf1dd9 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

Use ElapsedTimer in Document instead of doubles

Document stores a timestamp for the moment it was created in order to compute
the elapsed time whenever required. This looks like the perfect use case for
base::ElapsedTimer. We wouldn't have to convert from double to int anymore.

Actually we can go further and completely get rid of int downcasts as well and
operate always in terms of base::TimeDelta. Document::ElapsedTime() returns a
base::TimeDelta from now on and it was also moved to the private section as it
isn't used from the outside.

Bug: 979137
Change-Id: I2a3ede41fa947c400769ad21c515eefb857b7fbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1679755Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Sergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#676947}
parent 776e787a
......@@ -392,7 +392,8 @@ static const unsigned kCMaxWriteRecursionDepth = 21;
// a layout without a delay.
// FIXME: For faster machines this value can really be lowered to 200. 250 is
// adequate, but a little high for dual G5s. :)
static const int kCLayoutScheduleThreshold = 250;
static const base::TimeDelta kCLayoutScheduleThreshold =
base::TimeDelta::FromMilliseconds(250);
// DOM Level 2 says (letters added):
//
......@@ -989,7 +990,6 @@ Document::Document(const DocumentInit& initializer,
was_discarded_(false),
load_event_progress_(kLoadEventCompleted),
is_freezing_in_progress_(false),
start_time_(CurrentTime()),
script_runner_(MakeGarbageCollected<ScriptRunner>(this)),
xml_version_("1.0"),
xml_standalone_(kStandaloneUnspecified),
......@@ -3804,7 +3804,7 @@ void Document::ImplicitClose() {
}
if (GetFrame()->Loader().HasProvisionalNavigation() &&
ElapsedTime() < kCLayoutScheduleThreshold) {
start_time_.Elapsed() < kCLayoutScheduleThreshold) {
// Just bail out. Before or during the onload we were shifted to another
// page. The old i-Bench suite does this. When this happens don't bother
// painting or laying out.
......@@ -4174,10 +4174,6 @@ bool Document::ShouldScheduleLayout() const {
return false;
}
int Document::ElapsedTime() const {
return static_cast<int>((CurrentTime() - start_time_) * 1000);
}
void Document::write(const String& text,
Document* entered_document,
ExceptionState& exception_state) {
......
......@@ -772,7 +772,6 @@ class CORE_EXPORT Document : public ContainerNode,
bool HasFinishedParsing() const { return parsing_state_ == kFinishedParsing; }
bool ShouldScheduleLayout() const;
int ElapsedTime() const;
TextLinkColors& GetTextLinkColors() { return text_link_colors_; }
const TextLinkColors& GetTextLinkColors() const { return text_link_colors_; }
......@@ -1878,7 +1877,7 @@ class CORE_EXPORT Document : public ContainerNode,
bool is_freezing_in_progress_;
double start_time_;
base::ElapsedTimer start_time_;
Member<ScriptRunner> script_runner_;
......
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