| Index: ppapi/cpp/vpn_provider.h
|
| diff --git a/ppapi/cpp/vpn_provider.h b/ppapi/cpp/vpn_provider.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6e9c94130148348db874a921ce0b9944f9c0d30c
|
| --- /dev/null
|
| +++ b/ppapi/cpp/vpn_provider.h
|
| @@ -0,0 +1,94 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef PPAPI_CPP_VPN_PROVIDER_H_
|
| +#define PPAPI_CPP_VPN_PROVIDER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "ppapi/c/ppb_vpn_provider.h"
|
| +#include "ppapi/cpp/completion_callback.h"
|
| +
|
| +namespace pp {
|
| +
|
| +class InstanceHandle;
|
| +
|
| +/// @file
|
| +/// This file defines the VpnProvider interface providing a way to implement a
|
| +/// VPN client.
|
| +/// Important: This API is available only on Chrome OS.
|
| +
|
| +/// The <code>VpnProvider</code> class providing a way to implement a VPN
|
| +/// client.
|
| +class VpnProvider : public Resource {
|
| + public:
|
| + /// Constructs a VpnProvider object.
|
| + ///
|
| + /// @param[in] instance The instance with which this resource will be
|
| + /// associated.
|
| + explicit VpnProvider(Instance* instance);
|
| +
|
| + /// Destructs a WebSocket object.
|
| + virtual ~VpnProvider();
|
| +
|
| + /// Static function for determining whether the browser supports the
|
| + /// <code>VpnProvider</code> interface.
|
| + ///
|
| + /// @return true if the interface is available, false otherwise.
|
| + static bool IsAvailable();
|
| +
|
| + /// Binds to an existing connection created by
|
| + /// <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
|
| + /// via <code>SendPacket</code> and <code>GetPacket</code> in the Native
|
| + /// Client API.
|
| + ///
|
| + /// @param[in] name The connection name as defined by the user when calling
|
| + /// <code>chrome.vpnProvider.createConfig</code>.
|
| + ///
|
| + /// @param[in] id The connection id from the callback of
|
| + /// <code>chrome.vpnProvider.createConfig</code>.
|
| + ///
|
| + /// @param[in] callback A <code>CompletionCallback</code> to be
|
| + /// called upon completion of Bind.
|
| + int32_t Bind(const std::string& name,
|
| + const std::string& id,
|
| + const CompletionCallback& callback);
|
| +
|
| + /// GetUnBindEvent() registers a callback that will be called when the current
|
| + /// connection gets unbound.
|
| + ///
|
| + /// @param[in] callback A <code>PP_CompletionCallback</code> called when
|
| + /// the current connection gets unbound.
|
| + int32_t GetUnBindEvent(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.
|
| + ///
|
| + /// @param[in] data IP packet to be sent to the platform. The <code>Var</code>
|
| + /// will be of ArrayBuffer type.
|
| + int32_t SendPacket(const Var& packet, const CompletionCallback& callback);
|
| +
|
| + /// Receives an IP packet from the tunnel for the VPN session.
|
| + /// This interface only returns a single packet. That is, this interface must
|
| + /// be called at least N times to receive N packets, no matter the size of
|
| + /// each packet.
|
| + ///
|
| + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
|
| + /// called upon completion of GetPacket. It will be passed an ArrayBuffer type
|
| + /// <code>Var</code> containing an IP packet to be sent to the platform.
|
| + ///
|
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
|
| + /// If an error is detected or connection is closed, GetPacket() returns
|
| + /// <code>PP_ERROR_FAILED</code> after all buffered messages are received.
|
| + /// Until buffered packets become empty, GetPacket() continues to return
|
| + /// <code>PP_OK</code> as if connection is still established without errors.
|
| + int32_t GetPacket(const CompletionCallbackWithOutput<Var>& callback);
|
| +
|
| + private:
|
| + InstanceHandle associated_instance_;
|
| +};
|
| +
|
| +} // namespace pp
|
| +
|
| +#endif // PPAPI_CPP_VPN_PROVIDER_H_
|
|
|