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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compilation 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/native_handler.cc
diff --git a/chrome/renderer/extensions/native_handler.cc b/chrome/renderer/extensions/native_handler.cc
index ee03ad0cac034f6ffe187d47af974b7ed83f577b..d6a9e57cd5518fd35bfbf2e3cc682ab2a3949611 100644
--- a/chrome/renderer/extensions/native_handler.cc
+++ b/chrome/renderer/extensions/native_handler.cc
@@ -1,56 +1,17 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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/native_handler.h"
-#include "base/memory/linked_ptr.h"
-#include "base/logging.h"
-#include "chrome/renderer/extensions/module_system.h"
-#include "v8/include/v8.h"
-
namespace extensions {
-NativeHandler::NativeHandler(v8::Isolate* isolate)
- : object_template_(v8::ObjectTemplate::New()) {}
+NativeHandler::NativeHandler() : is_valid_(true) {}
NativeHandler::~NativeHandler() {}
-v8::Handle<v8::Object> NativeHandler::NewInstance() {
- return object_template_->NewInstance();
-}
-
-// static
-v8::Handle<v8::Value> NativeHandler::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.
- if (!ModuleSystem::IsPresentInCurrentContext()) {
- return v8::ThrowException(v8::Exception::Error(
- v8::String::New("ModuleSystem has been deleted")));
- }
- HandlerFunction* handler_function = static_cast<HandlerFunction*>(
- args.Data().As<v8::External>()->Value());
- return handler_function->Run(args);
-}
-
-void NativeHandler::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
- // on to these pointers here.
- handler_functions_.push_back(function);
- v8::Handle<v8::FunctionTemplate> function_template =
- v8::FunctionTemplate::New(Router,
- v8::External::New(function.get()));
- object_template_->Set(name.c_str(), function_template);
-}
-
-void NativeHandler::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 NativeHandler::Invalidate() {
+ is_valid_ = false;
}
-} // extensions
+} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/native_handler.h ('k') | chrome/renderer/extensions/object_backed_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698