Reviewers: jochen,

Message:
V8 side of adding the embedder specified time function to V8's platform object.
Chromium change is: https://codereview.chromium.org/634523002/

Jochen could you please take a look, thanks.


Description:
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

Please review this at https://codereview.chromium.org/632663002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+21, -0 lines):
  M include/v8-platform.h
  M src/libplatform/default-platform.h
  M src/libplatform/default-platform.cc


Index: include/v8-platform.h
diff --git a/include/v8-platform.h b/include/v8-platform.h
index 1f1679f0e0b60ec7e36281e480cb20d8c8cad64b..7bac11aef069957fc7e22b0a437becdac44b8148 100644
--- a/include/v8-platform.h
+++ b/include/v8-platform.h
@@ -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
Index: src/libplatform/default-platform.cc
diff --git a/src/libplatform/default-platform.cc b/src/libplatform/default-platform.cc index b5b8571dbc9a9e4d059d91bb641bf5a6ff81f858..1ac52f919f3f4889037512e332a5b07fba25146c 100644
--- a/src/libplatform/default-platform.cc
+++ b/src/libplatform/default-platform.cc
@@ -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
Index: src/libplatform/default-platform.h
diff --git a/src/libplatform/default-platform.h b/src/libplatform/default-platform.h index 1efd7b24fe8807275ba3a357795a21837e6179fc..552949826a4ea105364ea2b33d6f482d71ffaa89 100644
--- a/src/libplatform/default-platform.h
+++ b/src/libplatform/default-platform.h
@@ -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;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to