| Index: chrome/renderer/extensions/object_backed_native_handler.cc
|
| diff --git a/chrome/renderer/extensions/native_handler.cc b/chrome/renderer/extensions/object_backed_native_handler.cc
|
| similarity index 78%
|
| rename from chrome/renderer/extensions/native_handler.cc
|
| rename to chrome/renderer/extensions/object_backed_native_handler.cc
|
| index a294891b9cb0119e371233e1ec7b260bc72653b5..a1a3ea8ca40aa79932407bfe5fb584d435fd2ba3 100644
|
| --- a/chrome/renderer/extensions/native_handler.cc
|
| +++ b/chrome/renderer/extensions/object_backed_native_handler.cc
|
| @@ -2,30 +2,31 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/renderer/extensions/native_handler.h"
|
| +#include "chrome/renderer/extensions/object_backed_native_handler.h"
|
|
|
| -#include "base/memory/linked_ptr.h"
|
| #include "base/logging.h"
|
| +#include "base/memory/linked_ptr.h"
|
| #include "chrome/renderer/extensions/module_system.h"
|
| #include "v8/include/v8.h"
|
|
|
| namespace extensions {
|
|
|
| -NativeHandler::NativeHandler()
|
| +ObjectBackedNativeHandler::ObjectBackedNativeHandler()
|
| : object_template_(
|
| v8::Persistent<v8::ObjectTemplate>::New(v8::ObjectTemplate::New())) {
|
| }
|
|
|
| -NativeHandler::~NativeHandler() {
|
| +ObjectBackedNativeHandler::~ObjectBackedNativeHandler() {
|
| object_template_.Dispose();
|
| }
|
|
|
| -v8::Handle<v8::Object> NativeHandler::NewInstance() {
|
| +v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() {
|
| return object_template_->NewInstance();
|
| }
|
|
|
| // static
|
| -v8::Handle<v8::Value> NativeHandler::Router(const v8::Arguments& args) {
|
| +v8::Handle<v8::Value> ObjectBackedNativeHandler::Router(
|
| + const v8::Arguments& args) {
|
| // It is possible for JS code to execute after ModuleSystem has been deleted
|
| // in which case the native handlers will also have been deleted, making
|
| // HandlerFunction below point to freed memory.
|
| @@ -38,7 +39,7 @@ v8::Handle<v8::Value> NativeHandler::Router(const v8::Arguments& args) {
|
| return handler_function->Run(args);
|
| }
|
|
|
| -void NativeHandler::RouteFunction(const std::string& name,
|
| +void ObjectBackedNativeHandler::RouteFunction(const std::string& name,
|
| const HandlerFunction& handler_function) {
|
| linked_ptr<HandlerFunction> function(new HandlerFunction(handler_function));
|
| // TODO(koz): Investigate using v8's MakeWeak() function instead of holding
|
| @@ -50,7 +51,7 @@ void NativeHandler::RouteFunction(const std::string& name,
|
| object_template_->Set(name.c_str(), function_template);
|
| }
|
|
|
| -void NativeHandler::RouteStaticFunction(const std::string& name,
|
| +void ObjectBackedNativeHandler::RouteStaticFunction(const std::string& name,
|
| const HandlerFunc handler_func) {
|
| v8::Handle<v8::FunctionTemplate> function_template =
|
| v8::FunctionTemplate::New(handler_func, v8::External::New(this));
|
|
|