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

Unified Diff: examples/srpc/duality/loader.cc

Issue 2856050: Adding srpc example to naclports. (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: '' Created 10 years, 5 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
« no previous file with comments | « examples/srpc/duality/duality.html ('k') | examples/srpc/duality/nacl_build.mk » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/srpc/duality/loader.cc
===================================================================
--- examples/srpc/duality/loader.cc (revision 0)
+++ examples/srpc/duality/loader.cc (revision 0)
@@ -0,0 +1,57 @@
+// Copyright 2010 The Native Client SDK 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 <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <nacl/npupp.h>
+
+
+
+
+// These functions are called when a module instance is first loaded, and when
+// the module instance is finally deleted. They must use C-style linkage.
+
+extern "C" {
+// Populates |plugin_funcs| by calling InitializePluginFunctions.
+// Declaration: npupp.h
+// Web Reference: N/A
+NPError NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
+ extern NPError InitializePluginFunctions(NPPluginFuncs* plugin_funcs);
+ return InitializePluginFunctions(plugin_funcs);
+}
+
+// Some platforms, including Native Client use the two-parameter version of
+// NP_Initialize(), and do not call NP_GetEntryPoints(). Others (Mac, e.g.)
+// use single-parameter version of NP_Initialize(), and then call
+// NP_GetEntryPoints() to get the NPP functions. Also, the NPN entry points
+// are defined by the Native Client loader, but are not defined in the trusted
+// plugin loader (and must be filled in in NP_Initialize()).
+// Called when the first instance of this plugin is first allocated to
+// initialize global state. The browser is hereby telling the plugin its
+// interface in |browser_functions| and expects the plugin to populate
+// |plugin_functions| in return. Memory allocated by this function may only
+// be cleaned up by NP_Shutdown.
+// returns an NPError if anything went wrong.
+// Declaration: npupp.h
+// Documentation URL: https://developer.mozilla.org/en/NP_Initialize
+NPError NP_Initialize(NPNetscapeFuncs* browser_functions,
+ NPPluginFuncs* plugin_functions) {
+ printf("Duality: NP_Initialize was called!\n");
+ fflush(stdout);
+ return NP_GetEntryPoints(plugin_functions);
+}
+
+
+// Called just before the plugin itself is completely unloaded from the
+// browser. Should clean up anything allocated by NP_Initialize.
+// Declaration: npupp.h
+// Documentation URL: https://developer.mozilla.org/en/NP_Shutdown
+NPError NP_Shutdown() {
+ printf("Duality: NP_Shutdown was called!\n");
+ fflush(stdout);
+ return NPERR_NO_ERROR;
+}
+} // extern "C"
« no previous file with comments | « examples/srpc/duality/duality.html ('k') | examples/srpc/duality/nacl_build.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698