Chromium Code Reviews| Index: content/browser/renderer_host/pepper/pepper_vpn_provider_message_filter_chromeos.h |
| diff --git a/content/browser/renderer_host/pepper/pepper_vpn_provider_message_filter_chromeos.h b/content/browser/renderer_host/pepper/pepper_vpn_provider_message_filter_chromeos.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..80a3b9236018e84528da7ed3d4b6022d65b6f08f |
| --- /dev/null |
| +++ b/content/browser/renderer_host/pepper/pepper_vpn_provider_message_filter_chromeos.h |
| @@ -0,0 +1,102 @@ |
| +// 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_VPN_PROVIDER_MESSAGE_FILTER_CHROMEOS_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_VPN_PROVIDER_MESSAGE_FILTER_CHROMEOS_H_ |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
| +#include "content/common/content_export.h" |
| +#include "content/public/browser/vpn_service_proxy.h" |
| +#include "ppapi/c/ppb_vpn_provider.h" |
| +#include "ppapi/host/resource_host.h" |
| +#include "ppapi/host/resource_message_filter.h" |
| +#include "ppapi/shared_impl/vpn_provider_util.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| + |
| +// The host for PPB_VpnProvider. |
| +// Important: The PPB_VpnProvider API is available only on Chrome OS. |
| +class CONTENT_EXPORT PepperVpnProviderMessageFilter |
| + : public ppapi::host::ResourceMessageFilter { |
| + public: |
| + PepperVpnProviderMessageFilter(BrowserPpapiHostImpl* host, |
| + PP_Instance instance); |
| + |
| + // ppapi::host::ResourceMessageFilter overrides. |
| + scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( |
| + const IPC::Message& message) override; |
| + int32_t OnResourceMessageReceived( |
| + const IPC::Message& msg, |
| + ppapi::host::HostMessageContext* context) override; |
| + |
| + private: |
| + class PepperVpnProviderResourceHostProxyImpl; |
|
bbudge
2016/06/23 18:10:22
Since this is not used anywhere in the header, I t
adrian.belgun
2016/06/24 13:19:37
Done.
|
| + using SuccessCallback = base::Closure; |
| + using StringCallback = base::Callback<void(const std::string& result)>; |
|
bbudge
2016/06/23 18:10:23
nit: MessageCallback or ResultCallback
NOTE: this
adrian.belgun
2016/06/24 13:19:37
Done. Removed.
|
| + using FailureCallback = |
| + base::Callback<void(const std::string& error_name, |
| + const std::string& error_message)>; |
| + ~PepperVpnProviderMessageFilter() override; |
| + |
| + // Message handlers |
| + int32_t OnBind(ppapi::host::HostMessageContext* context, |
| + const std::string& configuration_id, |
| + const std::string& configuration_name); |
| + int32_t OnSendPacket(ppapi::host::HostMessageContext* context, |
| + uint32_t packet_size, |
| + uint32_t id); |
| + int32_t OnPacketReceivedReply(ppapi::host::HostMessageContext* context, |
| + uint32_t id); |
| + // OnBind helpers |
| + int32_t DoBind(SuccessCallback success, FailureCallback failure); |
| + void OnBindSuccess(const ppapi::host::ReplyMessageContext& context); |
| + void OnBindFailure(const ppapi::host::ReplyMessageContext& context, |
| + const std::string& error_name, |
| + const std::string& error_message); |
| + void OnBindReply(const ppapi::host::ReplyMessageContext& context, |
| + int32_t reply); |
| + |
| + // OnSendPacket helpers |
| + int32_t DoSendPacket(const std::vector<char>& packet, |
| + SuccessCallback success, |
| + FailureCallback failure); |
| + void OnSendPacketSuccess(const ppapi::host::ReplyMessageContext& context, |
| + uint32_t id); |
| + void OnSendPacketFailure(const ppapi::host::ReplyMessageContext& context, |
| + uint32_t id, |
| + const std::string& error_name, |
| + const std::string& error_message); |
| + void OnSendPacketReply(const ppapi::host::ReplyMessageContext& context, |
| + int32_t reply); |
| + |
| + // OnPacketReceived helper |
| + void DoPacketReceived(const std::vector<char>& packet, uint32_t id); |
| + |
| + // PepperVpnProviderResourceHostProxyImpl entry points. |
| + void SendOnPacketReceived(const std::vector<char>& packet); |
| + void SendOnUnbind(); |
| + |
| + GURL extension_id_; |
| + std::string configuration_id_; |
| + std::string configuration_name_; |
| + |
| + BrowserContext* browser_context_; |
| + std::unique_ptr<VpnServiceProxy> vpn_service_proxy_; |
| + |
| + bool bound_; |
| + std::unique_ptr<ppapi::VpnProviderSharedBuffer> send_packet_buffer_; |
| + std::unique_ptr<ppapi::VpnProviderSharedBuffer> receive_packet_buffer_; |
| + |
| + std::queue<std::vector<char>> received_packets_; |
| + |
| + base::WeakPtrFactory<PepperVpnProviderMessageFilter> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperVpnProviderMessageFilter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_VPN_PROVIDER_MESSAGE_FILTER_CHROMEOS_H_ |