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

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: Simplify IDL Created 4 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2015 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 providing a way to implement a VPN
23 /// client.
24 class VpnProvider : public Resource {
25 public:
26 /// Constructs a VpnProvider object.
27 ///
28 /// @param[in] instance The instance with which this resource will be
29 /// associated.
30 explicit VpnProvider(Instance* instance);
31
32 /// Destructs a WebSocket object.
33 virtual ~VpnProvider();
34
35 /// Static function for determining whether the browser supports the
36 /// <code>VpnProvider</code> interface.
37 ///
38 /// @return true if the interface is available, false otherwise.
39 static bool IsAvailable();
40
41 /// Binds to an existing connection created by
42 /// <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
43 /// via <code>SendPacket</code> and <code>GetPacket</code> in the Native
44 /// Client API.
45 ///
46 /// @param[in] name The connection name as defined by the user when calling
47 /// <code>chrome.vpnProvider.createConfig</code>.
48 ///
49 /// @param[in] id The connection id from the callback of
50 /// <code>chrome.vpnProvider.createConfig</code>.
51 ///
52 /// @param[in] callback A <code>CompletionCallback</code> to be
53 /// called upon completion of Bind.
54 int32_t Bind(const std::string& name,
55 const std::string& id,
56 const CompletionCallback& callback);
57
58 /// GetUnBindEvent() registers a callback that will be called when the current
59 /// connection gets unbound.
60 ///
61 /// @param[in] callback A <code>PP_CompletionCallback</code> called when
62 /// the current connection gets unbound.
63 int32_t GetUnBindEvent(const CompletionCallback& callback);
64
65 /// Sends an IP packet through the tunnel created for the VPN session. This
66 /// will succeed only when the VPN session is owned by the module.
67 ///
68 /// @param[in] data IP packet to be sent to the platform. The <code>Var</code>
69 /// will be of ArrayBuffer type.
70 int32_t SendPacket(const Var& packet, const CompletionCallback& callback);
71
72 /// Receives an IP packet from the tunnel for the VPN session.
73 /// This interface only returns a single packet. That is, this interface must
74 /// be called at least N times to receive N packets, no matter the size of
75 /// each packet.
76 ///
77 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
78 /// called upon completion of GetPacket. It will be passed an ArrayBuffer type
79 /// <code>Var</code> containing an IP packet to be sent to the platform.
80 ///
81 /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
82 /// If an error is detected or connection is closed, GetPacket() returns
83 /// <code>PP_ERROR_FAILED</code> after all buffered messages are received.
84 /// Until buffered packets become empty, GetPacket() continues to return
85 /// <code>PP_OK</code> as if connection is still established without errors.
86 int32_t GetPacket(const CompletionCallbackWithOutput<Var>& callback);
87
88 private:
89 InstanceHandle associated_instance_;
90 };
91
92 } // namespace pp
93
94 #endif // PPAPI_CPP_VPN_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698