diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 18:16:32 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 18:16:32 +0000 |
commit | da9a01cfbe84f32c73988f8edb8bf2134d17f10c (patch) | |
tree | 26f74fc05001e5f98912c779e0376453c10c324f /gin/test | |
parent | 15877542c33babc237586513096f3077c313449c (diff) | |
download | chromium_src-da9a01cfbe84f32c73988f8edb8bf2134d17f10c.zip chromium_src-da9a01cfbe84f32c73988f8edb8bf2134d17f10c.tar.gz chromium_src-da9a01cfbe84f32c73988f8edb8bf2134d17f10c.tar.bz2 |
Change mojo JS bindings to expose a handle object, which is Closed when garbage
collected, rather than a raw integer.
BUG=357785
Review URL: https://codereview.chromium.org/214183003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/test')
-rw-r--r-- | gin/test/file_runner.cc | 2 | ||||
-rw-r--r-- | gin/test/gc.cc | 39 | ||||
-rw-r--r-- | gin/test/gc.h | 21 |
3 files changed, 62 insertions, 0 deletions
diff --git a/gin/test/file_runner.cc b/gin/test/file_runner.cc index 86cb2f3..858fb39 100644 --- a/gin/test/file_runner.cc +++ b/gin/test/file_runner.cc @@ -12,6 +12,7 @@ #include "gin/modules/module_registry.h" #include "gin/public/context_holder.h" #include "gin/public/isolate_holder.h" +#include "gin/test/gc.h" #include "gin/test/gtest.h" #include "gin/try_catch.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,6 +35,7 @@ FileRunnerDelegate::FileRunnerDelegate() : ModuleRunnerDelegate(GetModuleSearchPaths()) { AddBuiltinModule(Console::kModuleName, Console::GetModule); AddBuiltinModule(GTest::kModuleName, GTest::GetModule); + AddBuiltinModule(GC::kModuleName, GC::GetModule); } FileRunnerDelegate::~FileRunnerDelegate() { diff --git a/gin/test/gc.cc b/gin/test/gc.cc new file mode 100644 index 0000000..1ad6cf2 --- /dev/null +++ b/gin/test/gc.cc @@ -0,0 +1,39 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gin/test/gc.h" + +#include "base/bind.h" +#include "base/logging.h" +#include "gin/arguments.h" +#include "gin/converter.h" +#include "gin/function_template.h" +#include "gin/object_template_builder.h" +#include "gin/per_isolate_data.h" +#include "gin/public/wrapper_info.h" +#include "gin/wrappable.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace gin { + +namespace { +WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; +} // namespace + +const char GC::kModuleName[] = "gc"; + +v8::Local<v8::Value> GC::GetModule(v8::Isolate* isolate) { + PerIsolateData* data = PerIsolateData::From(isolate); + v8::Local<v8::ObjectTemplate> templ = + data->GetObjectTemplate(&g_wrapper_info); + if (templ.IsEmpty()) { + templ = ObjectTemplateBuilder(isolate) + .SetMethod("collectGarbage", v8::V8::LowMemoryNotification) + .Build(); + data->SetObjectTemplate(&g_wrapper_info, templ); + } + return templ->NewInstance(); +} + +} // namespace gin diff --git a/gin/test/gc.h b/gin/test/gc.h new file mode 100644 index 0000000..25917ef --- /dev/null +++ b/gin/test/gc.h @@ -0,0 +1,21 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef GIN_TEST_GC_H_ +#define GIN_TEST_GC_H_ + +#include "v8/include/v8.h" + +namespace gin { + +// This module provides bindings to the garbage collector. +class GC { + public: + static const char kModuleName[]; + static v8::Local<v8::Value> GetModule(v8::Isolate* isolate); +}; + +} // namespace gin + +#endif // GIN_TEST_GC_H_ |