Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 /** | |
| 7 * This file defines the <code>PPB_VpnProvider</code> interface. | |
| 8 */ | |
| 9 | |
| 10 [generate_thunk] | |
| 11 | |
| 12 label Chrome { | |
| 13 [channel=dev] M52 = 0.1 | |
| 14 }; | |
| 15 | |
| 16 /** | |
| 17 * Use the <code>PPB_VpnProvider</code> interface to implement a VPN client. | |
| 18 * Important: This API is available only on Chrome OS. | |
| 19 * | |
| 20 * This interface enhances the <code>chrome.vpnProvider</code> JavaScript API by | |
| 21 * providing a high performance path for packet handling. | |
| 22 * | |
| 23 * Permissions: Apps permission <code>vpnProvider</code> is required for | |
| 24 * <code>PPB_VpnProvider.Bind()</code>. | |
| 25 * | |
| 26 * Typical usage: | |
| 27 * - Create a <code>PPB_VpnProvider</code> instance. | |
| 28 * - Register callbacks via <code>PPB_VpnProvider.GetUnbindEvent()</code> and | |
| 29 * <code>PPB_VpnProvider.ReceivePacket()</code>. | |
| 30 * - In the extension follow the usual workflow for configuring a VPN connection | |
| 31 * via the <code>chrome.vpnProvider</code> API until the step for notifying | |
| 32 * the connection state as "connected". | |
| 33 * - Bind to the previously created connection using | |
| 34 * <code>PPB_VpnProvider.Bind()</code>. | |
| 35 * - Notify the connection state as "connected" from JavaScript using | |
| 36 * <code>chrome.vpnProvider.notifyConnectionStateChanged</code>. | |
| 37 * - When the steps above are completed without errors, a virtual tunnel is | |
| 38 * created to the network stack of Chrome OS. IP packets can be sent through | |
| 39 * the tunnel using <code>PPB_VpnProvider.SendPacket()</code> and any packets | |
| 40 * originating on the Chrome OS device will be received using the callback | |
| 41 * registered for <code>PPB_VpnProvider.ReceivePacket()</code>. | |
| 42 * - When the user disconnects from the VPN configuration or there is an error | |
| 43 * the callback registered using <code>PPB_VpnProvider.GetUnbindEvent()</code> | |
| 44 * will be called. | |
| 45 */ | |
| 46 interface PPB_VpnProvider { | |
| 47 /** | |
| 48 * Create() creates a VpnProvider instance. | |
| 49 * | |
| 50 * @param[in] instance A <code>PP_Instance</code> identifying the instance | |
| 51 * with the VpnProvider. | |
| 52 * | |
| 53 * @return A <code>PP_Resource</code> corresponding to a VpnProvider if | |
| 54 * successful. | |
| 55 */ | |
| 56 PP_Resource Create([in] PP_Instance instance); | |
| 57 | |
| 58 /** | |
| 59 * IsVpnProvider() determines if the provided <code>resource</code> is a | |
| 60 * VpnProvider instance. | |
| 61 * | |
| 62 * @param[in] resource A <code>PP_Resource</code> corresponding to a | |
| 63 * VpnProvider. | |
| 64 * | |
| 65 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a | |
| 66 * <code>PPB_VpnProvider</code>, <code>PP_FALSE</code> if the | |
| 67 * <code>resource</code> is invalid or some type other than | |
| 68 * <code>PPB_VpnProvider</code>. | |
| 69 */ | |
| 70 PP_Bool IsVpnProvider([in] PP_Resource resource); | |
| 71 | |
| 72 /** | |
| 73 * Bind() binds to an existing configuration created from JavaScript by | |
| 74 * <code>chrome.vpnProvider.createConfig</code>. All packets will be routed | |
| 75 * via <code>SendPacket</code> and <code>ReceivePacket</code>. The user should | |
| 76 * register callbacks via <code>GetUnbindEvent</code> and | |
| 77 * <code>ReceivePacket</code> before calling <code>Bind()</code>. | |
| 78 * | |
| 79 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a | |
| 80 * VpnProvider. | |
| 81 * | |
| 82 * @param[in] configuration_id A <code>PP_VARTYPE_STRING</code> representing | |
| 83 * the configuration id from the callback of | |
| 84 * <code>chrome.vpnProvider.createConfig</code>. | |
| 85 * | |
| 86 * @param[in] configuration_name A <code>PP_VARTYPE_STRING</code> representing | |
| 87 * the configuration name as defined by the user when calling | |
| 88 * <code>chrome.vpnProvider.createConfig</code>. | |
| 89 * | |
| 90 * @param[in] callback A <code>PP_CompletionCallback</code> called on | |
| 91 * completion. | |
| 92 * | |
| 93 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 94 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to | |
| 95 * <code>Bind()</code> has not completed. | |
| 96 * Returns <code>PP_ERROR_BADARGUMENT</code> if either | |
| 97 * <code>configuration_id</code> or <code>configuration_name</code> are not of | |
| 98 * type <code>PP_VARTYPE_STRING</code>. | |
| 99 * Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the | |
| 100 * required "vpnProvider" permission. | |
| 101 * Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and | |
| 102 * <code>connection_name</code> could not be matched with the existing | |
| 103 * connection, or if the plugin originates from a different extension than the | |
| 104 * one that created the connection. | |
| 105 */ | |
| 106 int32_t Bind([in] PP_Resource vpn_provider, | |
| 107 [in] PP_Var configuration_id, | |
| 108 [in] PP_Var configuration_name, | |
| 109 [in] PP_CompletionCallback callback); | |
| 110 | |
| 111 /** | |
| 112 * GetUnbindEvent() registers a callback that will be called when the current | |
| 113 * configuration gets unbound. The callback should be registered before | |
| 114 * calling <code>Bind()</code>. | |
| 115 * | |
| 116 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a | |
| 117 * VpnProvider. | |
| 118 * | |
| 119 * @param[in] callback A <code>PP_CompletionCallback</code> called when | |
| 120 * the current configuration gets unbound. | |
| 121 * | |
| 122 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 123 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to | |
| 124 * <code>GetUnbindEvent()</code> has not completed. | |
| 125 */ | |
| 126 int32_t GetUnbindEvent([in] PP_Resource vpn_provider, | |
| 127 [in] PP_CompletionCallback callback); | |
|
bbudge
2016/05/05 21:45:50
I forgot to bring this up before, but it might be
adrian.belgun
2016/05/06 02:40:01
I've thought about this use case also. The issue i
bbudge
2016/05/06 17:06:30
I think if it's possible to simplify the Pepper AP
adrian.belgun
2016/05/06 20:08:48
Done.
| |
| 128 | |
| 129 /** | |
| 130 * SendPacket() sends an IP packet through the tunnel created for the VPN | |
| 131 * session. This will succeed only when the VPN session is owned by the | |
| 132 * module and the connection is bound. | |
| 133 * | |
| 134 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a | |
| 135 * VpnProvider. | |
| 136 * | |
| 137 * @param[in] packet A <code>PP_VARTYPE_ARRAY_BUFFER</code> corresponding to | |
| 138 * an IP packet to be sent to the platform. | |
| 139 * | |
| 140 * @param[in] callback A <code>PP_CompletionCallback</code> called on | |
| 141 * completion. | |
| 142 * | |
| 143 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 144 * Returns <code>PP_ERROR_FAILED</code> if the connection is not bound. | |
| 145 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to | |
| 146 * <code>SendPacket()</code> has not completed. | |
| 147 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>packet</code> is not of | |
| 148 * type <code>PP_VARTYPE_ARRAY_BUFFER</code>. | |
| 149 */ | |
| 150 int32_t SendPacket([in] PP_Resource vpn_provider, | |
| 151 [in] PP_Var packet, | |
| 152 [in] PP_CompletionCallback callback); | |
| 153 | |
| 154 /** | |
| 155 * ReceivePacket() receives an IP packet from the tunnel for the VPN session. | |
| 156 * This function only returns a single packet. This function must be called at | |
| 157 * least N times to receive N packets, no matter the size of each packet. The | |
| 158 * callback should be registered before calling <code>Bind()</code>. | |
| 159 * | |
| 160 * @param[in] vpn_provider A <code>PP_Resource</code> corresponding to a | |
| 161 * VpnProvider. | |
| 162 * | |
| 163 * @param[out] packet The received packet is copied to provided | |
| 164 * <code>packet</code>. The <code>packet</code> must remain valid until | |
| 165 * ReceivePacket() completes. Its received <code>PP_VarType</code> will be | |
| 166 * <code>PP_VARTYPE_ARRAY_BUFFER</code>. | |
| 167 * | |
| 168 * @param[in] callback A <code>PP_CompletionCallback</code> called on | |
| 169 * completion. | |
| 170 * | |
| 171 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 172 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to | |
| 173 * <code>ReceivePacket()</code> has not completed. | |
| 174 */ | |
| 175 int32_t ReceivePacket([in] PP_Resource vpn_provider, | |
| 176 [out] PP_Var packet, | |
| 177 [in] PP_CompletionCallback callback); | |
| 178 }; | |
| OLD | NEW |