Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: gin/function_template.h

Issue 2126763002: Remove the prototype from all V8 functions that aren't constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/object_backed_native_handler.cc ('k') | gin/modules/module_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GIN_FUNCTION_TEMPLATE_H_ 5 #ifndef GIN_FUNCTION_TEMPLATE_H_
6 #define GIN_FUNCTION_TEMPLATE_H_ 6 #define GIN_FUNCTION_TEMPLATE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // internal reasons, thus it is generally a good idea to cache the template 230 // internal reasons, thus it is generally a good idea to cache the template
231 // returned by this function. Otherwise, repeated method invocations from JS 231 // returned by this function. Otherwise, repeated method invocations from JS
232 // will create substantial memory leaks. See http://crbug.com/463487. 232 // will create substantial memory leaks. See http://crbug.com/463487.
233 template<typename Sig> 233 template<typename Sig>
234 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( 234 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
235 v8::Isolate* isolate, const base::Callback<Sig> callback, 235 v8::Isolate* isolate, const base::Callback<Sig> callback,
236 int callback_flags = 0) { 236 int callback_flags = 0) {
237 typedef internal::CallbackHolder<Sig> HolderT; 237 typedef internal::CallbackHolder<Sig> HolderT;
238 HolderT* holder = new HolderT(isolate, callback, callback_flags); 238 HolderT* holder = new HolderT(isolate, callback, callback_flags);
239 239
240 return v8::FunctionTemplate::New( 240 v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(
241 isolate, 241 isolate, &internal::Dispatcher<Sig>::DispatchToCallback,
242 &internal::Dispatcher<Sig>::DispatchToCallback, 242 ConvertToV8<v8::Local<v8::External>>(isolate,
243 ConvertToV8<v8::Local<v8::External> >(isolate, 243 holder->GetHandle(isolate)));
244 holder->GetHandle(isolate))); 244 tmpl->RemovePrototype();
245 return tmpl;
245 } 246 }
246 247
247 // CreateFunctionHandler installs a CallAsFunction handler on the given 248 // CreateFunctionHandler installs a CallAsFunction handler on the given
248 // object template that forwards to a provided C++ function or base::Callback. 249 // object template that forwards to a provided C++ function or base::Callback.
249 template<typename Sig> 250 template<typename Sig>
250 void CreateFunctionHandler(v8::Isolate* isolate, 251 void CreateFunctionHandler(v8::Isolate* isolate,
251 v8::Local<v8::ObjectTemplate> tmpl, 252 v8::Local<v8::ObjectTemplate> tmpl,
252 const base::Callback<Sig> callback, 253 const base::Callback<Sig> callback,
253 int callback_flags = 0) { 254 int callback_flags = 0) {
254 typedef internal::CallbackHolder<Sig> HolderT; 255 typedef internal::CallbackHolder<Sig> HolderT;
255 HolderT* holder = new HolderT(isolate, callback, callback_flags); 256 HolderT* holder = new HolderT(isolate, callback, callback_flags);
256 tmpl->SetCallAsFunctionHandler(&internal::Dispatcher<Sig>::DispatchToCallback, 257 tmpl->SetCallAsFunctionHandler(&internal::Dispatcher<Sig>::DispatchToCallback,
257 ConvertToV8<v8::Local<v8::External> >( 258 ConvertToV8<v8::Local<v8::External> >(
258 isolate, holder->GetHandle(isolate))); 259 isolate, holder->GetHandle(isolate)));
259 } 260 }
260 261
261 } // namespace gin 262 } // namespace gin
262 263
263 #endif // GIN_FUNCTION_TEMPLATE_H_ 264 #endif // GIN_FUNCTION_TEMPLATE_H_
OLDNEW
« no previous file with comments | « extensions/renderer/object_backed_native_handler.cc ('k') | gin/modules/module_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698