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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl_unittest.cc
diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc
index 2ac222bf871e07b90806434a483ab563b5b75e3a..16cb984805bd791323e47fcb26ea0a454d807620 100644
--- a/net/http/http_stream_factory_impl_unittest.cc
+++ b/net/http/http_stream_factory_impl_unittest.cc
@@ -1318,6 +1318,43 @@ TEST_F(HttpStreamFactoryTest, OnlyOnePreconnectToProxyServer) {
}
}
+TEST_F(HttpStreamFactoryTest, OnMetricsFinalizeTest) {
+ base::HistogramTester histogram_tester;
+ // Make the request hang.
+ MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)};
+ SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
+ SpdySessionDependencies session_deps;
+ session_deps.socket_factory->AddSocketDataProvider(&data);
+ HttpNetworkSession::Params params =
+ SpdySessionDependencies::CreateSessionParams(&session_deps);
+ std::unique_ptr<HttpNetworkSession> session(new HttpNetworkSession(params));
+ HttpRequestInfo request_info;
+ request_info.method = "GET";
+ request_info.url = GURL("http://www.example.com");
+ SSLConfig ssl_config;
+ StreamRequestWaiter waiter;
+ std::unique_ptr<HttpStreamRequest> request(
+ session->http_stream_factory()->RequestStream(
+ request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter,
+ /* enable_ip_based_pooling = */ true,
+ /* enable_alternative_services = */ true, NetLogWithSource()));
+ NetworkChangeNotifier::FinalizingMetricsLogRecord();
+ // Notification is asynchronous.
+ base::RunLoop().RunUntilIdle();
+ // There are two HttpStreamFactoryImpl in HttpNetworkSession
+ // (|http_stream_factory_| and |http_stream_factory_for_websocket_|), so there
+ // will be two samples logged per FinalizingMetricsLogRecord().
+ histogram_tester.ExpectBucketCount("Net.JobControllerSet.CountOfPreconnect",
+ 0, 2);
+ histogram_tester.ExpectBucketCount(
+ "Net.JobControllerSet.CountOfNonPreconnectAltJob", 0, 2);
+ histogram_tester.ExpectBucketCount(
+ "Net.JobControllerSet.CountOfNonPreconnectMainJob", 0, 1);
+ // HttpNetworkSession's |http_stream_factory_| reports 1 count to 1 bucket.
+ histogram_tester.ExpectBucketCount(
+ "Net.JobControllerSet.CountOfNonPreconnectMainJob", 1, 1);
+}
+
// Verify that preconnect to a HTTP2 proxy server with a privacy mode different
// than that of the in-flight preconnect job succeeds.
TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) {
« 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