Commit 3f8b2db5 authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

Reconcile code differences between google3 and Chromium QUIC code

Merge internal change: 237089889

R=rch@chromium.org

Change-Id: I8051e8cb9260833d678884a0affcb272ada8cd12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1507194
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638707}
parent 0a942fb1
......@@ -3061,6 +3061,7 @@ if (is_linux) {
"third_party/quic/core/quic_epoll_connection_helper.h",
"third_party/quic/core/quic_packet_reader.cc",
"third_party/quic/core/quic_packet_reader.h",
"third_party/quic/platform/api/quic_default_buffer_allocator.h",
"third_party/quic/platform/api/quic_default_proof_providers.h",
"third_party/quic/platform/api/quic_system_event_loop.h",
"third_party/quic/platform/impl/batch_writer/quic_batch_writer_base.cc",
......@@ -3071,6 +3072,7 @@ if (is_linux) {
"third_party/quic/platform/impl/batch_writer/quic_gso_batch_writer.h",
"third_party/quic/platform/impl/batch_writer/quic_sendmmsg_batch_writer.cc",
"third_party/quic/platform/impl/batch_writer/quic_sendmmsg_batch_writer.h",
"third_party/quic/platform/impl/quic_default_buffer_allocator_impl.h",
"third_party/quic/platform/impl/quic_default_proof_providers_impl.cc",
"third_party/quic/platform/impl/quic_default_proof_providers_impl.h",
"third_party/quic/platform/impl/quic_epoll_clock.cc",
......@@ -3343,8 +3345,6 @@ source_set("quic_test_tools") {
sources += [
"third_party/quic/test_tools/bad_packet_writer.cc",
"third_party/quic/test_tools/bad_packet_writer.h",
"third_party/quic/test_tools/fake_epoll_server.cc",
"third_party/quic/test_tools/fake_epoll_server.h",
"third_party/quic/test_tools/limited_mtu_test_writer.cc",
"third_party/quic/test_tools/limited_mtu_test_writer.h",
"third_party/quic/test_tools/packet_dropping_test_writer.cc",
......@@ -3361,6 +3361,8 @@ source_set("quic_test_tools") {
"third_party/quic/test_tools/quic_test_server.h",
"third_party/quic/test_tools/server_thread.cc",
"third_party/quic/test_tools/server_thread.h",
"tools/epoll_server/fake_epoll_server.cc",
"tools/epoll_server/fake_epoll_server.h",
]
deps += [
":epoll_quic_tools",
......
......@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "net/third_party/quic/core/quic_utils.h"
#include "net/third_party/quic/platform/api/quic_arraysize.h"
#include "net/third_party/quic/platform/api/quic_singleton.h"
namespace quic {
......@@ -142,17 +141,10 @@ class CommonCertSetsQUIC : public CommonCertSets {
return false;
}
static CommonCertSetsQUIC* GetInstance() {
return QuicSingleton<CommonCertSetsQUIC>::get();
}
private:
CommonCertSetsQUIC() {}
CommonCertSetsQUIC(const CommonCertSetsQUIC&) = delete;
CommonCertSetsQUIC& operator=(const CommonCertSetsQUIC&) = delete;
~CommonCertSetsQUIC() override {}
friend QuicSingletonFriend<CommonCertSetsQUIC>;
};
} // anonymous namespace
......@@ -161,7 +153,8 @@ CommonCertSets::~CommonCertSets() {}
// static
const CommonCertSets* CommonCertSets::GetInstanceQUIC() {
return CommonCertSetsQUIC::GetInstance();
static CommonCertSetsQUIC* certs = new CommonCertSetsQUIC();
return certs;
}
} // namespace quic
......@@ -6,7 +6,6 @@
#include "base/macros.h"
#include "net/third_party/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quic/platform/api/quic_singleton.h"
#include "third_party/boringssl/src/include/openssl/rand.h"
namespace quic {
......@@ -15,25 +14,16 @@ namespace {
class DefaultRandom : public QuicRandom {
public:
static DefaultRandom* GetInstance();
// QuicRandom implementation
void RandBytes(void* data, size_t len) override;
uint64_t RandUint64() override;
private:
DefaultRandom() {}
DefaultRandom(const DefaultRandom&) = delete;
DefaultRandom& operator=(const DefaultRandom&) = delete;
~DefaultRandom() override {}
friend QuicSingletonFriend<DefaultRandom>;
// QuicRandom implementation
void RandBytes(void* data, size_t len) override;
uint64_t RandUint64() override;
};
DefaultRandom* DefaultRandom::GetInstance() {
return QuicSingleton<DefaultRandom>::get();
}
void DefaultRandom::RandBytes(void* data, size_t len) {
RAND_bytes(reinterpret_cast<uint8_t*>(data), len);
}
......@@ -48,7 +38,8 @@ uint64_t DefaultRandom::RandUint64() {
// static
QuicRandom* QuicRandom::GetInstance() {
return DefaultRandom::GetInstance();
static DefaultRandom* random = new DefaultRandom();
return random;
}
} // namespace quic
......@@ -4,6 +4,8 @@
#include "net/third_party/quic/core/quic_epoll_alarm_factory.h"
#include <type_traits>
#include "net/third_party/quic/core/quic_arena_scoped_ptr.h"
namespace quic {
......@@ -42,10 +44,12 @@ class QuicEpollAlarm : public QuicAlarm {
private:
class EpollAlarmImpl : public QuicEpollAlarmBase {
public:
using int64_epoll = decltype(QuicEpollAlarmBase().OnAlarm());
explicit EpollAlarmImpl(QuicEpollAlarm* alarm) : alarm_(alarm) {}
// Use the same integer type as the base class.
int64_t /* allow-non-std-int */ OnAlarm() override {
int64_epoll OnAlarm() override {
QuicEpollAlarmBase::OnAlarm();
alarm_->Fire();
// Fire will take care of registering the alarm, if needed.
......@@ -78,8 +82,8 @@ QuicArenaScopedPtr<QuicAlarm> QuicEpollAlarmFactory::CreateAlarm(
if (arena != nullptr) {
return arena->New<QuicEpollAlarm>(epoll_server_, std::move(delegate));
}
return QuicArenaScopedPtr<QuicAlarm>(
new QuicEpollAlarm(epoll_server_, std::move(delegate)));
return QuicArenaScopedPtr<QuicAlarm>(
new QuicEpollAlarm(epoll_server_, std::move(delegate)));
}
} // namespace quic
......@@ -17,6 +17,7 @@
#include "net/third_party/quic/core/quic_packets.h"
#include "net/third_party/quic/core/quic_simple_buffer_allocator.h"
#include "net/third_party/quic/core/quic_time.h"
#include "net/third_party/quic/platform/api/quic_default_buffer_allocator.h"
#include "net/third_party/quic/platform/api/quic_epoll.h"
#include "net/third_party/quic/platform/impl/quic_epoll_clock.h"
......@@ -24,8 +25,6 @@ namespace quic {
class QuicRandom;
using QuicStreamBufferAllocator = SimpleBufferAllocator;
enum class QuicAllocator { SIMPLE, BUFFER_POOL };
class QuicEpollConnectionHelper : public QuicConnectionHelperInterface {
......@@ -46,7 +45,7 @@ class QuicEpollConnectionHelper : public QuicConnectionHelperInterface {
QuicRandom* random_generator_;
// Set up allocators. They take up minimal memory before use.
// Allocator for stream send buffers.
QuicStreamBufferAllocator stream_buffer_allocator_;
QuicDefaultBufferAllocator stream_buffer_allocator_;
SimpleBufferAllocator simple_buffer_allocator_;
QuicAllocator allocator_type_;
};
......
......@@ -65,7 +65,7 @@ bool QuicPacketReader::ReadAndDispatchPackets(
const QuicClock& clock,
ProcessPacketInterface* processor,
QuicPacketCount* packets_dropped) {
#if MMSG_MORE
#if MMSG_MORE_NO_ANDROID
return ReadAndDispatchManyPackets(fd, port, clock, processor,
packets_dropped);
#else
......@@ -80,7 +80,7 @@ bool QuicPacketReader::ReadAndDispatchManyPackets(
const QuicClock& clock,
ProcessPacketInterface* processor,
QuicPacketCount* packets_dropped) {
#if MMSG_MORE
#if MMSG_MORE_NO_ANDROID
// Re-set the length fields in case recvmmsg has changed them.
for (int i = 0; i < kNumPacketsPerReadMmsgCall; ++i) {
DCHECK_LE(kMaxPacketSize, packets_[i].iov.iov_len);
......
......@@ -19,8 +19,6 @@
#include "net/third_party/quic/platform/api/quic_socket_address.h"
#include "net/third_party/quic/platform/impl/quic_socket_utils.h"
#define MMSG_MORE 0
namespace quic {
#if MMSG_MORE
......
......@@ -13,6 +13,8 @@ namespace quic {
// Used to generate filtered supported versions based on flags.
class QUIC_EXPORT_PRIVATE QuicVersionManager {
public:
// |supported_versions| should be sorted in the order of preference (typically
// highest supported version to the lowest supported version).
explicit QuicVersionManager(ParsedQuicVersionVector supported_versions);
virtual ~QuicVersionManager();
......@@ -20,7 +22,8 @@ class QUIC_EXPORT_PRIVATE QuicVersionManager {
// TODO(nharper): Remove this method once it is unused.
const QuicTransportVersionVector& GetSupportedTransportVersions();
// Returns currently supported QUIC versions.
// Returns currently supported QUIC versions. This vector has the same order
// as the versions passed to the constructor.
const ParsedQuicVersionVector& GetSupportedVersions();
protected:
......
......@@ -8,7 +8,6 @@
#include "net/third_party/quic/core/tls_client_handshaker.h"
#include "net/third_party/quic/platform/api/quic_arraysize.h"
#include "net/third_party/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quic/platform/api/quic_singleton.h"
#include "third_party/boringssl/src/include/openssl/crypto.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
......@@ -19,7 +18,8 @@ namespace {
class SslIndexSingleton {
public:
static SslIndexSingleton* GetInstance() {
return QuicSingleton<SslIndexSingleton>::get();
static SslIndexSingleton* instance = new SslIndexSingleton();
return instance;
}
int HandshakerIndex() const { return ssl_ex_data_index_handshaker_; }
......@@ -35,8 +35,6 @@ class SslIndexSingleton {
SslIndexSingleton(const SslIndexSingleton&) = delete;
SslIndexSingleton& operator=(const SslIndexSingleton&) = delete;
friend QuicSingletonFriend<SslIndexSingleton>;
int ssl_ex_data_index_handshaker_;
};
......
// Copyright (c) 2019 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 NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_DEFAULT_BUFFER_ALLOCATOR_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_DEFAULT_BUFFER_ALLOCATOR_H_
#include "net/third_party/quic/platform/impl/quic_default_buffer_allocator_impl.h"
namespace quic {
using QuicDefaultBufferAllocator = QuicStreamBufferAllocatorImpl;
}
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_DEFAULT_BUFFER_ALLOCATOR_H_
......@@ -11,4 +11,6 @@ inline void QuicRunSystemEventLoopIteration() {
QuicRunSystemEventLoopIterationImpl();
}
using QuicSystemEventLoop = QuicSystemEventLoopImpl;
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_API_QUIC_SYSTEM_EVENT_LOOP_H_
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_DEFAULT_BUFFER_ALLOCATOR_IMPL_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_DEFAULT_BUFFER_ALLOCATOR_IMPL_H_
#include "net/third_party/quic/core/quic_simple_buffer_allocator.h"
namespace quic {
using QuicStreamBufferAllocatorImpl = SimpleBufferAllocator;
} // namespace quic
#endif /* NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_DEFAULT_BUFFER_ALLOCATOR_IMPL_H_ \
*/
......@@ -6,7 +6,7 @@
#include "net/third_party/quic/platform/api/quic_flags.h"
#include "net/third_party/quic/platform/api/quic_test.h"
#include "net/third_party/quic/test_tools/fake_epoll_server.h"
#include "net/tools/epoll_server/fake_epoll_server.h"
namespace quic {
namespace test {
......
......@@ -5,7 +5,7 @@
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_EPOLL_TEST_TOOLS_IMPL_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_EPOLL_TEST_TOOLS_IMPL_H_
#include "net/third_party/quic/test_tools/fake_epoll_server.h"
#include "net/tools/epoll_server/fake_epoll_server.h"
using QuicFakeEpollServerImpl = quic::test::FakeEpollServer;
......
......@@ -31,8 +31,11 @@ QuicSocketAddressImpl::QuicSocketAddressImpl(
}
QuicSocketAddressImpl::QuicSocketAddressImpl(const struct sockaddr& saddr) {
QUIC_BUG << "QuicSocketAddressImpl(const struct sockaddr& saddr) is not "
"implemented.";
if (saddr.sa_family == AF_INET) {
CHECK(socket_address_.FromSockAddr(&saddr, sizeof(struct sockaddr_in)));
} else if (saddr.sa_family == AF_INET6) {
CHECK(socket_address_.FromSockAddr(&saddr, sizeof(struct sockaddr_in6)));
}
}
bool operator==(const QuicSocketAddressImpl& lhs,
......
......@@ -19,6 +19,9 @@
#include "net/third_party/quic/core/quic_bandwidth.h"
#include "net/third_party/quic/core/quic_types.h"
#define MMSG_MORE 0
#define MMSG_MORE_NO_ANDROID 0
namespace quic {
class QuicIpAddress;
class QuicSocketAddress;
......
......@@ -5,10 +5,22 @@
#ifndef NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SYSTEM_EVENT_LOOP_IMPL_H_
#define NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SYSTEM_EVENT_LOOP_IMPL_H_
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/task/task_scheduler/task_scheduler.h"
inline void QuicRunSystemEventLoopIterationImpl() {
base::RunLoop().RunUntilIdle();
}
class QuicSystemEventLoopImpl {
public:
QuicSystemEventLoopImpl(std::string context_name) {
base::TaskScheduler::CreateAndStartWithDefaultParams(context_name);
}
private:
base::MessageLoopForIO message_loop_;
};
#endif // NET_THIRD_PARTY_QUIC_PLATFORM_IMPL_QUIC_SYSTEM_EVENT_LOOP_IMPL_H_
......@@ -80,7 +80,8 @@ TEST_F(QuartcEndpointTest, ClientCreatesSessionAsynchronously) {
// Tests that the server can negotiate for an older QUIC version if the client
// attempts to connect using a newer version.
TEST_F(QuartcEndpointTest, DISABLED_ServerNegotiatesForOldVersion) {
TEST_F(QuartcEndpointTest,
QUIC_TEST_DISABLED_IN_CHROME(ServerNegotiatesForOldVersion)) {
// Note: for this test, we need support for two versions. Which two shouldn't
// matter, but they must be enabled so that the version manager doesn't filter
// them out.
......@@ -124,7 +125,8 @@ TEST_F(QuartcEndpointTest, DISABLED_ServerNegotiatesForOldVersion) {
// Tests that the server can accept connections from clients that use older
// QUIC versions.
TEST_F(QuartcEndpointTest, DISABLED_ServerAcceptsOldVersion) {
TEST_F(QuartcEndpointTest,
QUIC_TEST_DISABLED_IN_CHROME(ServerAcceptsOldVersion)) {
// Note: for this test, we need support for two versions. Which two shouldn't
// matter, but they must be enabled so that the version manager doesn't filter
// them out.
......
......@@ -12,48 +12,31 @@
// Usage: quic_packet_printer server|client <hex dump of packet>
//
// Example input:
// quic_packet_printer server 0c6b810308320f24c004a939a38a2e3fd6ca589917f200400
// 201b80b0100501c0700060003023d0000001c00556e656e637279707465642073747265616d2
// 064617461207365656e
// quic_packet_printer server 0c6b810308320f24c004a939a38a2e3fd6ca589917f200400201b80b0100501c0700060003023d0000001c00556e656e637279707465642073747265616d2064617461207365656e
//
// Example output:
// OnPacket
// OnUnauthenticatedPublicHeader
// OnUnauthenticatedHeader: { connection_id: 13845207862000976235,
// connection_id_length:8, packet_number_length:1, multipath_flag: 0,
// reset_flag: 0, version_flag: 0, path_id: , packet_number: 4}
// OnUnauthenticatedHeader: { connection_id: 13845207862000976235, connection_id_length:8, packet_number_length:1, multipath_flag: 0, reset_flag: 0, version_flag: 0, path_id: , packet_number: 4 }
// OnDecryptedPacket
// OnPacketHeader
// OnAckFrame: largest_observed: 1 ack_delay_time: 3000
// missing_packets: [ ] is_truncated: 0 received_packets: [ 1 at 466016 ]
// OnAckFrame: largest_observed: 1 ack_delay_time: 3000 missing_packets: [ ] is_truncated: 0 received_packets: [ 1 at 466016 ]
// OnStopWaitingFrame
// OnConnectionCloseFrame: error_code { 61 } error_details { Unencrypted stream
// data seen }
// OnConnectionCloseFrame: error_code { 61 } error_details { Unencrypted stream data seen }
// clang-format on
#include <iostream>
#include <string>
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "net/third_party/quic/core/quic_framer.h"
#include "net/third_party/quic/core/quic_utils.h"
#include "net/third_party/quic/platform/api/quic_flags.h"
#include "net/third_party/quic/platform/api/quic_text_utils.h"
// If set, specify the QUIC version to use.
quic::QuicString FLAGS_quic_version = "";
namespace {
quic::QuicString ArgToString(base::CommandLine::StringType arg) {
#if defined(OS_WIN)
return base::UTF16ToASCII(arg);
#else
return arg;
#endif
}
} // namespace
DEFINE_QUIC_COMMAND_LINE_FLAG(std::string,
quic_version,
"",
"If set, specify the QUIC version to use.");
namespace quic {
......@@ -224,40 +207,35 @@ class QuicPacketPrinter : public QuicFramerVisitorInterface {
} // namespace quic
int main(int argc, char* argv[]) {
base::CommandLine::Init(argc, argv);
base::CommandLine* line = base::CommandLine::ForCurrentProcess();
const base::CommandLine::StringVector& args = line->GetArgs();
const char* usage = "Usage: quic_packet_printer client|server <hex>";
std::vector<quic::QuicString> args =
quic::QuicParseCommandLineFlags(usage, argc, argv);
if (args.size() != 3) {
std::cerr << "Missing argument " << argc << ". (Usage: " << argv[0]
<< " client|server <hex>\n";
if (args.size() < 2) {
quic::QuicPrintCommandLineFlagHelp(usage);
return 1;
}
if (line->HasSwitch("quic_version")) {
FLAGS_quic_version = line->GetSwitchValueASCII("quic_version");
}
quic::QuicString perspective_string = ArgToString(args[0]);
quic::QuicString perspective_string = args[0];
quic::Perspective perspective;
if (perspective_string == "client") {
perspective = quic::Perspective::IS_CLIENT;
} else if (perspective_string == "server") {
perspective = quic::Perspective::IS_SERVER;
} else {
std::cerr << "Invalid perspective. " << perspective_string
<< " Usage: " << args[0] << " client|server <hex>\n";
std::cerr << "Invalid perspective" << std::endl;
quic::QuicPrintCommandLineFlagHelp(usage);
return 1;
}
quic::QuicString hex = quic::QuicTextUtils::HexDecode(argv[2]);
quic::QuicString hex = quic::QuicTextUtils::HexDecode(args[1]);
quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions();
// Fake a time since we're not actually generating acks.
quic::QuicTime start(quic::QuicTime::Zero());
quic::QuicFramer framer(versions, start, perspective);
if (!FLAGS_quic_version.empty()) {
if (!GetQuicFlag(FLAGS_quic_version).empty()) {
for (quic::ParsedQuicVersion version : versions) {
if (quic::QuicVersionToString(version.transport_version) ==
FLAGS_quic_version) {
GetQuicFlag(FLAGS_quic_version)) {
framer.set_version(version);
}
}
......
......@@ -7,28 +7,27 @@
#include <iostream>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "net/third_party/quic/core/crypto/crypto_handshake.h"
#include "net/third_party/quic/core/crypto/crypto_utils.h"
#include "net/third_party/quic/platform/api/quic_flags.h"
#include "net/third_party/quic/platform/api/quic_text_utils.h"
using base::CommandLine;
using quic::HandshakeFailureReason;
using quic::CryptoUtils;
using quic::HandshakeFailureReason;
using quic::MAX_FAILURE_REASON;
int main(int argc, char* argv[]) {
CommandLine::Init(argc, argv);
CommandLine* line = CommandLine::ForCurrentProcess();
const CommandLine::StringVector& args = line->GetArgs();
const char* usage = "Usage: quic_reject_reason_decoder <packed_reason>";
std::vector<quic::QuicString> args =
quic::QuicParseCommandLineFlags(usage, argc, argv);
if (args.size() != 1) {
std::cerr << "Missing argument (Usage: " << argv[0] << " <packed_reason>\n";
std::cerr << usage << std::endl;
return 1;
}
uint32_t packed_error = 0;
if (!base::StringToUint(args[0], &packed_error)) {
if (!quic::QuicTextUtils::StringToUint32(args[0], &packed_error)) {
std::cerr << "Unable to parse: " << args[0] << "\n";
return 2;
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/third_party/quic/test_tools/fake_epoll_server.h"
#include "net/tools/epoll_server/fake_epoll_server.h"
namespace quic {
namespace test {
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_THIRD_PARTY_QUIC_TEST_TOOLS_FAKE_EPOLL_SERVER_H_
#define NET_THIRD_PARTY_QUIC_TEST_TOOLS_FAKE_EPOLL_SERVER_H_
#ifndef NET_TOOLS_EPOLL_SERVER_FAKE_EPOLL_SERVER_H_
#define NET_TOOLS_EPOLL_SERVER_FAKE_EPOLL_SERVER_H_
#include <stddef.h>
#include <stdint.h>
......@@ -112,4 +112,4 @@ class FakeEpollServer : public FakeTimeEpollServer {
} // namespace test
} // namespace quic
#endif // NET_THIRD_PARTY_QUIC_TEST_TOOLS_FAKE_EPOLL_SERVER_H_
#endif // NET_TOOLS_EPOLL_SERVER_FAKE_EPOLL_SERVER_H_
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