Use new context aware module API in builtin modules.

This commit is contained in:
Cheng Zhao 2014-06-29 20:48:44 +08:00
parent c3301a197e
commit ba46f2c820
16 changed files with 64 additions and 49 deletions

View file

@ -67,8 +67,9 @@ void Clear(ui::ClipboardType type) {
ui::Clipboard::GetForCurrentThread()->Clear(type);
}
void Initialize(v8::Handle<v8::Object> exports) {
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("_has", &Has);
dict.SetMethod("_read", &Read);
dict.SetMethod("_readText", &ReadText);
@ -78,4 +79,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_clipboard, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_clipboard, Initialize)

View file

@ -35,9 +35,10 @@ struct Converter<std::map<std::string, std::string> > {
namespace {
void Initialize(v8::Handle<v8::Object> exports) {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
using crash_reporter::CrashReporter;
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("start",
base::Bind(&CrashReporter::Start,
base::Unretained(CrashReporter::GetInstance())));
@ -45,4 +46,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_crash_reporter, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize)

View file

@ -91,10 +91,10 @@ void IDWeakMap::WeakCallback(
namespace {
void Initialize(v8::Handle<v8::Object> exports) {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
using atom::api::IDWeakMap;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(
isolate,
"IDWeakMap",
@ -104,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_id_weak_map, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_id_weak_map, Initialize)

View file

@ -86,13 +86,14 @@ struct Converter<gfx::Display> {
namespace {
void Initialize(v8::Handle<v8::Object> exports) {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
#if defined(TOOLKIT_GTK)
gfx::GdkInitFromCommandLine(*CommandLine::ForCurrentProcess());
#endif
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCursorScreenPoint",
base::Bind(&gfx::Screen::GetCursorScreenPoint,
base::Unretained(screen)));
@ -103,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_screen, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)

View file

@ -13,8 +13,9 @@
namespace {
void Initialize(v8::Handle<v8::Object> exports) {
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
dict.SetMethod("openItem", &platform_util::OpenItem);
dict.SetMethod("openExternal", &platform_util::OpenExternal);
@ -24,4 +25,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_shell, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize)

View file

@ -43,8 +43,9 @@ void TakeHeapSnapshot(v8::Isolate* isolate) {
mate::StringToV8(isolate, "test"));
}
void Initialize(v8::Handle<v8::Object> exports) {
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createObjectWithName", &CreateObjectWithName);
dict.SetMethod("getHiddenValue", &GetHiddenValue);
dict.SetMethod("setHiddenValue", &SetHiddenValue);
@ -55,4 +56,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
} // namespace
NODE_MODULE_X(atom_common_v8_util, Initialize, NULL, NM_F_BUILTIN)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_v8_util, Initialize)