| Index: ppapi/proxy/vpn_provider_resource.h
|
| diff --git a/ppapi/proxy/vpn_provider_resource.h b/ppapi/proxy/vpn_provider_resource.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0210ada4d6b10cb5e48effdd20f959096df7ff84
|
| --- /dev/null
|
| +++ b/ppapi/proxy/vpn_provider_resource.h
|
| @@ -0,0 +1,133 @@
|
| +// Copyright (c) 2015 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_PROXY_VPN_PROVIDER_RESOURCE_H_
|
| +#define PPAPI_PROXY_VPN_PROVIDER_RESOURCE_H_
|
| +
|
| +#include "ppapi/c/ppb_vpn_provider.h"
|
| +#include "ppapi/proxy/plugin_dispatcher.h"
|
| +#include "ppapi/proxy/plugin_resource.h"
|
| +#include "ppapi/shared_impl/tracked_callback.h"
|
| +#include "ppapi/thunk/ppb_vpn_provider_api.h"
|
| +
|
| +namespace ppapi {
|
| +namespace proxy {
|
| +
|
| +class PPAPI_PROXY_EXPORT VpnProviderResource
|
| + : public PluginResource,
|
| + public NON_EXPORTED_BASE(thunk::PPB_VpnProvider_API) {
|
| + public:
|
| + VpnProviderResource(Connection connection, PP_Instance instance);
|
| + virtual ~VpnProviderResource();
|
| +
|
| + // PluginResource implementation.
|
| + virtual thunk::PPB_VpnProvider_API* AsPPB_VpnProvider_API() override;
|
| +
|
| + // PPB_VpnProvider_API implementation.
|
| + virtual int32_t CreateConfig(
|
| + const PP_Var& name,
|
| + PP_Var* id,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t DestroyConfig(
|
| + const PP_Var& id,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t SetParameters(
|
| + const PP_Var& address,
|
| + const PP_Var& broadcast_address,
|
| + int32_t mtu,
|
| + const PP_Var& exclusion_list,
|
| + const PP_Var& inclusion_list,
|
| + const PP_Var& domain_search,
|
| + const PP_Var& dns_servers,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t SendPacket(const PP_Var& packet) override;
|
| + virtual int32_t NotifyConnectionStateChanged(
|
| + PP_VpnProvider_VpnConnectionState status,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t GetPacket(
|
| + PP_Var* packet,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t GetPlatformMessage(
|
| + PP_Var* message,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t GetConfigMessage(
|
| + PP_Var* message,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| + virtual int32_t GetUIMessage(
|
| + PP_Var* message,
|
| + const scoped_refptr<TrackedCallback>& callback) override;
|
| +
|
| + private:
|
| + // PluginResource overrides.
|
| + virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
|
| + const IPC::Message& msg) override;
|
| +
|
| + // PPB_VpnProvider IPC Replies
|
| + void OnPluginMsgCreateConfigReply(const ResourceMessageReplyParams& params,
|
| + int32_t result,
|
| + const std::string& id);
|
| + void OnPluginMsgDestroyConfigReply(const ResourceMessageReplyParams& params,
|
| + int32_t result);
|
| + void OnPluginMsgSetParametersReply(const ResourceMessageReplyParams& params,
|
| + int32_t result);
|
| + void OnPluginMsgNotifyConnectionStateChangedReply(
|
| + const ResourceMessageReplyParams& params,
|
| + int32_t result);
|
| +
|
| + // Browser callbacks
|
| + void OnPluginMsgOnPlatformMessage(const ResourceMessageReplyParams& params,
|
| + const std::string& id,
|
| + PP_VpnProvider_PlatformMessage status,
|
| + const std::string& message);
|
| + void OnPluginMsgOnPacketReceived(const ResourceMessageReplyParams& params,
|
| + const std::vector<char>& data);
|
| + void OnPluginMsgOnConfigEvent(const ResourceMessageReplyParams& params,
|
| + const std::string& id,
|
| + PP_VpnProvider_ConfigMessage message,
|
| + const std::string& name,
|
| + const std::string& data);
|
| + void OnPluginMsgOnUIEvent(const ResourceMessageReplyParams& params,
|
| + PP_VpnProvider_UIEvent event,
|
| + const std::string& id);
|
| +
|
| + // Picks up a received message and moves it to user receiving buffer. This
|
| + // function is used in both Get*() for fast returning path, and
|
| + // OnPluginMsgOn*() for delayed callback invocations.
|
| + void WritePacket();
|
| + void WritePlatformMessage();
|
| + void WriteConfigMessage();
|
| + void WriteUIMessage();
|
| +
|
| + // Holds user callbacks to invoke later.
|
| + scoped_refptr<TrackedCallback> create_config_callback_;
|
| + scoped_refptr<TrackedCallback> destroy_config_callback_;
|
| + scoped_refptr<TrackedCallback> set_parameters_callback_;
|
| + scoped_refptr<TrackedCallback> send_state_change_notification_callback_;
|
| +
|
| + scoped_refptr<TrackedCallback> get_packet_callback_;
|
| + scoped_refptr<TrackedCallback> get_platform_message_callback_;
|
| + scoped_refptr<TrackedCallback> get_config_message_callback_;
|
| + scoped_refptr<TrackedCallback> get_ui_message_callback_;
|
| +
|
| + // Keeps a pointer to the callback variable provided.
|
| + // Received data will be copied to this variable on ready.
|
| + PP_Var* create_config_callback_var_;
|
| + PP_Var* get_packet_callback_var_;
|
| + PP_Var* get_platform_message_callback_var_;
|
| + PP_Var* get_config_message_callback_var_;
|
| + PP_Var* get_ui_message_callback_var_;
|
| +
|
| + // Keeps received data.
|
| + std::queue<scoped_refptr<Var>> received_packets_;
|
| + std::queue<scoped_refptr<Var>> received_platform_messages_;
|
| + std::queue<scoped_refptr<Var>> received_config_messages_;
|
| + std::queue<scoped_refptr<Var>> received_ui_messages_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(VpnProviderResource);
|
| +};
|
| +
|
| +} // namespace proxy
|
| +} // namespace ppapi
|
| +
|
| +#endif // PPAPI_PROXY_VPN_PROVIDER_RESOURCE_H_
|
|
|