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

Side by Side Diff: ppapi/c/ppb_vpn_provider.h

Issue 1726303003: ppapi: PPB_VpnProvider: Define API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added documentation regarding permissions Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright 2016 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 /* From ppb_vpn_provider.idl modified Thu May 5 17:35:20 2016. */
7
8 #ifndef PPAPI_C_PPB_VPN_PROVIDER_H_
9 #define PPAPI_C_PPB_VPN_PROVIDER_H_
10
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_var.h"
18
19 #define PPB_VPNPROVIDER_INTERFACE_0_1 "PPB_VpnProvider;0.1" /* dev */
20 /**
21 * @file
22 * This file defines the <code>PPB_VpnProvider</code> interface.
23 */
24
25
26 /**
27 * @addtogroup Interfaces
28 * @{
29 */
30 /**
31 * Use the <code>PPB_VpnProvider</code> interface to implement a VPN client.
32 * Important: This API is available only on Chrome OS.
33 *
34 * This interface enhances the <code>chrome.vpnProvider</code> JavaScript API by
35 * providing a high performance path for packet handling.
36 *
37 * Permissions: Apps permission <code>vpnProvider</code> is required for
38 * <code>PPB_VpnProvider.Bind()</code>.
39 *
40 * Typical usage:
41 * - Create a <code>PPB_VpnProvider</code> instance.
42 * - Register callbacks via <code>PPB_VpnProvider.GetUnbindEvent()</code> and
43 * <code>PPB_VpnProvider.ReceivePacket()</code>.
44 * - In the extension follow the usual workflow for configuring a VPN connection
45 * via the <code>chrome.vpnProvider</code> API until the step for notifying
46 * the connection state as "connected".
47 * - Bind to the previously created connection using
48 * <code>PPB_VpnProvider.Bind()</code>.
49 * - Notify the connection state as "connected" from JavaScript using
50 * <code>chrome.vpnProvider.notifyConnectionStateChanged</code>.
51 * - When the steps above are completed without errors, a virtual tunnel is
52 * created to the network stack of Chrome OS. IP packets can be sent through
53 * the tunnel using <code>PPB_VpnProvider.SendPacket()</code> and any packets
54 * originating on the Chrome OS device will be received using the callback
55 * registered for <code>PPB_VpnProvider.ReceivePacket()</code>.
56 * - When the user disconnects from the VPN configuration or there is an error
57 * the callback registered using <code>PPB_VpnProvider.GetUnbindEvent()</code>
58 * will be called.
59 */
60 struct PPB_VpnProvider_0_1 { /* dev */
61 /**
62 * Create() creates a VpnProvider instance.
63 *
64 * @param[in] instance A <code>PP_Instance</code> identifying the instance
65 * with the VpnProvider.
66 *
67 * @return A <code>PP_Resource</code> corresponding to a VpnProvider if
68 * successful.
69 */
70 PP_Resource (*Create)(PP_Instance instance);
71 /**
72 * IsVpnProvider() determines if the provided <code>resource</code> is a
73 * VpnProvider instance.
74 *
75 * @param[in] resource A <code>PP_Resource</code> corresponding to a
76 * VpnProvider.
77 *
78 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a
79 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the
80 * <code>resource</code> is invalid or some type other than
81 * <code>PPB_VpnProvider</code>.
82 */
83 PP_Bool (*IsVpnProvider)(PP_Resource resource);
84 /**
85 * Bind() binds to an existing configuration created from JavaScript by
86 * <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
87 * via <code>SendPacket</code> and <code>ReceivePacket</code>. The user should
88 * register callbacks via <code>GetUnbindEvent</code> and
89 * <code>ReceivePacket</code> before calling <code>Bind()</code>.
90 *
91 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
92 * VpnProvider.
93 *
94 * @param[in] configuration_id A <code>PP_VARTYPE_STRING</code> representing
95 * the configuration id from the callback of
96 * <code>chrome.vpnProvider.createConfig</code>.
97 *
98 * @param[in] configuration_name A <code>PP_VARTYPE_STRING</code> representing
99 * the configuration name as defined by the user when calling
100 * <code>chrome.vpnProvider.createConfig</code>.
101 *
102 * @param[in] callback A <code>PP_CompletionCallback</code> called on
103 * completion.
104 *
105 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
106 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
107 * <code>Bind()</code> has not completed.
108 * Returns <code>PP_ERROR_BADARGUMENT</code> if either
109 * <code>configuration_id</code> or <code>configuration_name</code> are not of
110 * type <code>PP_VARTYPE_STRING</code>.
111 * Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the
112 * required "vpnProvider" permission.
113 * Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and
114 * <code>connection_name</code> could not be matched with the existing
115 * connection, or if the plugin originates from a different extension than the
116 * one that created the connection.
117 */
118 int32_t (*Bind)(PP_Resource vpn_provider,
119 struct PP_Var configuration_id,
120 struct PP_Var configuration_name,
121 struct PP_CompletionCallback callback);
122 /**
123 * GetUnbindEvent() registers a callback that will be called when the current
124 * configuration gets unbound. The callback should be registered before
125 * calling <code>Bind()</code>.
126 *
127 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
128 * VpnProvider.
129 *
130 * @param[in] callback A <code>PP_CompletionCallback</code> called when
131 * the current configuration gets unbound.
132 *
133 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
134 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
135 * <code>GetUnbindEvent()</code> has not completed.
136 */
137 int32_t (*GetUnbindEvent)(PP_Resource vpn_provider,
138 struct PP_CompletionCallback callback);
139 /**
140 * SendPacket() sends an IP packet through the tunnel created for the VPN
141 * session. This will succeed only when the VPN session is owned by the
142 * module and the connection is bound.
143 *
144 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
145 * VpnProvider.
146 *
147 * @param[in] packet A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to
148 * an IP packet to be sent to the platform.
149 *
150 * @param[in] callback A <code>PP_CompletionCallback</code> called on
151 * completion.
152 *
153 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
154 * Returns <code>PP_ERROR_FAILED</code> if the connection is not bound.
155 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
156 * <code>SendPacket()</code> has not completed.
157 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>packet</code> is not of
158 * type <code>PP_VARTYPE_ARRAY_BUFFER</code>.
159 */
160 int32_t (*SendPacket)(PP_Resource vpn_provider,
161 struct PP_Var packet,
162 struct PP_CompletionCallback callback);
163 /**
164 * ReceivePacket() receives an IP packet from the tunnel for the VPN session.
165 * This function only returns a single packet. This function must be called at
166 * least N times to receive N packets, no matter the size of each packet. The
167 * callback should be registered before calling <code>Bind()</code>.
168 *
169 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
170 * VpnProvider.
171 *
172 * @param[out] packet The received packet is copied to provided
173 * <code>packet</code>. The <code>packet</code> must remain valid until
174 * ReceivePacket() completes. Its received <code>PP_VarType</code> will be
175 * <code>PP_VARTYPE_ARRAY_BUFFER</code>.
176 *
177 * @param[in] callback A <code>PP_CompletionCallback</code> called on
178 * completion.
179 *
180 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
181 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
182 * <code>ReceivePacket()</code> has not completed.
183 */
184 int32_t (*ReceivePacket)(PP_Resource vpn_provider,
185 struct PP_Var* packet,
186 struct PP_CompletionCallback callback);
187 };
188 /**
189 * @}
190 */
191
192 #endif /* PPAPI_C_PPB_VPN_PROVIDER_H_ */
193
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698