22// Use of this source code is governed by the MIT license that can be
33// found in the LICENSE file.
44
5- #include < stddef.h>
6-
75#include < vector>
86
7+ #include " gin/handle.h"
8+ #include " gin/object_template_builder.h"
9+ #include " gin/wrappable.h"
910#include " shell/common/asar/archive.h"
1011#include " shell/common/asar/asar_util.h"
1112#include " shell/common/gin_converters/callback_converter.h"
1213#include " shell/common/gin_converters/file_path_converter.h"
1314#include " shell/common/gin_helper/dictionary.h"
14- #include " shell/common/gin_helper/object_template_builder.h"
15- #include " shell/common/gin_helper/wrappable.h"
1615#include " shell/common/node_includes.h"
1716#include " shell/common/node_util.h"
17+
1818namespace {
1919
20- class Archive : public gin_helper ::Wrappable<Archive> {
20+ class Archive : public gin ::Wrappable<Archive> {
2121 public:
22- static v8::Local<v8::Value > Create (v8::Isolate* isolate,
22+ static gin::Handle<Archive > Create (v8::Isolate* isolate,
2323 const base::FilePath& path) {
2424 auto archive = std::make_unique<asar::Archive>(path);
2525 if (!archive->Init ())
26- return v8::False (isolate );
27- return ( new Archive (isolate, std::move (archive)))-> GetWrapper ( );
26+ return gin::Handle<Archive>( );
27+ return gin::CreateHandle (isolate, new Archive (isolate, std::move (archive)));
2828 }
2929
30- static void BuildPrototype (v8::Isolate* isolate,
31- v8::Local<v8::FunctionTemplate> prototype) {
32- prototype->SetClassName (gin::StringToV8 (isolate, " Archive" ));
33- gin_helper::ObjectTemplateBuilder (isolate, prototype->PrototypeTemplate ())
30+ // gin::Wrappable
31+ static gin::WrapperInfo kWrapperInfo ;
32+ gin::ObjectTemplateBuilder GetObjectTemplateBuilder (
33+ v8::Isolate* isolate) override {
34+ return gin::ObjectTemplateBuilder (isolate)
3435 .SetProperty (" path" , &Archive::GetPath)
3536 .SetMethod (" getFileInfo" , &Archive::GetFileInfo)
3637 .SetMethod (" stat" , &Archive::Stat)
@@ -40,11 +41,11 @@ class Archive : public gin_helper::Wrappable<Archive> {
4041 .SetMethod (" getFd" , &Archive::GetFD);
4142 }
4243
44+ const char * GetTypeName () override { return " Archive" ; }
45+
4346 protected:
4447 Archive (v8::Isolate* isolate, std::unique_ptr<asar::Archive> archive)
45- : archive_(std::move(archive)) {
46- Init (isolate);
47- }
48+ : archive_(std::move(archive)) {}
4849
4950 // Returns the path of the file.
5051 base::FilePath GetPath () { return archive_->path (); }
@@ -116,6 +117,9 @@ class Archive : public gin_helper::Wrappable<Archive> {
116117 DISALLOW_COPY_AND_ASSIGN (Archive);
117118};
118119
120+ // static
121+ gin::WrapperInfo Archive::kWrapperInfo = {gin::kEmbedderNativeGin };
122+
119123void InitAsarSupport (v8::Isolate* isolate, v8::Local<v8::Value> require) {
120124 // Evaluate asar_bundle.js.
121125 std::vector<v8::Local<v8::String>> asar_bundle_params = {
0 commit comments