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

Side by Side Diff: chrome/renderer/native_handler.cc

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/native_handler.h ('k') | chrome/renderer/renderer_resources.grd » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/renderer/native_handler.h" 5 #include "chrome/renderer/native_handler.h"
6 6
7 #include "base/memory/linked_ptr.h" 7 #include "base/memory/linked_ptr.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "v8/include/v8.h" 9 #include "v8/include/v8.h"
10 10
(...skipping 10 matching lines...) Expand all
21 // static 21 // static
22 v8::Handle<v8::Value> NativeHandler::Router(const v8::Arguments& args) { 22 v8::Handle<v8::Value> NativeHandler::Router(const v8::Arguments& args) {
23 HandlerFunction* handler_function = static_cast<HandlerFunction*>( 23 HandlerFunction* handler_function = static_cast<HandlerFunction*>(
24 args.Data().As<v8::External>()->Value()); 24 args.Data().As<v8::External>()->Value());
25 return handler_function->Run(args); 25 return handler_function->Run(args);
26 } 26 }
27 27
28 void NativeHandler::RouteFunction(const std::string& name, 28 void NativeHandler::RouteFunction(const std::string& name,
29 const HandlerFunction& handler_function) { 29 const HandlerFunction& handler_function) {
30 linked_ptr<HandlerFunction> function(new HandlerFunction(handler_function)); 30 linked_ptr<HandlerFunction> function(new HandlerFunction(handler_function));
31 // TODO(koz): Investigate using v8's MakeWeak() function instead of holding
32 // on to these pointers here.
31 handler_functions_.push_back(function); 33 handler_functions_.push_back(function);
32 v8::Handle<v8::FunctionTemplate> function_template = 34 v8::Handle<v8::FunctionTemplate> function_template =
33 v8::FunctionTemplate::New(Router, 35 v8::FunctionTemplate::New(Router,
34 v8::External::New(function.get())); 36 v8::External::New(function.get()));
35 object_template_->Set(name.c_str(), function_template); 37 object_template_->Set(name.c_str(), function_template);
36 } 38 }
39
40 void NativeHandler::RouteStaticFunction(const std::string& name,
41 const HandlerFunc handler_func) {
42 v8::Handle<v8::FunctionTemplate> function_template =
43 v8::FunctionTemplate::New(handler_func, v8::External::New(this));
44 object_template_->Set(name.c_str(), function_template);
45 }
OLDNEW
« no previous file with comments | « chrome/renderer/native_handler.h ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698