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

Unified Diff: chrome/renderer/extensions/object_backed_native_handler.cc

Issue 12632004: Revert 186643 - Caused a 10% regression on SunSpider benchmark (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/object_backed_native_handler.cc
===================================================================
--- chrome/renderer/extensions/object_backed_native_handler.cc (revision 186747)
+++ chrome/renderer/extensions/object_backed_native_handler.cc (working copy)
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 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 "chrome/renderer/extensions/object_backed_native_handler.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 {
-
-// Data to pass to ObjectBackedNativeHandler::Router.
-struct ObjectBackedNativeHandler::RouterData {
- RouterData(ObjectBackedNativeHandler* self, HandlerFunction function)
- : self(self), function(function) {}
-
- ~RouterData() {}
-
- // The owner of the routed data.
- ObjectBackedNativeHandler* const self;
-
- // The function to route calls to.
- HandlerFunction function;
-};
-
-ObjectBackedNativeHandler::ObjectBackedNativeHandler(
- v8::Handle<v8::Context> context)
- : v8_context_(context),
- object_template_(
- v8::Persistent<v8::ObjectTemplate>::New(context->GetIsolate(),
- v8::ObjectTemplate::New())) {
-}
-
-ObjectBackedNativeHandler::~ObjectBackedNativeHandler() {
-}
-
-v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() {
- return object_template_->NewInstance();
-}
-
-// static
-v8::Handle<v8::Value> ObjectBackedNativeHandler::Router(
- const v8::Arguments& args) {
- RouterData* router_data = static_cast<RouterData*>(
- args.Data().As<v8::External>()->Value());
- // Router can be called during context destruction. Stop.
- if (!router_data->self->is_valid())
- return v8::Handle<v8::Value>();
- return router_data->function.Run(args);
-}
-
-void ObjectBackedNativeHandler::RouteFunction(const std::string& name,
- const HandlerFunction& handler_function) {
- linked_ptr<RouterData> data(new RouterData(this, handler_function));
- // TODO(koz): Investigate using v8's MakeWeak() function instead of holding
- // on to these pointers here.
- router_data_.push_back(data);
- v8::Handle<v8::FunctionTemplate> function_template =
- v8::FunctionTemplate::New(Router, v8::External::New(data.get()));
- object_template_->Set(name.c_str(), function_template);
-}
-
-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));
- object_template_->Set(name.c_str(), function_template);
-}
-
-void ObjectBackedNativeHandler::Invalidate() {
- if (!is_valid())
- return;
- object_template_.Clear();
- v8_context_.Clear();
- NativeHandler::Invalidate();
-}
-
-} // extensions
« no previous file with comments | « chrome/renderer/extensions/object_backed_native_handler.h ('k') | chrome/renderer/extensions/page_actions_custom_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698