Move quic_client_stats to quiche/common/platform/default.
Also break up quic_exported_stats for clarity, and leave a quic_client_stats API
behind that points to quiche/common/platform/api/quiche_client_stats (because
there are too many callers to migrate them all in this CL, besides server stats
should probably be moved and migrated at the same time).
PiperOrigin-RevId: 434909766
diff --git a/common/platform/api/quiche_client_stats.h b/common/platform/api/quiche_client_stats.h
new file mode 100644
index 0000000..5b1b08c
--- /dev/null
+++ b/common/platform/api/quiche_client_stats.h
@@ -0,0 +1,88 @@
+// 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 QUICHE_COMMON_PLATFORM_API_QUICHE_CLIENT_STATS_H_
+#define QUICHE_COMMON_PLATFORM_API_QUICHE_CLIENT_STATS_H_
+
+#include <string>
+
+#include "quiche_platform_impl/quiche_client_stats_impl.h"
+
+namespace quiche {
+
+//------------------------------------------------------------------------------
+// Enumeration histograms.
+//
+// Sample usage:
+// // In Chrome, these values are persisted to logs. Entries should not be
+// // renumbered and numeric values should never be reused.
+// enum class MyEnum {
+// FIRST_VALUE = 0,
+// SECOND_VALUE = 1,
+// ...
+// FINAL_VALUE = N,
+// COUNT
+// };
+// QUICHE_CLIENT_HISTOGRAM_ENUM("My.Enumeration", MyEnum::SOME_VALUE,
+// MyEnum::COUNT, "Number of time $foo equals to some enum value");
+//
+// Note: The value in |sample| must be strictly less than |enum_size|.
+
+#define QUICHE_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
+ QUICHE_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring)
+
+//------------------------------------------------------------------------------
+// Histogram for boolean values.
+
+// Sample usage:
+// QUICHE_CLIENT_HISTOGRAM_BOOL("My.Boolean", bool,
+// "Number of times $foo is true or false");
+#define QUICHE_CLIENT_HISTOGRAM_BOOL(name, sample, docstring) \
+ QUICHE_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring)
+
+//------------------------------------------------------------------------------
+// Timing histograms. These are used for collecting timing data (generally
+// latencies).
+
+// These macros create exponentially sized histograms (lengths of the bucket
+// ranges exponentially increase as the sample range increases). The units for
+// sample and max are unspecified, but they must be the same for one histogram.
+
+// Sample usage:
+// QUICHE_CLIENT_HISTOGRAM_TIMES("Very.Long.Timing.Histogram", time_delta,
+// QuicTime::Delta::FromSeconds(1), QuicTime::Delta::FromSecond(3600 *
+// 24), 100, "Time spent in doing operation.");
+#define QUICHE_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
+ docstring) \
+ QUICHE_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
+ docstring)
+
+//------------------------------------------------------------------------------
+// Count histograms. These are used for collecting numeric data.
+
+// These macros default to exponential histograms - i.e. the lengths of the
+// bucket ranges exponentially increase as the sample range increases.
+
+// All of these macros must be called with |name| as a runtime constant.
+
+// Any data outside the range here will be put in underflow and overflow
+// buckets. Min values should be >=1 as emitted 0s will still go into the
+// underflow bucket.
+
+// Sample usage:
+// UMA_CLIENT_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000, 100,
+// "Counters of hitting certain code.");
+
+#define QUICHE_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
+ docstring) \
+ QUICHE_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
+ docstring)
+
+inline void QuicheClientSparseHistogram(const std::string& name, int sample) {
+ QuicheClientSparseHistogramImpl(name, sample);
+}
+
+} // namespace quiche
+
+#endif // QUICHE_COMMON_PLATFORM_API_QUICHE_CLIENT_STATS_H_
diff --git a/common/platform/default/quiche_platform_impl/quiche_client_stats_impl.h b/common/platform/default/quiche_platform_impl/quiche_client_stats_impl.h
new file mode 100644
index 0000000..fde75f7
--- /dev/null
+++ b/common/platform/default/quiche_platform_impl/quiche_client_stats_impl.h
@@ -0,0 +1,44 @@
+// Copyright 2022 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 QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_CLIENT_STATS_IMPL_H_
+#define QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_CLIENT_STATS_IMPL_H_
+
+#include <string>
+
+namespace quiche {
+
+// Use namespace qualifier in case the macro is used outside the quiche
+// namespace.
+
+#define QUICHE_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) \
+ do { \
+ quiche::QuicheClientSparseHistogramImpl(name, static_cast<int>(sample)); \
+ } while (0)
+
+#define QUICHE_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring) \
+ do { \
+ (void)sample; /* Workaround for -Wunused-variable. */ \
+ } while (0)
+
+#define QUICHE_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, \
+ num_buckets, docstring) \
+ do { \
+ (void)sample; /* Workaround for -Wunused-variable. */ \
+ } while (0)
+
+#define QUICHE_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, \
+ num_buckets, docstring) \
+ do { \
+ quiche::QuicheClientSparseHistogramImpl(name, sample); \
+ } while (0)
+
+inline void QuicheClientSparseHistogramImpl(const std::string& /*name*/,
+ int /*sample*/) {
+ // No-op.
+}
+
+} // namespace quiche
+
+#endif // QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_CLIENT_STATS_IMPL_H_
diff --git a/quic/platform/api/quic_client_stats.h b/quic/platform/api/quic_client_stats.h
index b780ba6..2f29cd9 100644
--- a/quic/platform/api/quic_client_stats.h
+++ b/quic/platform/api/quic_client_stats.h
@@ -6,7 +6,8 @@
#define QUICHE_QUIC_PLATFORM_API_QUIC_CLIENT_STATS_H_
#include <string>
-#include "net/quic/platform/impl/quic_client_stats_impl.h"
+
+#include "common/platform/api/quiche_client_stats.h"
namespace quic {
@@ -29,7 +30,7 @@
// Note: The value in |sample| must be strictly less than |enum_size|.
#define QUIC_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
- QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring)
+ QUICHE_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring)
//------------------------------------------------------------------------------
// Histogram for boolean values.
@@ -38,7 +39,7 @@
// QUIC_CLIENT_HISTOGRAM_BOOL("My.Boolean", bool,
// "Number of times $foo is true or false");
#define QUIC_CLIENT_HISTOGRAM_BOOL(name, sample, docstring) \
- QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring)
+ QUICHE_CLIENT_HISTOGRAM_BOOL(name, sample, docstring)
//------------------------------------------------------------------------------
// Timing histograms. These are used for collecting timing data (generally
@@ -54,8 +55,7 @@
// 24), 100, "Time spent in doing operation.");
#define QUIC_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
docstring) \
- QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
- docstring)
+ QUICHE_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, docstring)
//------------------------------------------------------------------------------
// Count histograms. These are used for collecting numeric data.
@@ -75,11 +75,11 @@
#define QUIC_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
docstring) \
- QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
- docstring)
+ QUICHE_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
+ docstring)
inline void QuicClientSparseHistogram(const std::string& name, int sample) {
- QuicClientSparseHistogramImpl(name, sample);
+ quiche::QuicheClientSparseHistogram(name, sample);
}
} // namespace quic
diff --git a/quic/platform/api/quic_exported_stats.h b/quic/platform/api/quic_exported_stats.h
index 28c82ec..d2d0d4a 100644
--- a/quic/platform/api/quic_exported_stats.h
+++ b/quic/platform/api/quic_exported_stats.h
@@ -5,8 +5,8 @@
#ifndef QUICHE_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_
#define QUICHE_QUIC_PLATFORM_API_QUIC_EXPORTED_STATS_H_
-#include "net/quic/platform/impl/quic_client_stats_impl.h"
-#include "net/quic/platform/impl/quic_server_stats_impl.h"
+#include "quic/platform/api/quic_client_stats.h"
+#include "quic/platform/api/quic_server_stats.h"
namespace quic {
@@ -30,10 +30,10 @@
//
// Note: The value in |sample| must be strictly less than |enum_size|.
-#define QUIC_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
- do { \
- QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring); \
- QUIC_SERVER_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring); \
+#define QUIC_HISTOGRAM_ENUM(name, sample, enum_size, docstring) \
+ do { \
+ QUIC_CLIENT_HISTOGRAM_ENUM(name, sample, enum_size, docstring); \
+ QUIC_SERVER_HISTOGRAM_ENUM(name, sample, enum_size, docstring); \
} while (0)
//------------------------------------------------------------------------------
@@ -42,10 +42,10 @@
// Sample usage:
// QUIC_HISTOGRAM_BOOL("My.Boolean", bool,
// "Number of times $foo is true or false");
-#define QUIC_HISTOGRAM_BOOL(name, sample, docstring) \
- do { \
- QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring); \
- QUIC_SERVER_HISTOGRAM_BOOL_IMPL(name, sample, docstring); \
+#define QUIC_HISTOGRAM_BOOL(name, sample, docstring) \
+ do { \
+ QUIC_CLIENT_HISTOGRAM_BOOL(name, sample, docstring); \
+ QUIC_SERVER_HISTOGRAM_BOOL(name, sample, docstring); \
} while (0)
//------------------------------------------------------------------------------
@@ -63,10 +63,10 @@
#define QUIC_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, docstring) \
do { \
- QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
- docstring); \
- QUIC_SERVER_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
- docstring); \
+ QUIC_CLIENT_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
+ docstring); \
+ QUIC_SERVER_HISTOGRAM_TIMES(name, sample, min, max, bucket_count, \
+ docstring); \
} while (0)
//------------------------------------------------------------------------------
@@ -85,10 +85,10 @@
#define QUIC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, docstring) \
do { \
- QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
- docstring); \
- QUIC_SERVER_HISTOGRAM_COUNTS_IMPL(name, sample, min, max, bucket_count, \
- docstring); \
+ QUIC_CLIENT_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
+ docstring); \
+ QUIC_SERVER_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count, \
+ docstring); \
} while (0)
} // namespace quic