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

Side by Side Diff: gin/modules/console.cc

Issue 120043008: Add a simple one shot and repeating timer API for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gin/modules/console.h" 5 #include "gin/modules/console.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "gin/arguments.h" 10 #include "gin/arguments.h"
(...skipping 11 matching lines...) Expand all
22 void Log(const std::vector<std::string>& messages) { 22 void Log(const std::vector<std::string>& messages) {
23 std::cout << JoinString(messages, ' ') << std::endl; 23 std::cout << JoinString(messages, ' ') << std::endl;
24 } 24 }
25 25
26 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; 26 WrapperInfo g_wrapper_info = { kEmbedderNativeGin };
27 27
28 } // namespace 28 } // namespace
29 29
30 const char Console::kModuleName[] = "console"; 30 const char Console::kModuleName[] = "console";
31 31
32 v8::Local<ObjectTemplate> Console::GetTemplate(v8::Isolate* isolate) { 32 v8::Local<v8::Value> Console::GetModule(v8::Isolate* isolate) {
33 PerIsolateData* data = PerIsolateData::From(isolate); 33 PerIsolateData* data = PerIsolateData::From(isolate);
34 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); 34 v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info);
35 if (templ.IsEmpty()) { 35 if (templ.IsEmpty()) {
36 templ = ObjectTemplateBuilder(isolate) 36 templ = ObjectTemplateBuilder(isolate)
37 .SetMethod("log", Log) 37 .SetMethod("log", Log)
38 .Build(); 38 .Build();
39 data->SetObjectTemplate(&g_wrapper_info, templ); 39 data->SetObjectTemplate(&g_wrapper_info, templ);
40 } 40 }
41 return templ; 41 return templ->NewInstance();
42 } 42 }
43 43
44 } // namespace gin 44 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/console.h ('k') | gin/modules/module_registry.h » ('j') | gin/modules/timer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698