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

Side by Side Diff: ppapi/proxy/vpn_provider_resource.h

Issue 1931513002: ppapi: PPB_VpnProvider: Implement Resource Stub (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vpn-api-messages
Patch Set: Remove PPAPI mesages. Calls now stubbed. 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
OLDNEW
(Empty)
1 // Copyright (c) 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_PROXY_VPN_PROVIDER_RESOURCE_H_
6 #define PPAPI_PROXY_VPN_PROVIDER_RESOURCE_H_
7
8 #include <memory>
9 #include <queue>
10
11 #include "ppapi/proxy/plugin_resource.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/shared_impl/var.h"
14 #include "ppapi/shared_impl/vpn_provider_util.h"
15 #include "ppapi/thunk/ppb_vpn_provider_api.h"
16
17 namespace ppapi {
18 namespace proxy {
19
20 class PPAPI_PROXY_EXPORT VpnProviderResource
21 : public PluginResource,
22 public NON_EXPORTED_BASE(thunk::PPB_VpnProvider_API) {
23 public:
24 VpnProviderResource(Connection connection, PP_Instance instance);
25 virtual ~VpnProviderResource();
26
27 // PluginResource implementation.
28 virtual thunk::PPB_VpnProvider_API* AsPPB_VpnProvider_API() override;
29
30 // PPB_VpnProvider_API implementation.
31 virtual int32_t Bind(const PP_Var& configuration_id,
32 const PP_Var& configuration_name,
33 const scoped_refptr<TrackedCallback>& callback) override;
34 virtual int32_t SendPacket(
35 const PP_Var& packet,
36 const scoped_refptr<TrackedCallback>& callback) override;
37 virtual int32_t ReceivePacket(
38 PP_Var* packet,
39 const scoped_refptr<TrackedCallback>& callback) override;
40
41 private:
42 // PluginResource overrides.
43 virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
44 const IPC::Message& msg) override;
45
46 // PPB_VpnProvider IPC Replies
47 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params,
48 uint32_t queue_size,
49 uint32_t max_packet_size,
50 int32_t result);
51 void OnPluginMsgSendPacketReply(const ResourceMessageReplyParams& params,
52 int32_t result);
53
54 // Browser callbacks
55 void OnPluginMsgOnUnbindReceived(const ResourceMessageReplyParams& params);
56 void OnPluginMsgOnPacketReceived(const ResourceMessageReplyParams& params,
57 uint32_t packet_size,
58 uint32_t id);
59
60 // Picks up a received packet and moves it to user buffer. This method is used
61 // in both ReceivePacket() for fast returning path, and in
62 // OnPluginMsgOnPacketReceived() for delayed callback invocations.
63 void WritePacket();
64
65 // Sends a packet to the browser. This method is used in both SendPacket() for
66 // fast path, and in OnPluginMsgSendPacketReply for processing previously
67 // queued packets.
68 int32_t DoSendPacket(const PP_Var& packet, uint32_t id);
69
70 scoped_refptr<TrackedCallback> bind_callback_;
71 scoped_refptr<TrackedCallback> send_packet_callback_;
72 scoped_refptr<TrackedCallback> receive_packet_callback_;
73
74 // Keeps a pointer to the provided callback variable. Received packet will be
75 // copied to this variable on ready.
76 PP_Var* receive_packet_callback_var_;
77
78 std::unique_ptr<ppapi::VpnProviderSharedBuffer> send_packet_buffer_;
79 std::unique_ptr<ppapi::VpnProviderSharedBuffer> receive_packet_buffer_;
80
81 std::queue<PP_Var> send_packets_;
82 std::queue<scoped_refptr<Var>> received_packets_;
83
84 // Connection bound state
85 bool bound_;
86
87 DISALLOW_COPY_AND_ASSIGN(VpnProviderResource);
88 };
89
90 } // namespace proxy
91 } // namespace ppapi
92
93 #endif // PPAPI_PROXY_VPN_PROVIDER_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698