diff options
Diffstat (limited to 'chromium/net/quic/platform/impl')
7 files changed, 84 insertions, 17 deletions
diff --git a/chromium/net/quic/platform/impl/quic_logging_impl.h b/chromium/net/quic/platform/impl/quic_logging_impl.h index 37aa990b365..fb9add316fb 100644 --- a/chromium/net/quic/platform/impl/quic_logging_impl.h +++ b/chromium/net/quic/platform/impl/quic_logging_impl.h @@ -42,6 +42,8 @@ #define QUIC_CHROMIUM_DLOG_IF_DFATAL(condition) DLOG_IF(DFATAL, condition) #define QUIC_DVLOG_IMPL(verbose_level) DVLOG(verbose_level) +#define QUIC_DVLOG_IF_IMPL(verbose_level, condition) \ + DVLOG_IF(verbose_level, condition) #if defined(OS_WIN) // wingdi.h defines ERROR to be 0. When we call QUIC_DLOG(ERROR), it gets diff --git a/chromium/net/quic/platform/impl/quic_mem_slice_impl.cc b/chromium/net/quic/platform/impl/quic_mem_slice_impl.cc index 5fdeb24a408..e82fcf1493c 100644 --- a/chromium/net/quic/platform/impl/quic_mem_slice_impl.cc +++ b/chromium/net/quic/platform/impl/quic_mem_slice_impl.cc @@ -34,6 +34,11 @@ QuicMemSliceImpl& QuicMemSliceImpl::operator=(QuicMemSliceImpl&& other) { QuicMemSliceImpl::~QuicMemSliceImpl() = default; +void QuicMemSliceImpl::Reset() { + io_buffer_ = nullptr; + length_ = 0; +} + const char* QuicMemSliceImpl::data() const { if (io_buffer_ == nullptr) { return nullptr; diff --git a/chromium/net/quic/platform/impl/quic_mem_slice_impl.h b/chromium/net/quic/platform/impl/quic_mem_slice_impl.h index 43b9aad460a..1acf9f7b3f9 100644 --- a/chromium/net/quic/platform/impl/quic_mem_slice_impl.h +++ b/chromium/net/quic/platform/impl/quic_mem_slice_impl.h @@ -34,6 +34,10 @@ class QUIC_EXPORT_PRIVATE QuicMemSliceImpl { ~QuicMemSliceImpl(); + // Release the underlying reference. Further access the memory will result in + // undefined behavior. + void Reset(); + // Returns a char pointer to underlying data buffer. const char* data() const; // Returns the length of underlying data buffer. diff --git a/chromium/net/quic/platform/impl/quic_singleton_impl.h b/chromium/net/quic/platform/impl/quic_singleton_impl.h new file mode 100644 index 00000000000..9c02071cc53 --- /dev/null +++ b/chromium/net/quic/platform/impl/quic_singleton_impl.h @@ -0,0 +1,20 @@ +// Copyright (c) 2018 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_QUIC_PLATFORM_IMPL_QUIC_SINGLETON_IMPL_H_ +#define NET_QUIC_PLATFORM_IMPL_QUIC_SINGLETON_IMPL_H_ + +#include "base/memory/singleton.h" + +namespace net { + +template <typename T> +using QuicSingletonImpl = base::Singleton<T, base::DefaultSingletonTraits<T>>; + +template <typename T> +using QuicSingletonFriendImpl = base::DefaultSingletonTraits<T>; + +} // namespace net + +#endif // NET_QUIC_PLATFORM_IMPL_QUIC_SINGLETON_IMPL_H_ diff --git a/chromium/net/quic/platform/impl/quic_test_impl.cc b/chromium/net/quic/platform/impl/quic_test_impl.cc index dc1709b2856..6e22a9f5922 100644 --- a/chromium/net/quic/platform/impl/quic_test_impl.cc +++ b/chromium/net/quic/platform/impl/quic_test_impl.cc @@ -4,20 +4,14 @@ #include "net/quic/platform/impl/quic_test_impl.h" -#include "base/logging.h" -#include "net/quic/platform/api/quic_flags.h" - -QuicFlagSaver::QuicFlagSaver() { -#define QUIC_FLAG(type, flag, value) \ - CHECK_EQ(value, flag) \ - << "Flag set to an unexpected value. A prior test is likely " \ - << "setting a flag without using a QuicFlagSaver"; +QuicFlagSaverImpl::QuicFlagSaverImpl() { +#define QUIC_FLAG(type, flag, value) saved_##flag##_ = flag; #include "net/quic/core/quic_flags_list.h" #undef QUIC_FLAG } -QuicFlagSaver::~QuicFlagSaver() { -#define QUIC_FLAG(type, flag, value) flag = value; +QuicFlagSaverImpl::~QuicFlagSaverImpl() { +#define QUIC_FLAG(type, flag, value) flag = saved_##flag##_; #include "net/quic/core/quic_flags_list.h" #undef QUIC_FLAG } diff --git a/chromium/net/quic/platform/impl/quic_test_impl.h b/chromium/net/quic/platform/impl/quic_test_impl.h index 6be16527516..98ae8760cc2 100644 --- a/chromium/net/quic/platform/impl/quic_test_impl.h +++ b/chromium/net/quic/platform/impl/quic_test_impl.h @@ -5,26 +5,49 @@ #ifndef NET_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_ #define NET_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_ +#include "base/logging.h" +#include "net/quic/platform/api/quic_flags.h" #include "testing/gmock/include/gmock/gmock.h" // IWYU pragma: export #include "testing/gtest/include/gtest/gtest.h" // IWYU pragma: export -// When constructed, checks that all QUIC flags have their correct default -// values and when destructed, restores those values. -class QuicFlagSaver { +// When constructed, saves the current values of all QUIC flags. When +// destructed, restores all QUIC flags to the saved values. +class QuicFlagSaverImpl { public: - QuicFlagSaver(); - ~QuicFlagSaver(); + QuicFlagSaverImpl(); + ~QuicFlagSaverImpl(); + + private: +#define QUIC_FLAG(type, flag, value) type saved_##flag##_; +#include "net/quic/core/quic_flags_list.h" +#undef QUIC_FLAG +}; + +// Checks if all QUIC flags are on their default values on construction. +class QuicFlagChecker { + public: + QuicFlagChecker() { +#define QUIC_FLAG(type, flag, value) \ + CHECK_EQ(value, flag) \ + << "Flag set to an unexpected value. A prior test is likely " \ + << "setting a flag without using a QuicFlagSaver. Use QuicTest to " \ + "avoid this issue."; +#include "net/quic/core/quic_flags_list.h" +#undef QUIC_FLAG + } }; class QuicTestImpl : public ::testing::Test { private: - QuicFlagSaver flags_; // Save/restore all QUIC flag values. + QuicFlagChecker checker_; + QuicFlagSaverImpl saver_; // Save/restore all QUIC flag values. }; template <class T> class QuicTestWithParamImpl : public ::testing::TestWithParam<T> { private: - QuicFlagSaver flags_; // Save/restore all QUIC flag values. + QuicFlagChecker checker_; + QuicFlagSaverImpl saver_; // Save/restore all QUIC flag values. }; #endif // NET_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_ diff --git a/chromium/net/quic/platform/impl/quic_uint128_impl.h b/chromium/net/quic/platform/impl/quic_uint128_impl.h new file mode 100644 index 00000000000..cad9a6eea7d --- /dev/null +++ b/chromium/net/quic/platform/impl/quic_uint128_impl.h @@ -0,0 +1,19 @@ +// Copyright 2018 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_QUIC_PLATFORM_IMPL_QUIC_UINT128_IMPL_H_ +#define NET_QUIC_PLATFORM_IMPL_QUIC_UINT128_IMPL_H_ + +#include "net/base/int128.h" + +namespace net { + +using QuicUint128Impl = uint128; +#define MakeQuicUint128Impl(hi, lo) MakeUint128(hi, lo) +#define QuicUint128Low64Impl(x) Uint128Low64(x); +#define QuicUint128High64Impl(x) Uint128High64(x); + +} // namespace net + +#endif // NET_QUIC_PLATFORM_IMPL_QUIC_UINT128_IMPL_H_ |