From 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 14 Jul 2016 17:41:05 +0200 Subject: BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning --- chromium/ppapi/cpp/graphics_2d.cc | 15 +++++ chromium/ppapi/cpp/graphics_2d.h | 3 + chromium/ppapi/cpp/vpn_provider.cc | 68 +++++++++++++++++++ chromium/ppapi/cpp/vpn_provider.h | 135 +++++++++++++++++++++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 chromium/ppapi/cpp/vpn_provider.cc create mode 100644 chromium/ppapi/cpp/vpn_provider.h (limited to 'chromium/ppapi/cpp') diff --git a/chromium/ppapi/cpp/graphics_2d.cc b/chromium/ppapi/cpp/graphics_2d.cc index 3a766c83546..d196cabd583 100644 --- a/chromium/ppapi/cpp/graphics_2d.cc +++ b/chromium/ppapi/cpp/graphics_2d.cc @@ -26,6 +26,11 @@ template <> const char* interface_name() { return PPB_GRAPHICS_2D_INTERFACE_1_1; } +template <> const char* interface_name() { + return PPB_GRAPHICS_2D_INTERFACE_1_2; +} + + } // namespace Graphics2D::Graphics2D() : Resource() { @@ -152,4 +157,14 @@ float Graphics2D::GetScale() { return get_interface()->GetScale(pp_resource()); } +bool Graphics2D::SetLayerTransform(float scale, + const Point& origin, + const Point& translate) { + if (!has_interface()) + return false; + return PP_ToBool(get_interface()->SetLayerTransform( + pp_resource(), scale, &origin.pp_point(), &translate.pp_point())); +} + + } // namespace pp diff --git a/chromium/ppapi/cpp/graphics_2d.h b/chromium/ppapi/cpp/graphics_2d.h index c6a23905d6f..86b89c77efb 100644 --- a/chromium/ppapi/cpp/graphics_2d.h +++ b/chromium/ppapi/cpp/graphics_2d.h @@ -284,6 +284,9 @@ class Graphics2D : public Resource { /// is 1.0. float GetScale(); + bool SetLayerTransform(float scale, + const Point& origin, + const Point& translate); private: Size size_; }; diff --git a/chromium/ppapi/cpp/vpn_provider.cc b/chromium/ppapi/cpp/vpn_provider.cc new file mode 100644 index 00000000000..d44b7bc94d4 --- /dev/null +++ b/chromium/ppapi/cpp/vpn_provider.cc @@ -0,0 +1,68 @@ +// 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. + +#include "ppapi/cpp/vpn_provider.h" + +#include "ppapi/c/ppb_vpn_provider.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var_array.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name() { + return PPB_VPNPROVIDER_INTERFACE_0_1; +} +} // namespace + +VpnProvider::VpnProvider(const InstanceHandle& instance) + : associated_instance_(instance) { + if (has_interface()) { + PassRefFromConstructor(get_interface()->Create( + associated_instance_.pp_instance())); + } +} + +VpnProvider::~VpnProvider() {} + +// static +bool VpnProvider::IsAvailable() { + return has_interface(); +} + +int32_t VpnProvider::Bind(const Var& configuration_id, + const Var& configuration_name, + const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Bind( + pp_resource(), configuration_id.pp_var(), configuration_name.pp_var(), + callback.pp_completion_callback()); + } + return PP_ERROR_NOINTERFACE; +} + +int32_t VpnProvider::SendPacket(const Var& packet, + const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->SendPacket( + pp_resource(), packet.pp_var(), callback.pp_completion_callback()); + } + return PP_ERROR_NOINTERFACE; +} + +int32_t VpnProvider::ReceivePacket( + const CompletionCallbackWithOutput& callback) { + if (has_interface()) { + return get_interface()->ReceivePacket( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return PP_ERROR_NOINTERFACE; +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/vpn_provider.h b/chromium/ppapi/cpp/vpn_provider.h new file mode 100644 index 00000000000..9d94981e586 --- /dev/null +++ b/chromium/ppapi/cpp/vpn_provider.h @@ -0,0 +1,135 @@ +// 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 PPAPI_CPP_VPN_PROVIDER_H_ +#define PPAPI_CPP_VPN_PROVIDER_H_ + +#include + +#include "ppapi/c/ppb_vpn_provider.h" +#include "ppapi/cpp/completion_callback.h" + +namespace pp { + +class InstanceHandle; + +/// @file +/// This file defines the VpnProvider interface providing a way to implement a +/// VPN client. +/// Important: This API is available only on Chrome OS. + +/// The VpnProvider class enhances the +/// chrome.vpnProvider JavaScript API by providing a high +/// performance path for packet handling. +/// +/// Permissions: Apps permission vpnProvider is required for +/// VpnProvider.Bind(). +/// +/// Typical usage: +/// - Create a VpnProvider instance. +/// - Register the callback for VpnProvider.ReceivePacket(). +/// - In the extension follow the usual workflow for configuring a VPN +/// connection via the chrome.vpnProvider API until the step for +/// notifying the connection state as "connected". +/// - Bind to the previously created connection using +/// VpnProvider.Bind(). +/// - Notify the connection state as "connected" from JavaScript using +/// chrome.vpnProvider.notifyConnectionStateChanged. +/// - When the steps above are completed without errors, a virtual tunnel is +/// created to the network stack of Chrome OS. IP packets can be sent through +/// the tunnel using VpnProvider.SendPacket() and any packets +/// originating on the Chrome OS device will be received using the callback +/// registered for VpnProvider.ReceivePacket(). +/// - When the user disconnects from the VPN configuration or there is an error +/// the extension will be notfied via +/// chrome.vpnProvider.onPlatformMessage. +class VpnProvider : public Resource { + public: + /// Constructs a VpnProvider object. + /// + /// @param[in] instance The instance with which this resource will be + /// associated. + explicit VpnProvider(const InstanceHandle& instance); + + /// Destructs a VpnProvider object. + virtual ~VpnProvider(); + + /// Static function for determining whether the browser supports the + /// VpnProvider interface. + /// + /// @return true if the interface is available, false otherwise. + static bool IsAvailable(); + + /// Binds to an existing configuration created from JavaScript by + /// chrome.vpnProvider.createConfig. All packets will be routed + /// via SendPacket and ReceivePacket. The user + /// should register the callback for ReceivePacket before calling + /// Bind(). + /// + /// @param[in] configuration_id The configuration id from the callback of + /// chrome.vpnProvider.createConfig. This Var must + /// be of string type. + /// + /// @param[in] configuration_name The configuration name as defined by the + /// user when calling chrome.vpnProvider.createConfig. This + /// Var must be of string type. + /// + /// @param[in] callback A CompletionCallback to be called on + /// completion. + /// + /// @return An int32_t containing an error code from pp_errors.h. + /// Returns PP_ERROR_INPROGRESS if a previous call to + /// Bind() has not completed. + /// Returns PP_ERROR_BADARGUMENT if the Var type of + /// either configuration_id or configuration_name is + /// not of string type. + /// Returns PP_ERROR_NOACCESS if the caller does the have the + /// required "vpnProvider" permission. + /// Returns PP_ERROR_FAILED if connection_id and + /// connection_name could not be matched with the existing + /// connection, or if the plugin originates from a different extension than + /// the one that created the connection. + int32_t Bind(const Var& configuration_id, + const Var& configuration_name, + const CompletionCallback& callback); + + /// Sends an IP packet through the tunnel created for the VPN session. This + /// will succeed only when the VPN session is owned by the module and + /// connection is bound. + /// + /// @param[in] packet IP packet to be sent to the platform. The + /// Var must be of ArrayBuffer type. + /// + /// @param[in] callback A CompletionCallback to be called on + /// completion. + /// + /// @return An int32_t containing an error code from pp_errors.h. + /// Returns PP_ERROR_FAILED if the connection is not bound. + /// Returns PP_ERROR_INPROGRESS if a previous call to + /// SendPacket() has not completed. + /// Returns PP_ERROR_BADARGUMENT if the Var type of + /// packet is not of ArrayBuffer type. + int32_t SendPacket(const Var& packet, const CompletionCallback& callback); + + /// Receives an IP packet from the tunnel for the VPN session. This function + /// only returns a single packet. That is, this function must be called at + /// least N times to receive N packets, no matter the size of each packet. The + /// callback should be registered before calling Bind(). + /// + /// @param[in] callback A CompletionCallbackWithOutput to be + /// called upon completion of ReceivePacket. It will be passed an ArrayBuffer + /// type Var containing an IP packet to be sent to the platform. + /// + /// @return An int32_t containing an error code from pp_errors.h. + /// Returns PP_ERROR_INPROGRESS if a previous call to + /// ReceivePacket() has not completed. + int32_t ReceivePacket(const CompletionCallbackWithOutput& callback); + + private: + InstanceHandle associated_instance_; +}; + +} // namespace pp + +#endif // PPAPI_CPP_VPN_PROVIDER_H_ -- cgit v1.2.1