Commit b2223b28 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Move socket_client.h out of the Blink API

Now that socket_client.h can be moved out of the Blink exposed API
layer, the extra copy step in P2PSocketClientImpl::SendWithPacketId
can also be removed.
This solution was added temporarily in [1], as part of Onion souping
this file.

[1] https://crrev.com/c/1805159/

In summary, this CL:

- moves socket_client.h from blink/public/platform/modules/p2p/
  to blink/renderer/platform/p2p/.
  - adapts the header being moved accordingly.
  - eliminates blink/public/platform/modules/p2p/ altogether.

- P2PSocketClientImpl::SendWithPacketId to operate over WTF::Vector,
  instead of std::vector.

BUG=787254, 919392
R=guidou@chromium.org, haraken@chromium.org

Change-Id: I1c8713cb6c96663cd0d7db8acbac1dfaa4809931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806979
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697681}
parent 40a2546e
...@@ -149,7 +149,6 @@ source_set("blink_headers") { ...@@ -149,7 +149,6 @@ source_set("blink_headers") {
"platform/modules/mediastream/web_platform_media_stream_source.h", "platform/modules/mediastream/web_platform_media_stream_source.h",
"platform/modules/mediastream/web_platform_media_stream_track.h", "platform/modules/mediastream/web_platform_media_stream_track.h",
"platform/modules/mediastream/webrtc_uma_histograms.h", "platform/modules/mediastream/webrtc_uma_histograms.h",
"platform/modules/p2p/socket_client.h",
"platform/modules/peerconnection/audio_codec_factory.h", "platform/modules/peerconnection/audio_codec_factory.h",
"platform/modules/peerconnection/rtc_event_log_output_sink.h", "platform/modules/peerconnection/rtc_event_log_output_sink.h",
"platform/modules/peerconnection/rtc_event_log_output_sink_proxy_util.h", "platform/modules/peerconnection/rtc_event_log_output_sink_proxy_util.h",
......
include_rules = [
"+net/base/ip_endpoint.h",
"+services/network/public/cpp/p2p_socket_type.h",
]
file://third_party/blink/renderer/platform/p2p/OWNERS
...@@ -1247,6 +1247,7 @@ jumbo_component("platform") { ...@@ -1247,6 +1247,7 @@ jumbo_component("platform") {
"p2p/network_manager_uma.h", "p2p/network_manager_uma.h",
"p2p/port_allocator.cc", "p2p/port_allocator.cc",
"p2p/port_allocator.h", "p2p/port_allocator.h",
"p2p/socket_client.h",
"p2p/socket_client_delegate.h", "p2p/socket_client_delegate.h",
"p2p/socket_client_impl.cc", "p2p/socket_client_impl.cc",
"p2p/socket_client_impl.h", "p2p/socket_client_impl.h",
......
...@@ -424,7 +424,8 @@ int IpcPacketSocket::SendTo(const void* data, ...@@ -424,7 +424,8 @@ int IpcPacketSocket::SendTo(const void* data,
send_bytes_available_ -= data_size; send_bytes_available_ -= data_size;
const int8_t* data_char = reinterpret_cast<const int8_t*>(data); const int8_t* data_char = reinterpret_cast<const int8_t*>(data);
std::vector<int8_t> data_vector(data_char, data_char + data_size); Vector<int8_t> data_vector;
data_vector.AppendRange(data_char, data_char + data_size);
uint64_t packet_id = client_->Send(address_chrome, data_vector, options); uint64_t packet_id = client_->Send(address_chrome, data_vector, options);
// Ensure packet_id is not 0. It can't be the case according to // Ensure packet_id is not 0. It can't be the case according to
......
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_SOCKET_CLIENT_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_P2P_SOCKET_CLIENT_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_SOCKET_CLIENT_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_P2P_SOCKET_CLIENT_H_
#include <stdint.h> #include <stdint.h>
#include <vector>
#include "net/base/ip_endpoint.h" #include "net/base/ip_endpoint.h"
#include "services/network/public/cpp/p2p_socket_type.h" #include "services/network/public/cpp/p2p_socket_type.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace rtc { namespace rtc {
struct PacketOptions; struct PacketOptions;
...@@ -22,8 +21,10 @@ class P2PSocketClientDelegate; ...@@ -22,8 +21,10 @@ class P2PSocketClientDelegate;
// P2P socket that routes all calls over IPC. // P2P socket that routes all calls over IPC.
// //
// TODO(crbug.com/787254): Move this class out of the Blink exposed API when // TODO(crbug.com/787254): Verify whether this class is still needed
// all users of it have been Onion souped. Also, move it away from std::vector. // now that all its clients are in Blink.
//
// Also, move it away from std::vector.
class P2PSocketClient { class P2PSocketClient {
public: public:
virtual ~P2PSocketClient() {} virtual ~P2PSocketClient() {}
...@@ -31,7 +32,7 @@ class P2PSocketClient { ...@@ -31,7 +32,7 @@ class P2PSocketClient {
// Send the |data| to the |address| using Differentiated Services Code Point // Send the |data| to the |address| using Differentiated Services Code Point
// |dscp|. Return value is the unique packet_id for this packet. // |dscp|. Return value is the unique packet_id for this packet.
virtual uint64_t Send(const net::IPEndPoint& address, virtual uint64_t Send(const net::IPEndPoint& address,
const std::vector<int8_t>& data, const Vector<int8_t>& data,
const rtc::PacketOptions& options) = 0; const rtc::PacketOptions& options) = 0;
virtual void SetOption(network::P2PSocketOption option, int value) = 0; virtual void SetOption(network::P2PSocketOption option, int value) = 0;
...@@ -47,4 +48,4 @@ class P2PSocketClient { ...@@ -47,4 +48,4 @@ class P2PSocketClient {
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_SOCKET_CLIENT_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_P2P_SOCKET_CLIENT_H_
...@@ -67,7 +67,7 @@ void P2PSocketClientImpl::Init( ...@@ -67,7 +67,7 @@ void P2PSocketClientImpl::Init(
} }
uint64_t P2PSocketClientImpl::Send(const net::IPEndPoint& address, uint64_t P2PSocketClientImpl::Send(const net::IPEndPoint& address,
const std::vector<int8_t>& data, const Vector<int8_t>& data,
const rtc::PacketOptions& options) { const rtc::PacketOptions& options) {
uint64_t unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_); uint64_t unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_);
...@@ -81,19 +81,12 @@ uint64_t P2PSocketClientImpl::Send(const net::IPEndPoint& address, ...@@ -81,19 +81,12 @@ uint64_t P2PSocketClientImpl::Send(const net::IPEndPoint& address,
} }
void P2PSocketClientImpl::SendWithPacketId(const net::IPEndPoint& address, void P2PSocketClientImpl::SendWithPacketId(const net::IPEndPoint& address,
const std::vector<int8_t>& data, const Vector<int8_t>& data,
const rtc::PacketOptions& options, const rtc::PacketOptions& options,
uint64_t packet_id) { uint64_t packet_id) {
TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", packet_id); TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", packet_id);
// TODO(crbug.com/787254): Remove this helper when socket_client.h gets moved socket_->Send(data, network::P2PPacketInfo(address, options, packet_id),
// from blink/public to blink/renderer, and operates over WTF::Vector.
Vector<int8_t> copy(data.size());
for (size_t i = 0; i < data.size(); i++)
copy[i] = data[i];
socket_->Send(std::move(copy),
network::P2PPacketInfo(address, options, packet_id),
net::MutableNetworkTrafficAnnotationTag(traffic_annotation_)); net::MutableNetworkTrafficAnnotationTag(traffic_annotation_));
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <stdint.h> #include <stdint.h>
#include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
...@@ -17,7 +15,7 @@ ...@@ -17,7 +15,7 @@
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/p2p_socket_type.h" #include "services/network/public/cpp/p2p_socket_type.h"
#include "services/network/public/mojom/p2p.mojom-blink.h" #include "services/network/public/mojom/p2p.mojom-blink.h"
#include "third_party/blink/public/platform/modules/p2p/socket_client.h" #include "third_party/blink/renderer/platform/p2p/socket_client.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
namespace base { namespace base {
...@@ -52,7 +50,7 @@ class P2PSocketClientImpl : public blink::P2PSocketClient, ...@@ -52,7 +50,7 @@ class P2PSocketClientImpl : public blink::P2PSocketClient,
// Send the |data| to the |address| using Differentiated Services Code Point // Send the |data| to the |address| using Differentiated Services Code Point
// |dscp|. Return value is the unique packet_id for this packet. // |dscp|. Return value is the unique packet_id for this packet.
uint64_t Send(const net::IPEndPoint& address, uint64_t Send(const net::IPEndPoint& address,
const std::vector<int8_t>& data, const Vector<int8_t>& data,
const rtc::PacketOptions& options) override; const rtc::PacketOptions& options) override;
// Setting socket options. // Setting socket options.
...@@ -80,7 +78,7 @@ class P2PSocketClientImpl : public blink::P2PSocketClient, ...@@ -80,7 +78,7 @@ class P2PSocketClientImpl : public blink::P2PSocketClient,
// Helper function to be called by Send to handle different threading // Helper function to be called by Send to handle different threading
// condition. // condition.
void SendWithPacketId(const net::IPEndPoint& address, void SendWithPacketId(const net::IPEndPoint& address,
const std::vector<int8_t>& data, const Vector<int8_t>& data,
const rtc::PacketOptions& options, const rtc::PacketOptions& options,
uint64_t packet_id); uint64_t packet_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment