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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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/schema_generated_native_handler.cc
diff --git a/chrome/renderer/extensions/schema_generated_native_handler.cc b/chrome/renderer/extensions/schema_generated_native_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7bf4979cebe151a58d083de8b1c6beb7c966063c
--- /dev/null
+++ b/chrome/renderer/extensions/schema_generated_native_handler.cc
@@ -0,0 +1,39 @@
+// 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/schema_generated_native_handler.h"
+
+#include "chrome/renderer/extensions/module_system.h"
+#include "chrome/renderer/extensions/v8_schema_registry.h"
+
+namespace extensions {
+
+SchemaGeneratedNativeHandler::SchemaGeneratedNativeHandler(
+ ModuleSystem* module_system,
+ V8SchemaRegistry* schema_registry,
+ const std::string& api_name,
+ const std::string& bind_to)
+ : module_system_(module_system),
+ schema_registry_(schema_registry),
+ api_name_(api_name),
+ bind_to_(bind_to) {
+}
+
+v8::Handle<v8::Object> SchemaGeneratedNativeHandler::NewInstance() {
+ v8::Handle<v8::Object> schema = schema_registry_->GetSchema(api_name_);
+ v8::Handle<v8::Value> module =
+ module_system_->Require("schema_generated_bindings");
+ v8::Local<v8::Value> func =
+ v8::Handle<v8::Object>::Cast(module)->Get(
+ v8::String::New("compile"));
+
+ v8::Handle<v8::Value> argv[] = { schema };
+ v8::Handle<v8::Value> compiled_schema =
+ module_system_->CallModuleMethod(func, 1, argv);
+ object_template_->Set(bind_to_.c_str(), compiled_schema);
+ LOG(ERROR) << "CALLING NEW INSTANCE";
+ return object_template_->NewInstance();
not at google - send to devlin 2012/12/14 00:44:00 I think you can just construct a new object, no ne
cduvall 2012/12/14 02:04:50 I agree, I'll do it once I get some other stuff fi
+}
+
+} // extensions

Powered by Google App Engine
This is Rietveld 408576698