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 3// found in the LICENSE file. 4 5#include "mojo/edk/js/threading.h" 6 7#include "base/message_loop/message_loop.h" 8#include "gin/object_template_builder.h" 9#include "gin/per_isolate_data.h" 10#include "mojo/edk/js/handle.h" 11 12namespace mojo { 13namespace edk { 14namespace js { 15 16namespace { 17 18void Quit() { 19 base::MessageLoop::current()->QuitNow(); 20} 21 22gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; 23 24} // namespace 25 26const char Threading::kModuleName[] = "mojo/public/js/threading"; 27 28v8::Local<v8::Value> Threading::GetModule(v8::Isolate* isolate) { 29 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 30 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( 31 &g_wrapper_info); 32 33 if (templ.IsEmpty()) { 34 templ = gin::ObjectTemplateBuilder(isolate) 35 .SetMethod("quit", Quit) 36 .Build(); 37 38 data->SetObjectTemplate(&g_wrapper_info, templ); 39 } 40 41 return templ->NewInstance(); 42} 43 44Threading::Threading() { 45} 46 47} // namespace js 48} // namespace edk 49} // namespace mojo 50