pp::VpnProvider Class Reference

Inheritance diagram for pp::VpnProvider:

List of all members.

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 Chrome OS. IP packets can be sent through the tunnel using VpnProvider.SendPacket() and any packets originating on the Chrome OS device will be received using the callback registered for VpnProvider.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]instanceThe 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_idThe configuration id from the callback of chrome.vpnProvider.createConfig. This Var must be of string type.
[in]configuration_nameThe configuration name as defined by the user when calling chrome.vpnProvider.createConfig. This Var must be of string type.
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_INPROGRESS if a previous call to Bind() has not completed. Returns PP_ERROR_BADARGUMENT if the Var type of either configuration_id or configuration_name is not of string type. Returns PP_ERROR_NOACCESS if the caller does the have the required "vpnProvider" permission. Returns PP_ERROR_FAILED if connection_id and connection_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.

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]callbackA CompletionCallbackWithOutput to be called upon completion of ReceivePacket. It will be passed an ArrayBuffer type Var containing an IP packet to be sent to the platform.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_INPROGRESS if a previous call to ReceivePacket() 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]packetIP packet to be sent to the platform. The Var must be of ArrayBuffer type.
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_FAILED if the connection is not bound. Returns PP_ERROR_INPROGRESS if a previous call to SendPacket() has not completed. Returns PP_ERROR_BADARGUMENT if the Var type of packet is not of ArrayBuffer type.

The documentation for this class was generated from the following file: