chore: remove native_mate (Part 5) (#20264)

* deprecate native_mate/native_mate/object_template_builder.h

* add gin_helper/object_template_builder.h

* add patch to avoid ambiguous error

* remove usage of object_template_builder_deprecated.h in a few files

* add note we should remove gin_helper/object_template_builder.h in future
This commit is contained in:
Cheng Zhao 2019-09-19 11:09:15 -04:00 committed by Shelley Vohr
parent 63f08fcdb0
commit 624ba4f642
39 changed files with 474 additions and 121 deletions

View file

@ -7,9 +7,9 @@
#include "base/hash/hash.h"
#include "electron/buildflags/buildflags.h"
#include "native_mate/dictionary.h"
#include "shell/common/native_mate_converters/content_converter.h"
#include "shell/common/native_mate_converters/gurl_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/native_mate_handle_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
#include "url/origin.h"
#include "v8/include/v8-profiler.h"
@ -20,6 +20,10 @@
#include "shell/common/api/remote/remote_object_freer.h"
#endif
// TODO(zcbenz): Remove the includes after removing native_mate.
#include "native_mate/dictionary.h"
#include "shell/common/native_mate_converters/content_converter.h"
namespace std {
// The hash function used by DoubleIDWeakMap.
@ -32,7 +36,7 @@ struct hash<std::pair<Type1, Type2>> {
} // namespace std
namespace mate {
namespace gin {
template <typename Type1, typename Type2>
struct Converter<std::pair<Type1, Type2>> {
@ -54,7 +58,7 @@ struct Converter<std::pair<Type1, Type2>> {
}
};
} // namespace mate
} // namespace gin
namespace {
@ -115,15 +119,18 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
gin_helper::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getHiddenValue", &GetHiddenValue);
dict.SetMethod("setHiddenValue", &SetHiddenValue);
dict.SetMethod("deleteHiddenValue", &DeleteHiddenValue);
dict.SetMethod("getObjectHash", &GetObjectHash);
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
dict.SetMethod("setRemoteCallbackFreer",
&electron::RemoteCallbackFreer::BindTo);
// TODO(zcbenz): Use gin_helper::Dictionary when content_converter.h is moved
// to gin.
mate::Dictionary mdict(context->GetIsolate(), exports);
mdict.SetMethod("setRemoteCallbackFreer",
&electron::RemoteCallbackFreer::BindTo);
dict.SetMethod("setRemoteObjectFreer", &electron::RemoteObjectFreer::BindTo);
dict.SetMethod("addRemoteObjectRef", &electron::RemoteObjectFreer::AddRef);
dict.SetMethod("createIDWeakMap",