2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // NaCl-NPAPI Interface
35 #ifndef NATIVE_CLIENT_TOOLS_NPAPI_RUNTIME_NPRPC_H_
36 #define NATIVE_CLIENT_TOOLS_NPAPI_RUNTIME_NPRPC_H_
38 #include "native_client/tools/npapi_runtime/nacl_npapi.h"
39 #include "native_client/tools/npapi_runtime/npcapability.h"
43 // The RPC message types.
45 RPC_GET_WINDOW_OBJECT
, // NPN_GetValue() - NPNVWindowNPObject
46 RPC_GET_PLUGIN_ELEMENT_OBJECT
, // NPN_GetValue() - NPNVPluginElementNPObject
47 RPC_SET_EXCEPTION
, // NPNSetException()
48 RPC_SET_STATUS
, // NPN_Status()
50 RPC_DESTROY
, // NPP_Destroy()
51 RPC_CREATE_ARRAY
, // NaClNPN_CreateArray()
52 RPC_OPEN_URL
, // NaClNPN_OpenURL()
53 RPC_NOTIFY_URL
, // URLNotify()
54 RPC_DEALLOCATE
, // Deallocate
55 RPC_INVALIDATE
, // Invalidate
56 RPC_HAS_METHOD
, // HasMethod
58 RPC_INVOKE_DEFAULT
, // InvokeDefault
59 RPC_HAS_PROPERTY
, // HasProperty
60 RPC_GET_PROPERTY
, // GetProperty
61 RPC_SET_PROPERTY
, // SetProperty
62 RPC_REMOVE_PROPERTY
, // RemoveProperty
63 RPC_ENUMERATION
, // Enumeration
64 RPC_CONSTRUCT
, // Construct
65 RPC_INVALIDATE_RECT
, // NPN_InvalidateRect(NPRect*)
66 RPC_FORCE_REDRAW
, // NPN_ForceRedraw()
69 // The RPC message header.
71 RpcType type
; // The RPC message type.
72 int tag
; // The tag to distinguish each message.
73 int pid
; // The process ID that sends the request message.
74 int error_code
; // The error code of this message.
76 // Compares an RPC request with an RPC response and returns true if they
77 // match, and vice versa.
78 bool Equals(const RpcHeader
& header
) const {
79 return type
== header
.type
&& tag
== header
.tag
&& pid
== header
.pid
;
83 // The maximum number of NPVariant parameters passed by RPC_INVOKE or
84 // RPC_INVOKE_DEFAULT.
85 const size_t kParamMax
= 256;
87 // The maximum size of the NPVariant structure in bytes among various platforms.
88 const size_t kNPVariantSizeMax
= 16;
90 // Converts an array of NPVariant into another array of NPVariant that packed
91 // differently to support different ABIs between the NaCl module and the
92 // browser plugin. The target NPVariant size is given by peer_npvariant_size.
94 // Currently ConvertNPVariants() supports only 16 byte NPVariant (Win32) to
95 // 12 byte NPVariant (Linux and OS X) conversion and vice versa.
96 void* ConvertNPVariants(const NPVariant
* variant
, void* target
,
97 size_t peer_npvariant_size
,
102 #endif // NATIVE_CLIENT_TOOLS_NPAPI_RUNTIME_NPRPC_H_