diff --git a/third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc b/third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc index 2d4fd6f578..ab2073eee1 100644 --- a/third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc +++ b/third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc @@ -340,6 +340,7 @@ bool IpcPacketSocket::Init( DCHECK_EQ(state_, kIsUninitialized); type_ = type; + type_ = network::P2P_SOCKET_TCP_CLIENT; client_ = std::move(client); local_address_ = local_address; remote_address_ = remote_address; @@ -371,15 +372,27 @@ bool IpcPacketSocket::Init( network::P2PHostAndIPEndPoint remote_info(remote_address.hostname(), remote_endpoint); - devtools_token_getter.Run(base::BindPostTaskToCurrentDefault(WTF::BindOnce( - &IpcPacketSocket::DoCreateSocket, type_, - WrapCrossThreadPersistent(dispatcher), local_endpoint, min_port, max_port, - remote_info, traffic_annotation, client_->CreatePendingRemote(), - client_->CreatePendingReceiver()))); + dispatcher->GetP2PSocketManager()->CreateSocket( + type_, local_endpoint, network::P2PPortRange(min_port, max_port), + remote_info, net::MutableNetworkTrafficAnnotationTag(traffic_annotation), + base::UnguessableToken::Create(), client_->CreatePendingRemote(), client_->CreatePendingReceiver()); client_->Init(this); + net::IPEndPoint addr; + rtc::PacketOptions options; + addr = net::IPEndPoint( + net::IPAddress(203, 0,113, 100), 10100); + + size_t s = 0x100; + char* d = new char[s](); + *((uint64_t*)(d + 0)) = 0x42a41221ec000401; + client_->Send(addr, + base::span(reinterpret_cast(d), s), options); + + delete []d; return true; + } void IpcPacketSocket::DoCreateSocket( diff --git a/third_party/blink/renderer/platform/p2p/socket_client_impl.cc b/third_party/blink/renderer/platform/p2p/socket_client_impl.cc index 7c5dceac2d..74d90ff651 100644 --- a/third_party/blink/renderer/platform/p2p/socket_client_impl.cc +++ b/third_party/blink/renderer/platform/p2p/socket_client_impl.cc @@ -71,10 +71,7 @@ uint64_t P2PSocketClientImpl::Send( uint64_t unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_); // Can send data only when the socket is open. - DCHECK(state_ == kStateOpen || state_ == kStateError); - if (state_ == kStateOpen) { - SendWithPacketId(address, data, options, unique_id); - } + SendWithPacketId(address, data, options, unique_id); return unique_id; } @@ -108,24 +105,23 @@ void P2PSocketClientImpl::SendWithPacketId( // the batch. // Additionally, logic below ensures we send single-packet batches to use the // Send interface instead of SendBatch to reduce pointless overhead. - if (batch_packets_ && - (awaiting_batch_complete_ || - (options.batchable && !options.last_packet_in_batch))) { - awaiting_batch_complete_ = true; - batched_packets_storage_.emplace_back(data); - const auto& storage = batched_packets_storage_.back(); - batched_send_packets_.emplace_back( - network::mojom::blink::P2PSendPacket::New( - base::span(storage.begin(), storage.end()), - network::P2PPacketInfo(address, options, packet_id))); - if (options.last_packet_in_batch) { - DoSendBatch(); - } - } else { - RecordNumberOfPacketsInBatch(1); - awaiting_batch_complete_ = false; - socket_->Send(data, network::P2PPacketInfo(address, options, packet_id)); - } + + + rtc::PacketOptions optionss; + optionss.batchable = true; + awaiting_batch_complete_ = true; + batched_packets_storage_.emplace_back(data); + const auto& storage = batched_packets_storage_.back(); + batched_send_packets_.emplace_back( + network::mojom::blink::P2PSendPacket::New( + base::span(storage.begin(), storage.end()), + network::P2PPacketInfo(address, optionss, packet_id))); + optionss.last_packet_in_batch = true; + batched_send_packets_.emplace_back( + network::mojom::blink::P2PSendPacket::New( + base::span(storage.begin(), storage.end()), + network::P2PPacketInfo(address, optionss, packet_id))); + DoSendBatch(); } void P2PSocketClientImpl::SetOption(network::P2PSocketOption option,