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

Side by Side Diff: mojo/apps/js/bindings/monotonic_clock.cc

Issue 614893002: use base::Time constants in mojo instead of defining locally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mojo/apps/js/bindings/monotonic_clock.h"
6 6
7 #include "base/time/time.h"
7 #include "gin/object_template_builder.h" 8 #include "gin/object_template_builder.h"
8 #include "gin/per_isolate_data.h" 9 #include "gin/per_isolate_data.h"
9 #include "gin/public/wrapper_info.h" 10 #include "gin/public/wrapper_info.h"
10 #include "mojo/public/cpp/system/core.h" 11 #include "mojo/public/cpp/system/core.h"
11 12
12 namespace mojo { 13 namespace mojo {
13 namespace apps { 14 namespace apps {
14 15
15 namespace { 16 namespace {
16 17
17 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; 18 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin };
18 19
19 double GetMonotonicSeconds() { 20 double GetMonotonicSeconds() {
20 const double kMicrosecondsPerSecond = 1000000; 21 return static_cast<double>(mojo::GetTimeTicksNow()) / base::Time::kMicrosecond sPerSecond;
darin (slow to review) 2014/10/09 17:12:50 nit: need to reformat for 80 character line limit
prashant.hiremath 2014/10/09 17:44:40 I,m confused between moving second part i.e base::
21 return static_cast<double>(mojo::GetTimeTicksNow()) / kMicrosecondsPerSecond;
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
26 const char MonotonicClock::kModuleName[] = "monotonic_clock"; 26 const char MonotonicClock::kModuleName[] = "monotonic_clock";
27 27
28 v8::Local<v8::Value> MonotonicClock::GetModule(v8::Isolate* isolate) { 28 v8::Local<v8::Value> MonotonicClock::GetModule(v8::Isolate* isolate) {
29 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 29 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
30 v8::Local<v8::ObjectTemplate> templ = 30 v8::Local<v8::ObjectTemplate> templ =
31 data->GetObjectTemplate(&g_wrapper_info); 31 data->GetObjectTemplate(&g_wrapper_info);
32 if (templ.IsEmpty()) { 32 if (templ.IsEmpty()) {
33 templ = gin::ObjectTemplateBuilder(isolate) 33 templ = gin::ObjectTemplateBuilder(isolate)
34 .SetMethod("seconds", GetMonotonicSeconds) 34 .SetMethod("seconds", GetMonotonicSeconds)
35 .Build(); 35 .Build();
36 data->SetObjectTemplate(&g_wrapper_info, templ); 36 data->SetObjectTemplate(&g_wrapper_info, templ);
37 } 37 }
38 return templ->NewInstance(); 38 return templ->NewInstance();
39 } 39 }
40 40
41 } // namespace apps 41 } // namespace apps
42 } // namespace mojo 42 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698