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

Side by Side 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: Remove GetUnbindEvent Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ppapi/c/ppb_vpn_provider.h ('k') | ppapi/cpp/vpn_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_CPP_VPN_PROVIDER_H_
6 #define PPAPI_CPP_VPN_PROVIDER_H_
7
8 #include <string>
9
10 #include "ppapi/c/ppb_vpn_provider.h"
11 #include "ppapi/cpp/completion_callback.h"
12
13 namespace pp {
14
15 class InstanceHandle;
16
17 /// @file
18 /// This file defines the VpnProvider interface providing a way to implement a
19 /// VPN client.
20 /// Important: This API is available only on Chrome OS.
21
22 /// The <code>VpnProvider</code> class enhances the
23 /// <code>chrome.vpnProvider</code> JavaScript API by providing a high
24 /// performance path for packet handling.
25 ///
26 /// Permissions: Apps permission <code>vpnProvider</code> is required for
27 /// <code>VpnProvider.Bind()</code>.
28 ///
29 /// Typical usage:
30 /// - Create a <code>VpnProvider</code> instance.
31 /// - Register the callback for <code>VpnProvider.ReceivePacket()</code>.
32 /// - In the extension follow the usual workflow for configuring a VPN
33 /// connection via the <code>chrome.vpnProvider</code> API until the step for
34 /// notifying the connection state as "connected".
35 /// - Bind to the previously created connection using
36 /// <code>VpnProvider.Bind()</code>.
37 /// - Notify the connection state as "connected" from JavaScript using
38 /// <code>chrome.vpnProvider.notifyConnectionStateChanged</code>.
39 /// - When the steps above are completed without errors, a virtual tunnel is
40 /// created to the network stack of Chrome OS. IP packets can be sent through
41 /// the tunnel using <code>VpnProvider.SendPacket()</code> and any packets
42 /// originating on the Chrome OS device will be received using the callback
43 /// registered for <code>VpnProvider.ReceivePacket()</code>.
44 /// - When the user disconnects from the VPN configuration or there is an error
45 /// the extension will be notfied via
46 /// <code>chrome.vpnProvider.onPlatformMessage</code>.
47 class VpnProvider : public Resource {
48 public:
49 /// Constructs a VpnProvider object.
50 ///
51 /// @param[in] instance The instance with which this resource will be
52 /// associated.
53 explicit VpnProvider(const InstanceHandle& instance);
54
55 /// Destructs a VpnProvider object.
56 virtual ~VpnProvider();
57
58 /// Static function for determining whether the browser supports the
59 /// <code>VpnProvider</code> interface.
60 ///
61 /// @return true if the interface is available, false otherwise.
62 static bool IsAvailable();
63
64 /// Binds to an existing configuration created from JavaScript by
65 /// <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
66 /// via <code>SendPacket</code> and <code>ReceivePacket</code>. The user
67 /// should register the callback for <code>ReceivePacket</code> before calling
68 /// <code>Bind()</code>.
69 ///
70 /// @param[in] configuration_id The configuration id from the callback of
71 /// <code>chrome.vpnProvider.createConfig</code>. This <code>Var</code> must
72 /// be of string type.
73 ///
74 /// @param[in] configuration_name The configuration name as defined by the
75 /// user when calling <code>chrome.vpnProvider.createConfig</code>. This
76 /// <code>Var</code> must be of string type.
77 ///
78 /// @param[in] callback A <code>CompletionCallback</code> to be called on
79 /// completion.
80 ///
81 /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
82 /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
83 /// <code>Bind()</code> has not completed.
84 /// Returns <code>PP_ERROR_BADARGUMENT</code> if the <code>Var</code> type of
85 /// either <code>configuration_id</code> or <code>configuration_name</code> is
86 /// not of string type.
87 /// Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the
88 /// required "vpnProvider" permission.
89 /// Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and
90 /// <code>connection_name</code> could not be matched with the existing
91 /// connection, or if the plugin originates from a different extension than
92 /// the one that created the connection.
93 int32_t Bind(const Var& configuration_id,
94 const Var& configuration_name,
95 const CompletionCallback& callback);
96
97 /// Sends an IP packet through the tunnel created for the VPN session. This
98 /// will succeed only when the VPN session is owned by the module and
99 /// connection is bound.
100 ///
101 /// @param[in] packet IP packet to be sent to the platform. The
102 /// <code>Var</code> must be of ArrayBuffer type.
103 ///
104 /// @param[in] callback A <code>CompletionCallback</code> to be called on
105 /// completion.
106 ///
107 /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
108 /// Returns <code>PP_ERROR_FAILED</code> if the connection is not bound.
109 /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
110 /// <code>SendPacket()</code> has not completed.
111 /// Returns <code>PP_ERROR_BADARGUMENT</code> if the <code>Var</code> type of
112 /// <code>packet</code> is not of ArrayBuffer type.
113 int32_t SendPacket(const Var& packet, const CompletionCallback& callback);
114
115 /// Receives an IP packet from the tunnel for the VPN session. This function
116 /// only returns a single packet. That is, this function must be called at
117 /// least N times to receive N packets, no matter the size of each packet. The
118 /// callback should be registered before calling <code>Bind()</code>.
119 ///
120 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
121 /// called upon completion of ReceivePacket. It will be passed an ArrayBuffer
122 /// type <code>Var</code> containing an IP packet to be sent to the platform.
123 ///
124 /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
125 /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
126 /// <code>ReceivePacket()</code> has not completed.
127 int32_t ReceivePacket(const CompletionCallbackWithOutput<Var>& callback);
128
129 private:
130 InstanceHandle associated_instance_;
131 };
132
133 } // namespace pp
134
135 #endif // PPAPI_CPP_VPN_PROVIDER_H_
OLDNEW
« no previous file with comments | « ppapi/c/ppb_vpn_provider.h ('k') | ppapi/cpp/vpn_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698