Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: net/nqe/observation_buffer_unittest.cc

Issue 2453653002: Separate out observation sources as either HTTP layer or transport layer (Closed)
Patch Set: ps Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/nqe/observation_buffer_unittest.cc
diff --git a/net/nqe/observation_buffer_unittest.cc b/net/nqe/observation_buffer_unittest.cc
index 501c074c56354ae3a2445d6dbe3b831120a7ca55..812bd60856593affeea94d6898d2fe6fac15313b 100644
--- a/net/nqe/observation_buffer_unittest.cc
+++ b/net/nqe/observation_buffer_unittest.cc
@@ -33,8 +33,8 @@ TEST(NetworkQualityObservationBufferTest, BoundedBuffer) {
const base::TimeTicks now =
base::TimeTicks() + base::TimeDelta::FromSeconds(1);
for (int i = 1; i <= 1000; ++i) {
- observation_buffer.AddObservation(
- Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP));
+ observation_buffer.AddObservation(Observation<int32_t>(
+ i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
// The number of entries should be at most the maximum buffer size.
EXPECT_GE(300u, observation_buffer.Size());
}
@@ -56,8 +56,9 @@ TEST(NetworkQualityObservationBufferTest, GetPercentileWithWeights) {
const base::TimeTicks now = tick_clock_ptr->NowTicks();
for (int i = 1; i <= 100; ++i) {
tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1));
- observation_buffer.AddObservation(Observation<int32_t>(
- i, tick_clock_ptr->NowTicks(), NETWORK_QUALITY_OBSERVATION_SOURCE_TCP));
+ observation_buffer.AddObservation(
+ Observation<int32_t>(i, tick_clock_ptr->NowTicks(),
+ NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
}
EXPECT_EQ(100U, observation_buffer.Size());
@@ -110,11 +111,11 @@ TEST(NetworkQualityObservationBufferTest, PercentileSameTimestamps) {
// Insert samples from {1,2,3,..., 100}. First insert odd samples, then even
// samples. This helps in verifying that the order of samples does not matter.
for (int i = 1; i <= 99; i += 2) {
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
EXPECT_TRUE(int_buffer.GetPercentile(
base::TimeTicks(), &result, 50,
std::vector<NetworkQualityObservationSource>()));
@@ -126,11 +127,11 @@ TEST(NetworkQualityObservationBufferTest, PercentileSameTimestamps) {
}
for (int i = 2; i <= 100; i += 2) {
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
EXPECT_TRUE(int_buffer.GetPercentile(
base::TimeTicks(), &result, 50,
std::vector<NetworkQualityObservationSource>()));
@@ -201,19 +202,19 @@ TEST(NetworkQualityObservationBufferTest, PercentileDifferentTimestamps) {
// First 50 samples have very old timestamps.
for (int i = 1; i <= 50; ++i) {
int_buffer.AddObservation(Observation<int32_t>(
- i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
base::TimeDelta::FromMilliseconds(i), very_old,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// Next 50 (i.e., from 51 to 100) have recent timestamps.
for (int i = 51; i <= 100; ++i) {
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// Older samples have very little weight. So, all percentiles are >= 51
@@ -269,18 +270,18 @@ TEST(NetworkQualityObservationBufferTest,
for (int i = 1; i <= 50; ++i) {
time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
base::TimeDelta::FromMilliseconds(i), very_old,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
int_buffer.AddObservation(Observation<int32_t>(
- i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// The next 50 (i.e., from 51 to 100) samples have recent timestamps.
for (int i = 51; i <= 100; ++i) {
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// All samples have equal weight. So, the unweighted average is the average of
@@ -323,18 +324,18 @@ TEST(NetworkQualityObservationBufferTest, WeightedAverageDifferentTimestamps) {
for (int i = 1; i <= 50; ++i) {
time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
base::TimeDelta::FromMilliseconds(i), very_old,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
int_buffer.AddObservation(Observation<int32_t>(
- i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ i, very_old, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// The next 50 (i.e., from 51 to 100) samples have recent timestamps.
for (int i = 51; i <= 100; ++i) {
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// The older samples have very little weight, and so the weighted average must
@@ -378,41 +379,39 @@ TEST(NetworkQualityObservationBufferTest, DisallowedObservationSources) {
// Insert samples from {1,2,3,..., 100}. First insert odd samples, then even
// samples. This helps in verifying that the order of samples does not matter.
for (int i = 1; i <= 99; i += 2) {
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
// Add samples for TCP and QUIC observations which should not be taken into
// account when computing the percentile.
for (int i = 1; i <= 99; i += 2) {
int_buffer.AddObservation(Observation<int32_t>(
- 10000, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP));
+ 10000, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
int_buffer.AddObservation(Observation<int32_t>(
- 10000, now, NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC));
+ 10000, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
base::TimeDelta::FromMilliseconds(10000), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_TCP));
+ NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
base::TimeDelta::FromMilliseconds(10000), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC));
+ NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT));
}
for (int i = 2; i <= 100; i += 2) {
- int_buffer.AddObservation(Observation<int32_t>(
- i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(i), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(i, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(i), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
}
std::vector<NetworkQualityObservationSource> disallowed_observation_sources;
disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_TCP);
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC);
+ NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT);
for (int i = 0; i <= 100; ++i) {
// Checks if the difference between the two integers is less than 1. This is
@@ -431,7 +430,7 @@ TEST(NetworkQualityObservationBufferTest, DisallowedObservationSources) {
// Now check the percentile value for TCP and QUIC observations.
disallowed_observation_sources.clear();
disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST);
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP);
for (int i = 0; i <= 100; ++i) {
// Checks if the difference between the two integers is less than 1. This is
// required because computed percentiles may be slightly different from
@@ -455,17 +454,17 @@ TEST(NetworkQualityObservationBufferTest, TestGetMedianRTTSince) {
ASSERT_NE(old, now);
// First sample has very old timestamp.
- int_buffer.AddObservation(Observation<int32_t>(
- 1, old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(1), old,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
-
- int_buffer.AddObservation(Observation<int32_t>(
- 100, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
- time_delta_buffer.AddObservation(Observation<base::TimeDelta>(
- base::TimeDelta::FromMilliseconds(100), now,
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST));
+ int_buffer.AddObservation(
+ Observation<int32_t>(1, old, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(1), old,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+
+ int_buffer.AddObservation(
+ Observation<int32_t>(100, now, NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
+ time_delta_buffer.AddObservation(
+ Observation<base::TimeDelta>(base::TimeDelta::FromMilliseconds(100), now,
+ NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP));
const struct {
base::TimeTicks start_timestamp;
« net/nqe/network_quality_observation_source.h ('K') | « net/nqe/network_quality_observation_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698