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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the ChromeHistogramHelper Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/test/statistics_delta_reader.h" 11 #include "base/test/histogram_tester.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/ip_endpoint.h" 13 #include "net/base/ip_endpoint.h"
14 #include "net/base/net_log_unittest.h" 14 #include "net/base/net_log_unittest.h"
15 #include "net/base/request_priority.h" 15 #include "net/base/request_priority.h"
16 #include "net/base/test_data_directory.h" 16 #include "net/base/test_data_directory.h"
17 #include "net/base/test_data_stream.h" 17 #include "net/base/test_data_stream.h"
18 #include "net/socket/client_socket_pool_manager.h" 18 #include "net/socket/client_socket_pool_manager.h"
19 #include "net/socket/next_proto.h" 19 #include "net/socket/next_proto.h"
20 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
21 #include "net/spdy/spdy_http_utils.h" 21 #include "net/spdy/spdy_http_utils.h"
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 session, url, MEDIUM, BoundNetLog()); 1784 session, url, MEDIUM, BoundNetLog());
1785 test::StreamDelegateDoNothing delegate(spdy_stream); 1785 test::StreamDelegateDoNothing delegate(spdy_stream);
1786 spdy_stream->SetDelegate(&delegate); 1786 spdy_stream->SetDelegate(&delegate);
1787 1787
1788 scoped_ptr<SpdyHeaderBlock> headers( 1788 scoped_ptr<SpdyHeaderBlock> headers(
1789 spdy_util_.ConstructGetHeaderBlock(url.spec())); 1789 spdy_util_.ConstructGetHeaderBlock(url.spec()));
1790 spdy_stream->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND); 1790 spdy_stream->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND);
1791 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders()); 1791 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders());
1792 1792
1793 // Write request headers & capture resulting histogram update. 1793 // Write request headers & capture resulting histogram update.
1794 base::StatisticsDeltaReader statistics_delta_reader; 1794 base::HistogramTester histogram_tester;
1795
1795 data.RunFor(1); 1796 data.RunFor(1);
1796 scoped_ptr<base::HistogramSamples> samples(
1797 statistics_delta_reader.GetHistogramSamplesSinceCreation(
1798 "Net.SpdySynStreamCompressionPercentage"));
1799
1800 // Regression test of compression performance under the request fixture. 1797 // Regression test of compression performance under the request fixture.
1801 switch (spdy_util_.spdy_version()) { 1798 switch (spdy_util_.spdy_version()) {
1802 case SPDY2: 1799 case SPDY2:
1803 EXPECT_EQ(samples->GetCount(0), 1); 1800 histogram_tester.ExpectBucketCount(
1801 "Net.SpdySynStreamCompressionPercentage", 0, 1);
1804 break; 1802 break;
1805 case SPDY3: 1803 case SPDY3:
1806 EXPECT_EQ(samples->GetCount(30), 1); 1804 histogram_tester.ExpectBucketCount(
1805 "Net.SpdySynStreamCompressionPercentage", 30, 1);
1807 break; 1806 break;
1808 case SPDY4: 1807 case SPDY4:
1809 EXPECT_EQ(samples->GetCount(82), 1); 1808 histogram_tester.ExpectBucketCount(
1809 "Net.SpdySynStreamCompressionPercentage", 82, 1);
1810 break; 1810 break;
1811 case SPDY5: 1811 case SPDY5:
1812 EXPECT_EQ(samples->GetCount(82), 1); 1812 histogram_tester.ExpectBucketCount(
1813 "Net.SpdySynStreamCompressionPercentage", 82, 1);
1813 break; 1814 break;
1814 default: 1815 default:
1815 NOTREACHED(); 1816 NOTREACHED();
1816 } 1817 }
1817 1818
1818 // Read and process EOF. 1819 // Read and process EOF.
1819 data.RunFor(1); 1820 data.RunFor(1);
1820 base::MessageLoop::current()->RunUntilIdle(); 1821 base::MessageLoop::current()->RunUntilIdle();
1821 EXPECT_TRUE(session == NULL); 1822 EXPECT_TRUE(session == NULL);
1822 } 1823 }
(...skipping 2829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4652 CHECK_EQ(GOAWAY_PROTOCOL_ERROR, 4653 CHECK_EQ(GOAWAY_PROTOCOL_ERROR,
4653 MapNetErrorToGoAwayStatus(ERR_SPDY_PROTOCOL_ERROR)); 4654 MapNetErrorToGoAwayStatus(ERR_SPDY_PROTOCOL_ERROR));
4654 CHECK_EQ(GOAWAY_COMPRESSION_ERROR, 4655 CHECK_EQ(GOAWAY_COMPRESSION_ERROR,
4655 MapNetErrorToGoAwayStatus(ERR_SPDY_COMPRESSION_ERROR)); 4656 MapNetErrorToGoAwayStatus(ERR_SPDY_COMPRESSION_ERROR));
4656 CHECK_EQ(GOAWAY_FRAME_SIZE_ERROR, 4657 CHECK_EQ(GOAWAY_FRAME_SIZE_ERROR,
4657 MapNetErrorToGoAwayStatus(ERR_SPDY_FRAME_SIZE_ERROR)); 4658 MapNetErrorToGoAwayStatus(ERR_SPDY_FRAME_SIZE_ERROR));
4658 CHECK_EQ(GOAWAY_PROTOCOL_ERROR, MapNetErrorToGoAwayStatus(ERR_UNEXPECTED)); 4659 CHECK_EQ(GOAWAY_PROTOCOL_ERROR, MapNetErrorToGoAwayStatus(ERR_UNEXPECTED));
4659 } 4660 }
4660 4661
4661 } // namespace net 4662 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698