OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 5 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 FilePath(FILE_PATH_LITERAL("chrome/test/data/http_pipelining"))), | 87 FilePath(FILE_PATH_LITERAL("chrome/test/data/http_pipelining"))), |
88 io_thread_(BrowserThread::IO, &message_loop_) { | 88 io_thread_(BrowserThread::IO, &message_loop_) { |
89 } | 89 } |
90 | 90 |
91 protected: | 91 protected: |
92 virtual void SetUp() OVERRIDE { | 92 virtual void SetUp() OVERRIDE { |
93 // Start up a histogram recorder. | 93 // Start up a histogram recorder. |
94 // TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions. | 94 // TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions. |
95 base::StatisticsRecorder::Initialize(); | 95 base::StatisticsRecorder::Initialize(); |
96 ASSERT_TRUE(test_server_.Start()); | 96 ASSERT_TRUE(test_server_.Start()); |
97 context_ = new TestURLRequestContextGetter( | 97 context_ = new net::TestURLRequestContextGetter( |
98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
99 context_->AddRef(); | 99 context_->AddRef(); |
100 | 100 |
101 for (size_t i = 0; i < arraysize(kHistogramNames); ++i) { | 101 for (size_t i = 0; i < arraysize(kHistogramNames); ++i) { |
102 const char* name = kHistogramNames[i]; | 102 const char* name = kHistogramNames[i]; |
103 scoped_ptr<HistogramSamples> samples = GetHistogram(name); | 103 scoped_ptr<HistogramSamples> samples = GetHistogram(name); |
104 if (samples.get() && samples->TotalCount() > 0) { | 104 if (samples.get() && samples->TotalCount() > 0) { |
105 original_samples_[name] = samples.release(); | 105 original_samples_[name] = samples.release(); |
106 } | 106 } |
107 } | 107 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 EXPECT_EQ(expected_count, samples->TotalCount()) << name; | 199 EXPECT_EQ(expected_count, samples->TotalCount()) << name; |
200 if (expected_count > 0) { | 200 if (expected_count > 0) { |
201 EXPECT_EQ(expected_count, samples->GetCount(expected_value)) << name; | 201 EXPECT_EQ(expected_count, samples->GetCount(expected_value)) << name; |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 MessageLoopForIO message_loop_; | 205 MessageLoopForIO message_loop_; |
206 net::TestServer test_server_; | 206 net::TestServer test_server_; |
207 TestURLRequestContextGetter* context_; | 207 net::TestURLRequestContextGetter* context_; |
208 content::TestBrowserThread io_thread_; | 208 content::TestBrowserThread io_thread_; |
209 | 209 |
210 private: | 210 private: |
211 scoped_ptr<HistogramSamples> GetHistogram(const char* name) { | 211 scoped_ptr<HistogramSamples> GetHistogram(const char* name) { |
212 scoped_ptr<HistogramSamples> samples; | 212 scoped_ptr<HistogramSamples> samples; |
213 Histogram* cached_histogram = NULL; | 213 Histogram* cached_histogram = NULL; |
214 Histogram* current_histogram = | 214 Histogram* current_histogram = |
215 base::StatisticsRecorder::FindHistogram(name); | 215 base::StatisticsRecorder::FindHistogram(name); |
216 if (ContainsKey(histograms_, name)) { | 216 if (ContainsKey(histograms_, name)) { |
217 cached_histogram = histograms_[name]; | 217 cached_histogram = histograms_[name]; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 callback.WaitForResult(); | 586 callback.WaitForResult(); |
587 | 587 |
588 ExpectHistogramCount(1, false, FIELD_CANARY); | 588 ExpectHistogramCount(1, false, FIELD_CANARY); |
589 ExpectHistogramCount(0, false, FIELD_SUCCESS); | 589 ExpectHistogramCount(0, false, FIELD_SUCCESS); |
590 ExpectHistogramCount(0, true, FIELD_SUCCESS); | 590 ExpectHistogramCount(0, true, FIELD_SUCCESS); |
591 } | 591 } |
592 | 592 |
593 } // anonymous namespace | 593 } // anonymous namespace |
594 | 594 |
595 } // namespace chrome_browser_net | 595 } // namespace chrome_browser_net |
OLD | NEW |