{{+bindTo:partials.standard_nacl_api}}
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 bool | IsAvailable () |
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:
VpnProvider
instance.VpnProvider.ReceivePacket()
.chrome.vpnProvider
API until the step for notifying the connection state as "connected".VpnProvider.Bind()
.chrome.vpnProvider.notifyConnectionStateChanged
.VpnProvider.SendPacket()
and any packets originating on the Chrome OS device will be received using the callback registered for VpnProvider.ReceivePacket()
.chrome.vpnProvider.onPlatformMessage
. pp::VpnProvider::VpnProvider | ( | const InstanceHandle & | instance | ) | [explicit] |
Constructs a VpnProvider object.
[in] | instance | The instance with which this resource will be associated. |
virtual pp::VpnProvider::~VpnProvider | ( | ) | [virtual] |
Destructs a VpnProvider object.
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()
.
[in] | configuration_id | The configuration id from the callback of chrome.vpnProvider.createConfig . This Var must be of string type. |
[in] | configuration_name | The configuration name as defined by the user when calling chrome.vpnProvider.createConfig . This Var must be of string type. |
[in] | callback | A CompletionCallback to be called on completion. |
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.
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()
.
[in] | callback | A 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. |
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.
[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. |
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.