summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 21:47:04 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 21:47:04 +0000
commitcb6c2bb25fa9cb9aaa7713fb829f77d660899b39 (patch)
treeee85fec3be3152fcb7ad8c8caa8dac19072a37e8 /mojo
parent22c17bcb2e798ed74c25cd366b40d8483c7eaf24 (diff)
downloadchromium_src-cb6c2bb25fa9cb9aaa7713fb829f77d660899b39.zip
chromium_src-cb6c2bb25fa9cb9aaa7713fb829f77d660899b39.tar.gz
chromium_src-cb6c2bb25fa9cb9aaa7713fb829f77d660899b39.tar.bz2
[gin] Introduce Wrappable::GetObjectTemplate
Instead of explicitly registering object templates for all wrapper infos, add a method on wrappable that returns the template when needed. BUG=none R=aa@chromium.org,abarth@chromium.org Review URL: https://codereview.chromium.org/113893005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/apps/js/bindings/gl/context.cc22
-rw-r--r--mojo/apps/js/bindings/gl/context.h4
-rw-r--r--mojo/apps/js/bindings/gl/module.cc4
-rw-r--r--mojo/apps/js/bindings/gl/opaque.cc13
-rw-r--r--mojo/apps/js/bindings/gl/opaque.h1
-rw-r--r--mojo/apps/js/bindings/support.cc10
-rw-r--r--mojo/apps/js/bindings/waiting_callback.cc11
-rw-r--r--mojo/apps/js/bindings/waiting_callback.h2
8 files changed, 13 insertions, 54 deletions
diff --git a/mojo/apps/js/bindings/gl/context.cc b/mojo/apps/js/bindings/gl/context.cc
index 27622a7..efba8e5 100644
--- a/mojo/apps/js/bindings/gl/context.cc
+++ b/mojo/apps/js/bindings/gl/context.cc
@@ -8,7 +8,6 @@
#include "gin/arguments.h"
#include "gin/object_template_builder.h"
-#include "gin/per_isolate_data.h"
#include "mojo/public/gles2/gles2.h"
namespace mojo {
@@ -22,21 +21,14 @@ gin::Handle<Context> Context::Create(v8::Isolate* isolate, uint64_t encoded,
return gin::CreateHandle(isolate, new Context(encoded, width, height));
}
-v8::Handle<v8::ObjectTemplate> Context::GetObjectTemplate(
+v8::Local<v8::ObjectTemplate> Context::GetObjectTemplate(
v8::Isolate* isolate) {
- gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
- v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(&kWrapperInfo);
- if (templ.IsEmpty()) {
- templ = gin::ObjectTemplateBuilder(isolate)
- .SetValue("VERTEX_SHADER", GL_VERTEX_SHADER)
- .SetMethod("createShader", CreateShader)
- .SetMethod("shaderSource", ShaderSource)
- .SetMethod("compileShader", CompileShader)
- .Build();
- templ->SetInternalFieldCount(gin::kNumberOfInternalFields);
- data->SetObjectTemplate(&kWrapperInfo, templ);
- }
- return templ;
+ return gin::ObjectTemplateBuilder(isolate)
+ .SetValue("VERTEX_SHADER", GL_VERTEX_SHADER)
+ .SetMethod("createShader", CreateShader)
+ .SetMethod("shaderSource", ShaderSource)
+ .SetMethod("compileShader", CompileShader)
+ .Build();
}
gin::Handle<Shader> Context::CreateShader(const gin::Arguments& args,
diff --git a/mojo/apps/js/bindings/gl/context.h b/mojo/apps/js/bindings/gl/context.h
index 40203c3..11f1753 100644
--- a/mojo/apps/js/bindings/gl/context.h
+++ b/mojo/apps/js/bindings/gl/context.h
@@ -28,10 +28,10 @@ class Context : public gin::Wrappable<Context> {
public:
static gin::WrapperInfo kWrapperInfo;
+ static v8::Local<v8::ObjectTemplate> GetObjectTemplate(v8::Isolate* isolate);
+
static gin::Handle<Context> Create(v8::Isolate* isolate, uint64_t encoded,
int width, int height);
- static v8::Handle<v8::ObjectTemplate> GetObjectTemplate(v8::Isolate* isolate);
-
static gin::Handle<Shader> CreateShader(const gin::Arguments& arguments,
GLenum type);
static void ShaderSource(gin::Handle<Shader> shader,
diff --git a/mojo/apps/js/bindings/gl/module.cc b/mojo/apps/js/bindings/gl/module.cc
index abc0706..adf5ac3 100644
--- a/mojo/apps/js/bindings/gl/module.cc
+++ b/mojo/apps/js/bindings/gl/module.cc
@@ -39,13 +39,9 @@ v8::Local<v8::ObjectTemplate> GetModuleTemplate(v8::Isolate* isolate) {
templ = gin::ObjectTemplateBuilder(isolate)
.SetMethod("Context", CreateContext)
.Build();
- templ->SetInternalFieldCount(gin::kNumberOfInternalFields);
data->SetObjectTemplate(&kWrapperInfo, templ);
}
- Context::GetObjectTemplate(isolate);
- Opaque::GetObjectTemplate(isolate);
-
return templ;
}
diff --git a/mojo/apps/js/bindings/gl/opaque.cc b/mojo/apps/js/bindings/gl/opaque.cc
index 8f45f48..91365f8 100644
--- a/mojo/apps/js/bindings/gl/opaque.cc
+++ b/mojo/apps/js/bindings/gl/opaque.cc
@@ -5,7 +5,6 @@
#include "mojo/apps/js/bindings/gl/opaque.h"
#include "gin/object_template_builder.h"
-#include "gin/per_isolate_data.h"
namespace mojo {
namespace js {
@@ -17,18 +16,6 @@ gin::Handle<Opaque> Opaque::Create(v8::Isolate* isolate, GLuint value) {
return gin::CreateHandle(isolate, new Opaque(value));
}
-v8::Handle<v8::ObjectTemplate> Opaque::GetObjectTemplate(v8::Isolate* isolate) {
- gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
- v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(&kWrapperInfo);
- if (templ.IsEmpty()) {
- templ = gin::ObjectTemplateBuilder(isolate)
- .Build();
- templ->SetInternalFieldCount(gin::kNumberOfInternalFields);
- data->SetObjectTemplate(&kWrapperInfo, templ);
- }
- return templ;
-}
-
Opaque::Opaque(GLuint value) : value_(value) {
}
diff --git a/mojo/apps/js/bindings/gl/opaque.h b/mojo/apps/js/bindings/gl/opaque.h
index 10df134..4755658 100644
--- a/mojo/apps/js/bindings/gl/opaque.h
+++ b/mojo/apps/js/bindings/gl/opaque.h
@@ -23,7 +23,6 @@ class Opaque : public gin::Wrappable<Opaque> {
static gin::WrapperInfo kWrapperInfo;
static gin::Handle<Opaque> Create(v8::Isolate* isolate, GLuint value);
- static v8::Handle<v8::ObjectTemplate> GetObjectTemplate(v8::Isolate* isolate);
GLuint value() const { return value_; }
void set_value(GLuint val) { value_ = val; }
diff --git a/mojo/apps/js/bindings/support.cc b/mojo/apps/js/bindings/support.cc
index 2e627bd..9907680 100644
--- a/mojo/apps/js/bindings/support.cc
+++ b/mojo/apps/js/bindings/support.cc
@@ -54,12 +54,10 @@ v8::Local<v8::ObjectTemplate> Support::GetTemplate(v8::Isolate* isolate) {
&g_wrapper_info);
if (templ.IsEmpty()) {
- WaitingCallback::EnsureRegistered(isolate);
-
- templ = gin::ObjectTemplateBuilder(isolate)
- .SetMethod("asyncWait", AsyncWait)
- .SetMethod("cancelWait", CancelWait)
- .Build();
+ templ = gin::ObjectTemplateBuilder(isolate)
+ .SetMethod("asyncWait", AsyncWait)
+ .SetMethod("cancelWait", CancelWait)
+ .Build();
data->SetObjectTemplate(&g_wrapper_info, templ);
}
diff --git a/mojo/apps/js/bindings/waiting_callback.cc b/mojo/apps/js/bindings/waiting_callback.cc
index 7537806..6769eb7 100644
--- a/mojo/apps/js/bindings/waiting_callback.cc
+++ b/mojo/apps/js/bindings/waiting_callback.cc
@@ -5,7 +5,6 @@
#include "mojo/apps/js/bindings/waiting_callback.h"
#include "gin/per_context_data.h"
-#include "gin/per_isolate_data.h"
namespace mojo {
namespace js {
@@ -37,16 +36,6 @@ gin::Handle<WaitingCallback> WaitingCallback::Create(
return gin::CreateHandle(isolate, new WaitingCallback(isolate, callback));
}
-void WaitingCallback::EnsureRegistered(v8::Isolate* isolate) {
- gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
- if (!data->GetObjectTemplate(&WaitingCallback::kWrapperInfo).IsEmpty()) {
- return;
- }
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
- templ->SetInternalFieldCount(gin::kNumberOfInternalFields);
- data->SetObjectTemplate(&WaitingCallback::kWrapperInfo, templ);
-}
-
void WaitingCallback::OnHandleReady(MojoResult result) {
wait_id_ = NULL;
diff --git a/mojo/apps/js/bindings/waiting_callback.h b/mojo/apps/js/bindings/waiting_callback.h
index 55c9b3e..63b3dda 100644
--- a/mojo/apps/js/bindings/waiting_callback.h
+++ b/mojo/apps/js/bindings/waiting_callback.h
@@ -21,8 +21,6 @@ class WaitingCallback : public gin::Wrappable<WaitingCallback>,
static gin::Handle<WaitingCallback> Create(
v8::Isolate* isolate, v8::Handle<v8::Function> callback);
- static void EnsureRegistered(v8::Isolate* isolate);
-
BindingsSupport::AsyncWaitID wait_id() const {
return wait_id_;
}