From 49ac160ff78da795133187eff30f4cb787b202c1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 11 May 2016 19:30:06 +0900 Subject: [PATCH] Move createIDWeakMap to v8Util --- atom/common/api/atom_api_key_weak_map.cc | 21 --------------------- atom/common/api/atom_api_v8_util.cc | 2 ++ atom/common/node_bindings.cc | 1 - filenames.gypi | 1 - lib/browser/rpc-server.js | 3 +-- lib/renderer/api/remote.js | 3 +-- 6 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 atom/common/api/atom_api_key_weak_map.cc diff --git a/atom/common/api/atom_api_key_weak_map.cc b/atom/common/api/atom_api_key_weak_map.cc deleted file mode 100644 index be703c2b15d..00000000000 --- a/atom/common/api/atom_api_key_weak_map.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/common/api/atom_api_key_weak_map.h" - -#include "atom/common/node_includes.h" -#include "native_mate/dictionary.h" - -namespace { - -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { - mate::Dictionary dict(context->GetIsolate(), exports); - dict.SetMethod("createIDWeakMap", - &atom::api::KeyWeakMap::Create); -} - -} // namespace - -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_id_weak_map, Initialize) diff --git a/atom/common/api/atom_api_v8_util.cc b/atom/common/api/atom_api_v8_util.cc index 109f9f0f36c..dcaa2ee5a74 100644 --- a/atom/common/api/atom_api_v8_util.cc +++ b/atom/common/api/atom_api_v8_util.cc @@ -4,6 +4,7 @@ #include +#include "atom/common/api/atom_api_key_weak_map.h" #include "atom/common/api/remote_callback_freer.h" #include "atom/common/api/remote_object_freer.h" #include "atom/common/native_mate_converters/content_converter.h" @@ -67,6 +68,7 @@ void Initialize(v8::Local exports, v8::Local unused, dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot); dict.SetMethod("setRemoteCallbackFreer", &atom::RemoteCallbackFreer::BindTo); dict.SetMethod("setRemoteObjectFreer", &atom::RemoteObjectFreer::BindTo); + dict.SetMethod("createIDWeakMap", &atom::api::KeyWeakMap::Create); } } // namespace diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 31105886eb7..b3c36fdd8e0 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -52,7 +52,6 @@ REFERENCE_MODULE(atom_browser_window); REFERENCE_MODULE(atom_common_asar); REFERENCE_MODULE(atom_common_clipboard); REFERENCE_MODULE(atom_common_crash_reporter); -REFERENCE_MODULE(atom_common_id_weak_map); REFERENCE_MODULE(atom_common_native_image); REFERENCE_MODULE(atom_common_screen); REFERENCE_MODULE(atom_common_shell); diff --git a/filenames.gypi b/filenames.gypi index e85f150615a..f9bbe8f75f1 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -288,7 +288,6 @@ 'atom/common/api/atom_api_asar.cc', 'atom/common/api/atom_api_clipboard.cc', 'atom/common/api/atom_api_crash_reporter.cc', - 'atom/common/api/atom_api_key_weak_map.cc', 'atom/common/api/atom_api_key_weak_map.h', 'atom/common/api/atom_api_native_image.cc', 'atom/common/api/atom_api_native_image.h', diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index 00b0e9f468e..afb50501871 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -3,7 +3,6 @@ const electron = require('electron') const v8Util = process.atomBinding('v8_util') const {ipcMain} = electron -const {createIDWeakMap} = process.atomBinding('id_weak_map') const objectsRegistry = require('./objects-registry') @@ -14,7 +13,7 @@ const FUNCTION_PROPERTIES = [ // The remote functions in renderer processes. // id => Function -let rendererFunctions = createIDWeakMap() +let rendererFunctions = v8Util.createIDWeakMap() // Merge two IDs together. let mergeIds = function (webContentsId, metaId) { diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index ae3011c5eb1..01d777e8526 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -2,13 +2,12 @@ const v8Util = process.atomBinding('v8_util') const {ipcRenderer, CallbacksRegistry} = require('electron') -const {createIDWeakMap} = process.atomBinding('id_weak_map') const callbacksRegistry = new CallbacksRegistry() var includes = [].includes -var remoteObjectCache = createIDWeakMap() +var remoteObjectCache = v8Util.createIDWeakMap() // Check for circular reference. var isCircular = function (field, visited) {