Commit f2c37216 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

bindings: Convert some time-in-double instances to base::Time

This CL has no behavior changes.

Change-Id: If2317def8d94c339c3a3bb8d8c6518347a718da8
Bug: 988343
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928817
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717610}
parent 23b9cb1d
......@@ -1495,14 +1495,14 @@ TEST(V8ScriptValueSerializerTest, RoundTripFileNonNativeSnapshot) {
// when the checker was constructed, according to WTF::currentTime.
class TimeIntervalChecker {
public:
TimeIntervalChecker() : start_time_(base::Time::Now().ToDoubleT()) {}
TimeIntervalChecker() : start_time_(base::Time::Now()) {}
bool WasAliveAt(double time_in_milliseconds) {
double time = time_in_milliseconds / kMsPerSecond;
return start_time_ <= time && time <= base::Time::Now().ToDoubleT();
base::Time time = base::Time::FromJsTime(time_in_milliseconds);
return start_time_ <= time && time <= base::Time::Now();
}
private:
const double start_time_;
const base::Time start_time_;
};
TEST(V8ScriptValueSerializerTest, DecodeFileV3) {
......
......@@ -68,7 +68,7 @@ void V8GCForContextDispose::NotifyContextDisposed(
bool is_main_frame,
WindowProxy::FrameReuseStatus frame_reuse_status) {
did_dispose_context_for_main_frame_ = is_main_frame;
last_context_disposal_time_ = base::Time::Now().ToDoubleT();
last_context_disposal_time_ = base::Time::Now();
#if defined(OS_ANDROID)
// When a low end device is in a low memory situation we should prioritize
// memory use and trigger a V8+Blink GC. However, on Android, if the frame
......@@ -97,10 +97,11 @@ void V8GCForContextDispose::NotifyContextDisposed(
}
void V8GCForContextDispose::NotifyIdle() {
double max_time_since_last_context_disposal = .2;
constexpr base::TimeDelta kMaxTimeSinceLastContextDisposal =
base::TimeDelta::FromMilliseconds(200);
if (!did_dispose_context_for_main_frame_ && !pseudo_idle_timer_.IsActive() &&
last_context_disposal_time_ + max_time_since_last_context_disposal >=
base::Time::Now().ToDoubleT()) {
last_context_disposal_time_ + kMaxTimeSinceLastContextDisposal >=
base::Time::Now()) {
pseudo_idle_timer_.StartOneShot(base::TimeDelta(), FROM_HERE);
}
}
......@@ -118,7 +119,7 @@ void V8GCForContextDispose::PseudoIdleTimerFired(TimerBase*) {
void V8GCForContextDispose::Reset() {
did_dispose_context_for_main_frame_ = false;
last_context_disposal_time_ = -1;
last_context_disposal_time_ = base::Time();
}
void V8GCForContextDispose::SetForcePageNavigationGC() {
......
......@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_GC_FOR_CONTEXT_DISPOSE_H_
#include "base/macros.h"
#include "base/time/time.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/timer.h"
......@@ -59,7 +60,7 @@ class V8GCForContextDispose {
TaskRunnerTimer<V8GCForContextDispose> pseudo_idle_timer_;
bool did_dispose_context_for_main_frame_;
double last_context_disposal_time_;
base::Time last_context_disposal_time_;
bool force_page_navigation_gc_;
DISALLOW_COPY_AND_ASSIGN(V8GCForContextDispose);
......
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