| Index: mojo/apps/js/bindings/monotonic_clock.cc
|
| diff --git a/mojo/apps/js/bindings/threading.cc b/mojo/apps/js/bindings/monotonic_clock.cc
|
| similarity index 54%
|
| copy from mojo/apps/js/bindings/threading.cc
|
| copy to mojo/apps/js/bindings/monotonic_clock.cc
|
| index 4b10bff0d170836002ef0501ee5561b6ad58f958..869a8316fb8f96e17ff036120ed85203b66b99d4 100644
|
| --- a/mojo/apps/js/bindings/threading.cc
|
| +++ b/mojo/apps/js/bindings/monotonic_clock.cc
|
| @@ -2,46 +2,41 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "mojo/apps/js/bindings/threading.h"
|
| +#include "mojo/apps/js/bindings/monotonic_clock.h"
|
|
|
| -#include "base/message_loop/message_loop.h"
|
| #include "gin/object_template_builder.h"
|
| #include "gin/per_isolate_data.h"
|
| -#include "mojo/apps/js/bindings/handle.h"
|
| +#include "gin/public/wrapper_info.h"
|
| +#include "mojo/public/system/core_cpp.h"
|
|
|
| namespace mojo {
|
| namespace apps {
|
|
|
| namespace {
|
|
|
| -void Quit() {
|
| - base::MessageLoop::current()->QuitNow();
|
| -}
|
| -
|
| gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin };
|
|
|
| +double GetMonotonicSeconds() {
|
| + const double kMicrosecondsPerSecond = 1000000;
|
| + return static_cast<double>(mojo::GetTimeTicksNow()) / kMicrosecondsPerSecond;
|
| +}
|
| +
|
| } // namespace
|
|
|
| -const char Threading::kModuleName[] = "mojo/apps/js/bindings/threading";
|
| +const char MonotonicClock::kModuleName[] = "monotonic_clock";
|
|
|
| -v8::Local<v8::Value> Threading::GetModule(v8::Isolate* isolate) {
|
| +v8::Local<v8::Value> MonotonicClock::GetModule(v8::Isolate* isolate) {
|
| gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
|
| - v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(
|
| - &g_wrapper_info);
|
| -
|
| + v8::Local<v8::ObjectTemplate> templ =
|
| + data->GetObjectTemplate(&g_wrapper_info);
|
| if (templ.IsEmpty()) {
|
| templ = gin::ObjectTemplateBuilder(isolate)
|
| - .SetMethod("quit", Quit)
|
| + .SetMethod("seconds", GetMonotonicSeconds)
|
| .Build();
|
| -
|
| data->SetObjectTemplate(&g_wrapper_info, templ);
|
| }
|
| -
|
| return templ->NewInstance();
|
| }
|
|
|
| -Threading::Threading() {
|
| -}
|
| -
|
| } // namespace apps
|
| } // namespace mojo
|
|
|