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

Unified Diff: chrome/browser/extensions/api/generated_api_functions.h.tmpl

Issue 9359040: WIP IDL-IPC2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Checkpoint before going back to returning ListValue via ExtensionMsg_Response. Created 8 years, 10 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/browser/extensions/api/generated_api_functions.h.tmpl
diff --git a/chrome/browser/extensions/api/generated_api_functions.h.tmpl b/chrome/browser/extensions/api/generated_api_functions.h.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..ce2d3961002463c846d19f4c43ad335ae0a48bb5
--- /dev/null
+++ b/chrome/browser/extensions/api/generated_api_functions.h.tmpl
@@ -0,0 +1,90 @@
+// Copyright (c) $year 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.
+
+// This file is generated. Don't edit it.
+
+\#ifndef $guard
+\#define $guard
+\#pragma once
+
+\#include <string>
+
+\#include "chrome/browser/extensions/api/api_function.h"
+\#include "chrome/browser/extensions/extension_factory_registry.h"
+\#include "chrome/browser/extensions/extension_function.h"
+\#include "chrome/browser/extensions/extension_function_dispatcher.h"
+\#include "chrome/common/extensions/api/generated_messages.h"
+\#include "content/browser/renderer_host/render_view_host.h"
+\#include "content/public/browser/web_contents_observer.h"
+\#include "ipc/ipc_message.h"
+
+#for $family in $families
+\#include "${family.header_path}"
+#end for
+
+namespace extensions {
+
+// Keys used in API responses.
+#for $family in $families
+#for $function in $family.functions
+#for $return_value in $function.return_values
+extern const char k${$return_value.name}Key[];
+#end for
+#end for
+#end for
+
+class ExtensionAPIHost :
+ public content::WebContentsObserver {
+ public:
+ ExtensionAPIHost(
+ RenderViewHost* render_view_host,
+ ExtensionFunctionDispatcher* extension_function_dispatcher) :
+ render_view_host_(render_view_host),
+ extension_function_dispatcher_(extension_function_dispatcher) {
+ }
+
+ bool OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ExtensionAPIHost, message)
+#for $family in $families
+#for $function in $family.functions
+ IPC_MESSAGE_HANDLER(ExtensionAPIHostMsg_${function.class_name}, On${function.class_name})
+#end for
+#end for
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ private:
+#for $family in $families
+#for $function in $family.functions
+ void On${function.class_name}(
+ int request_id#for $argument in $function.arguments#,
+ $argument.mapped_arg_type $argument.name#end for#) {
+ render_view_host_->Send(
+ new ExtensionAPIViewMsg_${function.class_name}Response(
+ render_view_host_->routing_id(), request_id, 42));
+ }
+#end for
+#end for
+
+ RenderViewHost* render_view_host_;
+ ExtensionFunctionDispatcher* extension_function_dispatcher_;
+};
+
+class GeneratedAPIFunctionRegistry {
+ public:
+ static void RegisterAll(FactoryRegistry* registry) {
+#for $family in $families
+#for $f in $family.functions
+ registry->RegisterFunction<${f.class_name}Function>();
+#end for
+#end for
+ }
+};
+
+} // namespace extensions
+
+\#endif // $guard

Powered by Google App Engine
This is Rietveld 408576698