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
* 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
#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"
main_thread_queue_[isolate].push(task);
}
+
+double DefaultPlatform::MonotonicallyIncreasingTime() {
+ return base::TimeTicks::HighResolutionNow().ToInternalValue() /
+ static_cast<double>(base::Time::kMicrosecondsPerSecond);
+}
} } // namespace v8::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;