Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7014)

Unified Diff: components/scheduler/child/web_task_runner_impl.cc

Issue 1646583002: [Reland] Per WebViewScheduler virtual time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/scheduler/child/web_task_runner_impl.cc
diff --git a/components/scheduler/child/web_task_runner_impl.cc b/components/scheduler/child/web_task_runner_impl.cc
index 49b5133b9ab033ba545844c97b00628226727521..d3ba45532e278a49f5acf70c52afef7024b61cac 100644
--- a/components/scheduler/child/web_task_runner_impl.cc
+++ b/components/scheduler/child/web_task_runner_impl.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "components/scheduler/base/task_queue.h"
+#include "components/scheduler/base/time_domain.h"
#include "third_party/WebKit/public/platform/WebTraceLocation.h"
namespace scheduler {
@@ -40,6 +41,24 @@ void WebTaskRunnerImpl::postDelayedTask(
base::TimeDelta::FromMillisecondsD(delayMs));
}
+double WebTaskRunnerImpl::virtualTimeSeconds() const {
+ return (Now() - base::TimeTicks::UnixEpoch()).InSecondsF();
+}
+
+double WebTaskRunnerImpl::monotonicallyIncreasingVirtualTimeSeconds() const {
+ return Now().ToInternalValue() /
+ static_cast<double>(base::Time::kMicrosecondsPerSecond);
+}
+
+base::TimeTicks WebTaskRunnerImpl::Now() const {
+ TimeDomain* time_domain = task_queue_->GetTimeDomain();
+ // It's possible task_queue_ has been Unregistered which can lead to a null
+ // TimeDomain. If that happens just return the current real time.
+ if (!time_domain)
+ return base::TimeTicks::Now();
+ return time_domain->Now();
+}
+
blink::WebTaskRunner* WebTaskRunnerImpl::clone() {
return new WebTaskRunnerImpl(task_queue_);
}
« no previous file with comments | « components/scheduler/child/web_task_runner_impl.h ('k') | components/scheduler/renderer/renderer_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698