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

Unified Diff: chrome/browser/net/http_pipelining_compatibility_client_unittest.cc

Issue 9433015: Add a force pipelining option to load flags. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge Created 8 years, 10 months 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: chrome/browser/net/http_pipelining_compatibility_client_unittest.cc
diff --git a/chrome/browser/net/http_pipelining_compatibility_client_unittest.cc b/chrome/browser/net/http_pipelining_compatibility_client_unittest.cc
index 9e3caea0a7fe3e8e197ca32bae76e73306df1842..91608c76908785526358442edb7aa30cd7de9f12 100644
--- a/chrome/browser/net/http_pipelining_compatibility_client_unittest.cc
+++ b/chrome/browser/net/http_pipelining_compatibility_client_unittest.cc
@@ -127,13 +127,32 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
private:
base::Histogram::SampleSet GetHistogram(const char* name) {
base::Histogram::SampleSet sample;
- base::Histogram* histogram;
+ base::Histogram* current_histogram = NULL;
+ base::Histogram* cached_histogram = NULL;
+ base::StatisticsRecorder::FindHistogram(name, &current_histogram);
if (ContainsKey(histograms_, name)) {
- histogram = histograms_[name];
- histogram->SnapshotSample(&sample);
- } else if (base::StatisticsRecorder::FindHistogram(name, &histogram)) {
- histograms_[name] = histogram;
- histogram->SnapshotSample(&sample);
+ cached_histogram = histograms_[name];
+ }
+
+ // This is to work around the CACHE_HISTOGRAM_* macros caching the last used
+ // histogram by name. So, even though we throw out the StatisticsRecorder
+ // between tests, the CACHE_HISTOGRAM_* might still write into the old
+ // Histogram if it has the same name as the last run. We keep a cache of the
+ // last used Histogram and then update the cache if it's different than the
+ // current Histogram.
+ if (cached_histogram && current_histogram) {
+ cached_histogram->SnapshotSample(&sample);
+ if (cached_histogram != current_histogram) {
+ base::Histogram::SampleSet current_sample;
+ current_histogram->SnapshotSample(&current_sample);
+ sample.Add(current_sample);
+ histograms_[name] = current_histogram;
+ }
+ } else if (current_histogram) {
+ current_histogram->SnapshotSample(&sample);
+ histograms_[name] = current_histogram;
+ } else if (cached_histogram) {
+ cached_histogram->SnapshotSample(&sample);
}
return sample;
}
@@ -416,7 +435,7 @@ TEST_F(HttpPipeliningCompatibilityClientTest, MultipleRequests) {
base::Histogram::SampleSet network_sample2 =
GetHistogramValue(1, FIELD_NETWORK_ERROR);
EXPECT_EQ(1, network_sample2.TotalCount());
- EXPECT_EQ(1, network_sample2.counts(-net::ERR_EMPTY_RESPONSE));
+ EXPECT_EQ(1, network_sample2.counts(-net::ERR_PIPELINE_EVICTION));
base::Histogram::SampleSet response_sample2 =
GetHistogramValue(1, FIELD_RESPONSE_CODE);
@@ -426,16 +445,16 @@ TEST_F(HttpPipeliningCompatibilityClientTest, MultipleRequests) {
GetHistogramValue(2, FIELD_STATUS);
EXPECT_EQ(1, status_sample3.TotalCount());
EXPECT_EQ(1, status_sample3.counts(
- HttpPipeliningCompatibilityClient::BAD_RESPONSE_CODE));
+ HttpPipeliningCompatibilityClient::NETWORK_ERROR));
base::Histogram::SampleSet network_sample3 =
GetHistogramValue(2, FIELD_NETWORK_ERROR);
- EXPECT_EQ(0, network_sample3.TotalCount());
+ EXPECT_EQ(1, network_sample3.TotalCount());
+ EXPECT_EQ(1, network_sample3.counts(-net::ERR_PIPELINE_EVICTION));
base::Histogram::SampleSet response_sample3 =
GetHistogramValue(2, FIELD_RESPONSE_CODE);
- EXPECT_EQ(1, response_sample3.TotalCount());
- EXPECT_EQ(1, response_sample3.counts(401));
+ EXPECT_EQ(0, response_sample3.TotalCount());
}
} // anonymous namespace

Powered by Google App Engine
This is Rietveld 408576698