Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: ppapi/cpp/vpn_provider.h

Issue 1726303003: ppapi: PPB_VpnProvider: Define API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split patch & responded to reviews Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8fbb8e93acca112bdeef43b6832a36c75b8b6575
--- /dev/null
+++ b/ppapi/cpp/vpn_provider.h
@@ -0,0 +1,93 @@
+// Copyright 2016 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(const InstanceHandle& 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 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 Var& configuration_id,
+ const Var& configuration_name,
+ 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);
+
+ /// 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 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.
+ ///
+ /// @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_

Powered by Google App Engine
This is Rietveld 408576698