Commit 06ca96a9 authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

Use more Abseil features in QUICHE.

This switches all QUICHE container aliases to the appropriate type
of hash map, switches optional to absl::optional, and also changes
some of the macros.

Bug: 1128392
Change-Id: I47384d899c509170cd8d46208ee6a7eeac78d59b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416945Reviewed-by: default avatarDavid Schinazi <dschinazi@chromium.org>
Reviewed-by: default avatarMirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808332}
parent ab56f417
include_rules = [
# This is a temporary rule to simplify migrating QUICHE to using Abseil
# directly.
# TODO(b/166325009): remove this rule.
"+third_party/abseil-cpp/absl/base",
"+third_party/abseil-cpp/absl/container",
]
......@@ -5,6 +5,8 @@
#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_ALIGNED_IMPL_H_
#define NET_QUIC_PLATFORM_IMPL_QUIC_ALIGNED_IMPL_H_
#include "third_party/abseil-cpp/absl/base/optimization.h"
#ifdef _MSC_VER
// MSVC 2013 and prior don't have alignof or aligned(); they have __alignof and
// a __declspec instead.
......@@ -15,9 +17,7 @@
#define QUIC_ALIGNED_IMPL(X) __attribute__((aligned(X)))
#endif // _MSC_VER
// TODO(rtenneti): Change the default 64 alignas value (used the default
// value from ABSL_CACHELINE_SIZE).
#define QUIC_CACHELINE_SIZE_IMPL (64)
#define QUIC_CACHELINE_ALIGNED_IMPL ALIGNAS(QUIC_CACHELINE_SIZE)
#define QUIC_CACHELINE_SIZE_IMPL ABSL_CACHELINE_SIZE
#define QUIC_CACHELINE_ALIGNED_IMPL ABSL_CACHELINE_ALIGNED
#endif // NET_QUIC_PLATFORM_IMPL_QUIC_ALIGNED_IMPL_H_
......@@ -13,38 +13,29 @@
#include "base/containers/small_map.h"
#include "net/third_party/quiche/src/common/simple_linked_hash_map.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
#include "third_party/abseil-cpp/absl/container/node_hash_map.h"
#include "third_party/abseil-cpp/absl/container/node_hash_set.h"
namespace quic {
// The default hasher used by hash tables.
template <typename Key>
using QuicDefaultHasherImpl = std::hash<Key>;
using QuicDefaultHasherImpl = absl::Hash<Key>;
// TODO(mpw): s/std::unordered_map/gtl::node_hash_map/ once node_hash_map is
// PG3-compatible.
template <typename Key,
typename Value,
typename Hash,
typename Eq =
typename std::unordered_map<Key, Value, Hash>::key_equal,
typename Alloc =
typename std::unordered_map<Key, Value, Hash>::allocator_type>
using QuicUnorderedMapImpl = std::unordered_map<Key, Value, Hash, Eq, Alloc>;
template <typename Key, typename Value, typename Hash>
using QuicUnorderedMapImpl = absl::node_hash_map<Key, Value, Hash>;
template <typename Key, typename Value, typename Hash>
using QuicHashMapImpl = std::unordered_map<Key, Value, Hash>;
using QuicHashMapImpl = absl::flat_hash_map<Key, Value, Hash>;
// TODO(mpw): s/std::unordered_set/gtl::node_hash_set/ once node_hash_set is
// PG3-compatible.
template <typename Key,
typename Hash,
typename Eq = typename std::unordered_set<Key, Hash>::key_equal,
typename Alloc =
typename std::unordered_set<Key, Hash>::allocator_type>
using QuicUnorderedSetImpl = std::unordered_set<Key, Hash, Eq, Alloc>;
template <typename Key, typename Hash>
using QuicUnorderedSetImpl = absl::node_hash_set<Key, Hash>;
template <typename Key, typename Hash>
using QuicHashSetImpl = std::unordered_set<Key, Hash>;
using QuicHashSetImpl = absl::flat_hash_set<Key, Hash>;
// A map which offers insertion-ordered iteration.
template <typename Key, typename Value, typename Hash>
......
......@@ -2,7 +2,9 @@ include_rules = [
# This is a temporary rule to simplify migrating QUICHE to using Abseil
# directly.
# TODO(b/166325009): remove this rule.
"+third_party/abseil-cpp/absl/base/macros.h",
"+third_party/abseil-cpp/absl/container/node_hash_map.h",
"+third_party/abseil-cpp/absl/hash/hash.h",
"+third_party/abseil-cpp/absl/strings",
"+third_party/abseil-cpp/absl/types/optional.h",
]
......@@ -5,8 +5,8 @@
#ifndef NET_QUICHE_COMMON_PLATFORM_IMPL_QUICHE_ARRAYSIZE_IMPL_H_
#define NET_QUICHE_COMMON_PLATFORM_IMPL_QUICHE_ARRAYSIZE_IMPL_H_
#include "base/stl_util.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#define QUICHE_ARRAYSIZE_IMPL(x) base::size(x)
#define QUICHE_ARRAYSIZE_IMPL(x) ABSL_ARRAYSIZE(x)
#endif // NET_QUICHE_COMMON_PLATFORM_IMPL_QUICHE_ARRAYSIZE_IMPL_H_
......@@ -5,14 +5,14 @@
#ifndef NET_QUICHE_COMMON_PLATFORM_IMPL_QUICHE_OPTIONAL_IMPL_H_
#define NET_QUICHE_COMMON_PLATFORM_IMPL_QUICHE_OPTIONAL_IMPL_H_
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace quiche {
template <typename T>
using QuicheOptionalImpl = base::Optional<T>;
using QuicheOptionalImpl = absl::optional<T>;
#define QUICHE_NULLOPT_IMPL base::nullopt
#define QUICHE_NULLOPT_IMPL absl::nullopt
} // namespace quiche
......
......@@ -22,7 +22,7 @@ QuicheOptional<int64_t> QuicheUtcDateTimeToUnixSecondsInner(int year,
};
base::Time time;
if (!base::Time::FromUTCExploded(exploded, &time)) {
return base::nullopt;
return absl::nullopt;
}
return (time - base::Time::UnixEpoch()).InSeconds();
}
......@@ -38,7 +38,7 @@ QuicheOptional<int64_t> QuicheUtcDateTimeToUnixSecondsImpl(int year,
auto previous_second = QuicheUtcDateTimeToUnixSecondsInner(
year, month, day, hour, minute, second - 1);
if (!previous_second.has_value()) {
return base::nullopt;
return absl::nullopt;
}
return *previous_second + 1;
}
......
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