Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: services/js/modules/clock/monotonic_clock.cc

Issue 703023004: Move the JS content handler et al from mojo/apps/js to mojo/services (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixed DEPS gl build Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/apps/js/bindings/monotonic_clock.h" 5 #include "services/js/modules/clock/monotonic_clock.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "gin/object_template_builder.h" 8 #include "gin/object_template_builder.h"
9 #include "gin/per_isolate_data.h" 9 #include "gin/per_isolate_data.h"
10 #include "gin/public/wrapper_info.h" 10 #include "gin/public/wrapper_info.h"
11 #include "mojo/public/cpp/system/core.h" 11 #include "mojo/public/cpp/system/core.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace apps { 14 namespace js {
15 15
16 namespace { 16 namespace {
17 17
18 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; 18 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin };
19 19
20 double GetMonotonicSeconds() { 20 double GetMonotonicSeconds() {
21 return static_cast<double>(mojo::GetTimeTicksNow()) / 21 return static_cast<double>(mojo::GetTimeTicksNow()) /
22 base::Time::kMicrosecondsPerSecond; 22 base::Time::kMicrosecondsPerSecond;
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 const char MonotonicClock::kModuleName[] = "monotonic_clock"; 27 const char MonotonicClock::kModuleName[] = "services/js/modules/clock";
28 28
29 v8::Local<v8::Value> MonotonicClock::GetModule(v8::Isolate* isolate) { 29 v8::Local<v8::Value> MonotonicClock::GetModule(v8::Isolate* isolate) {
30 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 30 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
31 v8::Local<v8::ObjectTemplate> templ = 31 v8::Local<v8::ObjectTemplate> templ =
32 data->GetObjectTemplate(&g_wrapper_info); 32 data->GetObjectTemplate(&g_wrapper_info);
33 if (templ.IsEmpty()) { 33 if (templ.IsEmpty()) {
34 templ = gin::ObjectTemplateBuilder(isolate) 34 templ = gin::ObjectTemplateBuilder(isolate)
35 .SetMethod("seconds", GetMonotonicSeconds) 35 .SetMethod("seconds", GetMonotonicSeconds)
36 .Build(); 36 .Build();
37 data->SetObjectTemplate(&g_wrapper_info, templ); 37 data->SetObjectTemplate(&g_wrapper_info, templ);
38 } 38 }
39 return templ->NewInstance(); 39 return templ->NewInstance();
40 } 40 }
41 41
42 } // namespace apps 42 } // namespace js
43 } // namespace mojo 43 } // namespace mojo
OLDNEW
« no previous file with comments | « services/js/modules/clock/monotonic_clock.h ('k') | services/js/modules/clock/monotonic_clock_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698