Public Member Functions
VpnProvider (const InstanceHandle &instance) | |
virtual | ~VpnProvider () |
int32_t | Bind (const Var &configuration_id, const Var &configuration_name, const CompletionCallback &callback) |
int32_t | SendPacket (const Var &packet, const CompletionCallback &callback) |
int32_t | ReceivePacket (const CompletionCallbackWithOutput< Var > &callback) |
Static Public Member Functions
static bool | IsAvailable () |
Detailed Description
The VpnProvider
class enhances the chrome.vpnProvider
JavaScript API by providing a high performance path for packet handling.
Permissions: Apps permission vpnProvider
is required for VpnProvider.Bind()
.
Typical usage:
- Create a
VpnProvider
instance. - Register the callback for
VpnProvider.ReceivePacket()
. - In the extension follow the usual workflow for configuring a VPN connection via the
chrome.vpnProvider
API until the step for notifying the connection state as "connected". - Bind to the previously created connection using
VpnProvider.Bind()
. - Notify the connection state as "connected" from JavaScript using
chrome.vpnProvider.notifyConnectionStateChanged
. - When the steps above are completed without errors, a virtual tunnel is created to the network stack of ChromeOS. IP packets can be sent through the tunnel using
VpnProvider.SendPacket()
and any packets originating on the ChromeOS device will be received using the callback registered forVpnProvider.ReceivePacket()
. - When the user disconnects from the VPN configuration or there is an error the extension will be notfied via
chrome.vpnProvider.onPlatformMessage
.
Constructor & Destructor Documentation
pp::VpnProvider::VpnProvider | ( | const InstanceHandle & | instance | ) | [explicit] |
Constructs a VpnProvider object.
- Parameters:
[in] instance The instance with which this resource will be associated.
virtual pp::VpnProvider::~VpnProvider | ( | ) | [virtual] |
Destructs a VpnProvider object.
Member Function Documentation
int32_t pp::VpnProvider::Bind | ( | const Var & | configuration_id, |
const Var & | configuration_name, | ||
const CompletionCallback & | callback | ||
) |
Binds to an existing configuration created from JavaScript by chrome.vpnProvider.createConfig
.
All packets will be routed via SendPacket
and ReceivePacket
. The user should register the callback for ReceivePacket
before calling Bind()
.
- Parameters:
[in] configuration_id The configuration id from the callback of chrome.vpnProvider.createConfig
. ThisVar
must be of string type.[in] configuration_name The configuration name as defined by the user when calling chrome.vpnProvider.createConfig
. ThisVar
must be of string type.[in] callback A CompletionCallback
to be called on completion.
- Returns:
- An int32_t containing an error code from
pp_errors.h
. ReturnsPP_ERROR_INPROGRESS
if a previous call toBind()
has not completed. ReturnsPP_ERROR_BADARGUMENT
if theVar
type of eitherconfiguration_id
orconfiguration_name
is not of string type. ReturnsPP_ERROR_NOACCESS
if the caller does the have the required "vpnProvider" permission. ReturnsPP_ERROR_FAILED
ifconnection_id
andconnection_name
could not be matched with the existing connection, or if the plugin originates from a different extension than the one that created the connection.
static bool pp::VpnProvider::IsAvailable | ( | ) | [static] |
Static function for determining whether the browser supports the VpnProvider
interface.
- Returns:
- true if the interface is available, false otherwise.
int32_t pp::VpnProvider::ReceivePacket | ( | const CompletionCallbackWithOutput< Var > & | callback | ) |
Receives an IP packet from the tunnel for the VPN session.
This function only returns a single packet. That is, this function must be called at least N times to receive N packets, no matter the size of each packet. The callback should be registered before calling Bind()
.
- Parameters:
[in] callback A CompletionCallbackWithOutput
to be called upon completion of ReceivePacket. It will be passed an ArrayBuffer typeVar
containing an IP packet to be sent to the platform.
- Returns:
- An int32_t containing an error code from
pp_errors.h
. ReturnsPP_ERROR_INPROGRESS
if a previous call toReceivePacket()
has not completed.
int32_t pp::VpnProvider::SendPacket | ( | const Var & | packet, |
const CompletionCallback & | callback | ||
) |
Sends an IP packet through the tunnel created for the VPN session.
This will succeed only when the VPN session is owned by the module and connection is bound.
- Parameters:
[in] packet IP packet to be sent to the platform. The Var
must be of ArrayBuffer type.[in] callback A CompletionCallback
to be called on completion.
- Returns:
- An int32_t containing an error code from
pp_errors.h
. ReturnsPP_ERROR_FAILED
if the connection is not bound. ReturnsPP_ERROR_INPROGRESS
if a previous call toSendPacket()
has not completed. ReturnsPP_ERROR_BADARGUMENT
if theVar
type ofpacket
is not of ArrayBuffer type.
The documentation for this class was generated from the following file: