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

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: Remove GetUnbindEvent 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
« no previous file with comments | « ppapi/api/ppb_vpn_provider.idl ('k') | ppapi/cpp/vpn_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Fri May 6 20:42:01 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 the callback for <code>PPB_VpnProvider.ReceivePacket()</code>.
43 * - In the extension follow the usual workflow for configuring a VPN connection
44 * via the <code>chrome.vpnProvider</code> API until the step for notifying
45 * the connection state as "connected".
46 * - Bind to the previously created connection using
47 * <code>PPB_VpnProvider.Bind()</code>.
48 * - Notify the connection state as "connected" from JavaScript using
49 * <code>chrome.vpnProvider.notifyConnectionStateChanged</code>.
50 * - When the steps above are completed without errors, a virtual tunnel is
51 * created to the network stack of Chrome OS. IP packets can be sent through
52 * the tunnel using <code>PPB_VpnProvider.SendPacket()</code> and any packets
53 * originating on the Chrome OS device will be received using the callback
54 * registered for <code>PPB_VpnProvider.ReceivePacket()</code>.
55 * - When the user disconnects from the VPN configuration or there is an error
56 * the extension will be notfied via
57 * <code>chrome.vpnProvider.onPlatformMessage</code>.
58 */
59 struct PPB_VpnProvider_0_1 { /* dev */
60 /**
61 * Create() creates a VpnProvider instance.
62 *
63 * @param[in] instance A <code>PP_Instance</code> identifying the instance
64 * with the VpnProvider.
65 *
66 * @return A <code>PP_Resource</code> corresponding to a VpnProvider if
67 * successful.
68 */
69 PP_Resource (*Create)(PP_Instance instance);
70 /**
71 * IsVpnProvider() determines if the provided <code>resource</code> is a
72 * VpnProvider instance.
73 *
74 * @param[in] resource A <code>PP_Resource</code> corresponding to a
75 * VpnProvider.
76 *
77 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a
78 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the
79 * <code>resource</code> is invalid or some type other than
80 * <code>PPB_VpnProvider</code>.
81 */
82 PP_Bool (*IsVpnProvider)(PP_Resource resource);
83 /**
84 * Bind() binds to an existing configuration created from JavaScript by
85 * <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
86 * via <code>SendPacket</code> and <code>ReceivePacket</code>. The user should
87 * register the callback for <code>ReceivePacket</code> before calling
88 * <code>Bind()</code>.
89 *
90 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
91 * VpnProvider.
92 *
93 * @param[in] configuration_id A <code>PP_VARTYPE_STRING</code> representing
94 * the configuration id from the callback of
95 * <code>chrome.vpnProvider.createConfig</code>.
96 *
97 * @param[in] configuration_name A <code>PP_VARTYPE_STRING</code> representing
98 * the configuration name as defined by the user when calling
99 * <code>chrome.vpnProvider.createConfig</code>.
100 *
101 * @param[in] callback A <code>PP_CompletionCallback</code> called on
102 * completion.
103 *
104 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
105 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
106 * <code>Bind()</code> has not completed.
107 * Returns <code>PP_ERROR_BADARGUMENT</code> if either
108 * <code>configuration_id</code> or <code>configuration_name</code> are not of
109 * type <code>PP_VARTYPE_STRING</code>.
110 * Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the
111 * required "vpnProvider" permission.
112 * Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and
113 * <code>connection_name</code> could not be matched with the existing
114 * connection, or if the plugin originates from a different extension than the
115 * one that created the connection.
116 */
117 int32_t (*Bind)(PP_Resource vpn_provider,
118 struct PP_Var configuration_id,
119 struct PP_Var configuration_name,
120 struct PP_CompletionCallback callback);
121 /**
122 * SendPacket() sends an IP packet through the tunnel created for the VPN
123 * session. This will succeed only when the VPN session is owned by the
124 * module and the connection is bound.
125 *
126 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
127 * VpnProvider.
128 *
129 * @param[in] packet A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to
130 * an IP packet to be sent to the platform.
131 *
132 * @param[in] callback A <code>PP_CompletionCallback</code> called on
133 * completion.
134 *
135 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
136 * Returns <code>PP_ERROR_FAILED</code> if the connection is not bound.
137 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
138 * <code>SendPacket()</code> has not completed.
139 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>packet</code> is not of
140 * type <code>PP_VARTYPE_ARRAY_BUFFER</code>.
141 */
142 int32_t (*SendPacket)(PP_Resource vpn_provider,
143 struct PP_Var packet,
144 struct PP_CompletionCallback callback);
145 /**
146 * ReceivePacket() receives an IP packet from the tunnel for the VPN session.
147 * This function only returns a single packet. This function must be called at
148 * least N times to receive N packets, no matter the size of each packet. The
149 * callback should be registered before calling <code>Bind()</code>.
150 *
151 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a
152 * VpnProvider.
153 *
154 * @param[out] packet The received packet is copied to provided
155 * <code>packet</code>. The <code>packet</code> must remain valid until
156 * ReceivePacket() completes. Its received <code>PP_VarType</code> will be
157 * <code>PP_VARTYPE_ARRAY_BUFFER</code>.
158 *
159 * @param[in] callback A <code>PP_CompletionCallback</code> called on
160 * completion.
161 *
162 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
163 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
164 * <code>ReceivePacket()</code> has not completed.
165 */
166 int32_t (*ReceivePacket)(PP_Resource vpn_provider,
167 struct PP_Var* packet,
168 struct PP_CompletionCallback callback);
169 };
170 /**
171 * @}
172 */
173
174 #endif /* PPAPI_C_PPB_VPN_PROVIDER_H_ */
175
OLDNEW
« no previous file with comments | « ppapi/api/ppb_vpn_provider.idl ('k') | ppapi/cpp/vpn_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698