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

Side by Side Diff: net/http/http_stream_factory_impl_unittest.cc

Issue 2814473002: Move HttpStreamFactoryImpl::JobController UMA to a schedule upload (Closed)
Patch Set: add test Created 3 years, 8 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
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 histogram_tester.ExpectUniqueSample( 1311 histogram_tester.ExpectUniqueSample(
1312 "Net.PreconnectSkippedToProxyServers", 1, 1); 1312 "Net.PreconnectSkippedToProxyServers", 1, 1);
1313 } else { 1313 } else {
1314 histogram_tester.ExpectTotalCount("Net.PreconnectSkippedToProxyServers", 1314 histogram_tester.ExpectTotalCount("Net.PreconnectSkippedToProxyServers",
1315 0); 1315 0);
1316 } 1316 }
1317 } 1317 }
1318 } 1318 }
1319 } 1319 }
1320 1320
1321 TEST_F(HttpStreamFactoryTest, OnMetricsFinalizeTest) {
1322 base::HistogramTester histogram_tester;
1323 // Make the request hang.
1324 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)};
1325 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1326 SpdySessionDependencies session_deps;
1327 session_deps.socket_factory->AddSocketDataProvider(&data);
1328 HttpNetworkSession::Params params =
1329 SpdySessionDependencies::CreateSessionParams(&session_deps);
1330 std::unique_ptr<HttpNetworkSession> session(new HttpNetworkSession(params));
1331 HttpRequestInfo request_info;
1332 request_info.method = "GET";
1333 request_info.url = GURL("http://www.example.com");
1334 SSLConfig ssl_config;
1335 StreamRequestWaiter waiter;
1336 std::unique_ptr<HttpStreamRequest> request(
1337 session->http_stream_factory()->RequestStream(
1338 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter,
1339 /* enable_ip_based_pooling = */ true,
1340 /* enable_alternative_services = */ true, NetLogWithSource()));
1341 NetworkChangeNotifier::FinalizingMetricsLogRecord();
1342 // Notification is asynchronous.
1343 base::RunLoop().RunUntilIdle();
1344 // There are two HttpStreamFactoryImpl in HttpNetworkSession
1345 // (|http_stream_factory_| and |http_stream_factory_for_websocket_|), so there
1346 // will be two samples logged per FinalizingMetricsLogRecord().
1347 histogram_tester.ExpectBucketCount("Net.JobControllerSet.CountOfPreconnect",
1348 0, 2);
1349 histogram_tester.ExpectBucketCount(
1350 "Net.JobControllerSet.CountOfNonPreconnectAltJob", 0, 2);
1351 histogram_tester.ExpectBucketCount(
1352 "Net.JobControllerSet.CountOfNonPreconnectMainJob", 0, 1);
1353 // HttpNetworkSession's |http_stream_factory_| reports 1 count to 1 bucket.
1354 histogram_tester.ExpectBucketCount(
1355 "Net.JobControllerSet.CountOfNonPreconnectMainJob", 1, 1);
1356 }
1357
1321 // Verify that preconnect to a HTTP2 proxy server with a privacy mode different 1358 // Verify that preconnect to a HTTP2 proxy server with a privacy mode different
1322 // than that of the in-flight preconnect job succeeds. 1359 // than that of the in-flight preconnect job succeeds.
1323 TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) { 1360 TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) {
1324 int num_streams = 1; 1361 int num_streams = 1;
1325 base::HistogramTester histogram_tester; 1362 base::HistogramTester histogram_tester;
1326 GURL url = GURL("http://www.google.com"); 1363 GURL url = GURL("http://www.google.com");
1327 std::unique_ptr<ProxyService> proxy_service = 1364 std::unique_ptr<ProxyService> proxy_service =
1328 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); 1365 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443");
1329 1366
1330 // Set up the proxy server as a server that supports request priorities. 1367 // Set up the proxy server as a server that supports request priorities.
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 session->GetTransportSocketPool( 2800 session->GetTransportSocketPool(
2764 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 2801 HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
2765 EXPECT_EQ(1, GetSocketPoolGroupCount( 2802 EXPECT_EQ(1, GetSocketPoolGroupCount(
2766 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 2803 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
2767 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 2804 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
2768 } 2805 }
2769 2806
2770 } // namespace 2807 } // namespace
2771 2808
2772 } // namespace net 2809 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698