diff options
author | alexclarke <alexclarke@chromium.org> | 2015-11-06 01:26:12 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-06 09:26:56 +0000 |
commit | 822562449e875d806b16d94fa4ee0167e2a2c78e (patch) | |
tree | a6fe9ef8bc8565652cc196eb1041cbd29691526f /content | |
parent | 4b5626e2f4fe64eb42bb968107fcb89d9f1c4c09 (diff) | |
download | chromium_src-822562449e875d806b16d94fa4ee0167e2a2c78e.zip chromium_src-822562449e875d806b16d94fa4ee0167e2a2c78e.tar.gz chromium_src-822562449e875d806b16d94fa4ee0167e2a2c78e.tar.bz2 |
Make blink platform time consistent with the timer virtual time
This patch doesn't change anything unless the --enable-virtualized-time
command line flag is specifed. If it is specified it makes
monotonicallyIncreasingTime and currentTime use the virtual
time source which drives the timers.
Also rename BlinkPlatform's currentTIme to currentTimeSeconds and
monotonicallyIncreacingTime to monotonicallyIncreacingTimeSeconds.
BUG=546953
Review URL: https://codereview.chromium.org/1411843008
Cr-Commit-Position: refs/heads/master@{#358291}
Diffstat (limited to 'content')
-rw-r--r-- | content/child/blink_platform_impl.cc | 4 | ||||
-rw-r--r-- | content/child/blink_platform_impl.h | 4 | ||||
-rw-r--r-- | content/renderer/renderer_blink_platform_impl.cc | 13 | ||||
-rw-r--r-- | content/renderer/renderer_blink_platform_impl.h | 4 | ||||
-rw-r--r-- | content/test/fake_renderer_scheduler.cc | 8 | ||||
-rw-r--r-- | content/test/fake_renderer_scheduler.h | 2 |
6 files changed, 30 insertions, 5 deletions
diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc index 7f99386..67c6f8e 100644 --- a/content/child/blink_platform_impl.cc +++ b/content/child/blink_platform_impl.cc @@ -1074,11 +1074,11 @@ WebString BlinkPlatformImpl::queryLocalizedString( GetContentClient()->GetLocalizedString(message_id), values, NULL); } -double BlinkPlatformImpl::currentTime() { +double BlinkPlatformImpl::currentTimeSeconds() { return base::Time::Now().ToDoubleT(); } -double BlinkPlatformImpl::monotonicallyIncreasingTime() { +double BlinkPlatformImpl::monotonicallyIncreasingTimeSeconds() { return base::TimeTicks::Now().ToInternalValue() / static_cast<double>(base::Time::kMicrosecondsPerSecond); } diff --git a/content/child/blink_platform_impl.h b/content/child/blink_platform_impl.h index 6e7f834..6aab04b 100644 --- a/content/child/blink_platform_impl.h +++ b/content/child/blink_platform_impl.h @@ -165,8 +165,8 @@ class CONTENT_EXPORT BlinkPlatformImpl const blink::WebString& value1, const blink::WebString& value2) override; void suddenTerminationChanged(bool enabled) override {} - double currentTime() override; - double monotonicallyIncreasingTime() override; + double currentTimeSeconds() override; + double monotonicallyIncreasingTimeSeconds() override; double systemTraceTime() override; void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override; diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc index 72f0975..7e75ee9 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc @@ -242,7 +242,8 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl( plugin_refresh_allowed_(true), default_task_runner_(renderer_scheduler->DefaultTaskRunner()), loading_task_runner_(renderer_scheduler->LoadingTaskRunner()), - web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { + web_scrollbar_behavior_(new WebScrollbarBehaviorImpl), + renderer_scheduler_(renderer_scheduler) { #if !defined(OS_ANDROID) && !defined(OS_WIN) if (g_sandbox_enabled && sandboxEnabled()) { sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); @@ -278,6 +279,16 @@ void RendererBlinkPlatformImpl::Shutdown() { //------------------------------------------------------------------------------ +double RendererBlinkPlatformImpl::currentTimeSeconds() { + return renderer_scheduler_->CurrentTimeSeconds(); +} + +double RendererBlinkPlatformImpl::monotonicallyIncreasingTimeSeconds() { + return renderer_scheduler_->MonotonicallyIncreasingTimeSeconds(); +} + +//------------------------------------------------------------------------------ + blink::WebURLLoader* RendererBlinkPlatformImpl::createURLLoader() { ChildThreadImpl* child_thread = ChildThreadImpl::current(); // There may be no child thread in RenderViewTests. These tests can still use diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h index 235a66f..d9279741 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h @@ -170,6 +170,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { void recordRappor(const char* metric, const blink::WebString& sample) override; void recordRapporURL(const char* metric, const blink::WebURL& url) override; + double currentTimeSeconds() override; + double monotonicallyIncreasingTimeSeconds() override; // Set the PlatformEventObserverBase in |platform_event_observers_| associated // with |type| to |observer|. If there was already an observer associated to @@ -275,6 +277,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_; + scheduler::RendererScheduler* renderer_scheduler_; // NOT OWNED + DISALLOW_COPY_AND_ASSIGN(RendererBlinkPlatformImpl); }; diff --git a/content/test/fake_renderer_scheduler.cc b/content/test/fake_renderer_scheduler.cc index a869bf0..f0ae6c7 100644 --- a/content/test/fake_renderer_scheduler.cc +++ b/content/test/fake_renderer_scheduler.cc @@ -118,4 +118,12 @@ void FakeRendererScheduler::ResumeTimerQueue() { void FakeRendererScheduler::SetTimerQueueSuspensionWhenBackgroundedEnabled( bool enabled) {} +double FakeRendererScheduler::CurrentTimeSeconds() const { + return 0.0; +} + +double FakeRendererScheduler::MonotonicallyIncreasingTimeSeconds() const { + return 0.0; +} + } // namespace content diff --git a/content/test/fake_renderer_scheduler.h b/content/test/fake_renderer_scheduler.h index 168b428..4367f3f1 100644 --- a/content/test/fake_renderer_scheduler.h +++ b/content/test/fake_renderer_scheduler.h @@ -51,6 +51,8 @@ class FakeRendererScheduler : public scheduler::RendererScheduler { void SuspendTimerQueue() override; void ResumeTimerQueue() override; void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override; + double CurrentTimeSeconds() const override; + double MonotonicallyIncreasingTimeSeconds() const override; private: DISALLOW_COPY_AND_ASSIGN(FakeRendererScheduler); |