Commit 7cbe1ef9 authored by rmcilroy@chromium.org's avatar rmcilroy@chromium.org

Add MonotonicallyIncreasingTime to V8 Platform.

Adds a MonotonicallyIncreasingTime() function to the Platform API to enable the
embedder to provide a time API to V8 which will be used for IdleNotification deadlines.

BUG=417668
LOG=Y
R=jochen@chromium.org

Review URL: https://codereview.chromium.org/632663002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24411 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent de518336
......@@ -55,6 +55,20 @@ class Platform {
* scheduling. The definition of "foreground" is opaque to V8.
*/
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
/**
* Monotonically increasing time in seconds from an arbitrary fixed point in
* the past. This function is expected to return at least
* millisecond-precision values. For this reason,
* it is recommended that the fixed point be no further in the past than
* the epoch.
**/
virtual double MonotonicallyIncreasingTime() {
// TODO(rmcilroy): Remove this default implementation when Chromium
// change has landed.
return 0;
}
};
} // namespace v8
......
......@@ -9,6 +9,7 @@
#include "src/base/logging.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/sys-info.h"
#include "src/libplatform/worker-thread.h"
......@@ -106,4 +107,9 @@ void DefaultPlatform::CallOnForegroundThread(v8::Isolate* isolate, Task* task) {
main_thread_queue_[isolate].push(task);
}
double DefaultPlatform::MonotonicallyIncreasingTime() {
return base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);
}
} } // namespace v8::platform
......@@ -37,6 +37,7 @@ class DefaultPlatform : public Platform {
Task* task, ExpectedRuntime expected_runtime) OVERRIDE;
virtual void CallOnForegroundThread(v8::Isolate* isolate,
Task* task) OVERRIDE;
virtual double MonotonicallyIncreasingTime() OVERRIDE;
private:
static const int kMaxThreadPoolSize;
......
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