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..83bc556b5b934b48cb5230f113a1f1cca2a0a812 |
--- /dev/null |
+++ b/ppapi/cpp/vpn_provider.h |
@@ -0,0 +1,93 @@ |
+// 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); |
bbudge
2016/04/26 18:25:21
Use InstanceHandle here.
adrian.belgun
2016/04/27 14:55:21
Done.
|
+ |
+ /// 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 configuration created by |
+ /// <code>chrome.vpnProvider.createConfig</code>. All packets will be routed |
+ /// via <code>SendPacket</code> and <code>ReceivePacket</code>. |
+ /// |
+ /// @param[in] configuration_id The configuration id from the callback of |
+ /// <code>chrome.vpnProvider.createConfig</code>. |
+ /// |
+ /// @param[in] configuration_name The configuration name as defined by the |
+ /// user when calling <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& configuration_id, |
+ const std::string& configuration_name, |
bbudge
2016/04/26 18:25:21
Why not use pp::Var's here? Won't these come from
adrian.belgun
2016/04/27 14:55:21
Done.
|
+ const CompletionCallback& callback); |
+ |
+ /// GetUnBindEvent() registers a callback that will be called when the current |
+ /// configuration gets unbound. |
+ /// |
+ /// @param[in] callback A <code>PP_CompletionCallback</code> called when |
+ /// the current configuration gets unbound. |
+ int32_t GetUnBindEvent(const CompletionCallback& callback); |
bbudge
2016/04/26 18:25:21
s/UnBind/Unbind
Here and in comment
adrian.belgun
2016/04/27 14:55:20
Done.
|
+ |
+ /// 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 ReceivePacket. 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, ReceivePacket() returns |
+ /// <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
+ /// Until buffered packets become empty, ReceivePacket() continues to return |
+ /// <code>PP_OK</code> as if connection is still established without errors. |
+ int32_t ReceivePacket(const CompletionCallbackWithOutput<Var>& callback); |
+ |
+ private: |
+ InstanceHandle associated_instance_; |
+}; |
+ |
+} // namespace pp |
+ |
+#endif // PPAPI_CPP_VPN_PROVIDER_H_ |