Commit 216426ea authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Pass annotation to SpdyHttpStream.

Network traffic annotation is passed from HttpRequestInfo to
SpdyHttpStream.

Bug: 656607
Change-Id: I8cfc0cade93e016c3e7f497e3a06a1dbf9894494
Reviewed-on: https://chromium-review.googlesource.com/958921
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542624}
parent ab61a762
...@@ -369,6 +369,8 @@ void PreconnectHelperForURL(int num_streams, ...@@ -369,6 +369,8 @@ void PreconnectHelperForURL(int num_streams,
request.url = url; request.url = url;
request.load_flags = 0; request.load_flags = 0;
request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
session->http_stream_factory()->PreconnectStreams(num_streams, request); session->http_stream_factory()->PreconnectStreams(num_streams, request);
mock_factory->WaitForPreconnects(); mock_factory->WaitForPreconnects();
...@@ -717,6 +719,8 @@ TEST_F(HttpStreamFactoryTest, JobNotifiesProxy) { ...@@ -717,6 +719,8 @@ TEST_F(HttpStreamFactoryTest, JobNotifiesProxy) {
HttpRequestInfo request_info; HttpRequestInfo request_info;
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -805,6 +809,8 @@ TEST_F(HttpStreamFactoryTest, QuicProxyMarkedAsBad) { ...@@ -805,6 +809,8 @@ TEST_F(HttpStreamFactoryTest, QuicProxyMarkedAsBad) {
HttpRequestInfo request_info; HttpRequestInfo request_info;
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1009,6 +1015,8 @@ TEST_F(HttpStreamFactoryTest, WithQUICAlternativeProxyMarkedAsBad) { ...@@ -1009,6 +1015,8 @@ TEST_F(HttpStreamFactoryTest, WithQUICAlternativeProxyMarkedAsBad) {
HttpRequestInfo request_info; HttpRequestInfo request_info;
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1107,6 +1115,8 @@ TEST_F(HttpStreamFactoryTest, WithQUICAlternativeProxyNotMarkedAsBad) { ...@@ -1107,6 +1115,8 @@ TEST_F(HttpStreamFactoryTest, WithQUICAlternativeProxyNotMarkedAsBad) {
HttpRequestInfo request_info; HttpRequestInfo request_info;
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1257,6 +1267,8 @@ TEST_F(HttpStreamFactoryTest, OnlyOnePreconnectToProxyServer) { ...@@ -1257,6 +1267,8 @@ TEST_F(HttpStreamFactoryTest, OnlyOnePreconnectToProxyServer) {
request.method = "GET"; request.method = "GET";
request.url = url; request.url = url;
request.load_flags = 0; request.load_flags = 0;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
if (preconnect_request == 0) { if (preconnect_request == 0) {
// First preconnect job should succeed. // First preconnect job should succeed.
...@@ -1345,6 +1357,8 @@ TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) { ...@@ -1345,6 +1357,8 @@ TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) {
request_privacy_mode_disabled.method = "GET"; request_privacy_mode_disabled.method = "GET";
request_privacy_mode_disabled.url = url; request_privacy_mode_disabled.url = url;
request_privacy_mode_disabled.load_flags = 0; request_privacy_mode_disabled.load_flags = 0;
request_privacy_mode_disabled.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// First preconnect job should succeed. // First preconnect job should succeed.
session->http_stream_factory()->PreconnectStreams( session->http_stream_factory()->PreconnectStreams(
...@@ -1365,6 +1379,8 @@ TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) { ...@@ -1365,6 +1379,8 @@ TEST_F(HttpStreamFactoryTest, ProxyServerPreconnectDifferentPrivacyModes) {
request_privacy_mode_enabled.url = url; request_privacy_mode_enabled.url = url;
request_privacy_mode_enabled.load_flags = 0; request_privacy_mode_enabled.load_flags = 0;
request_privacy_mode_enabled.privacy_mode = PRIVACY_MODE_ENABLED; request_privacy_mode_enabled.privacy_mode = PRIVACY_MODE_ENABLED;
request_privacy_mode_enabled.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// Request with a different privacy mode should succeed. // Request with a different privacy mode should succeed.
session->http_stream_factory()->PreconnectStreams( session->http_stream_factory()->PreconnectStreams(
...@@ -1398,6 +1414,8 @@ TEST_F(HttpStreamFactoryTest, PrivacyModeDisablesChannelId) { ...@@ -1398,6 +1414,8 @@ TEST_F(HttpStreamFactoryTest, PrivacyModeDisablesChannelId) {
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.privacy_mode = PRIVACY_MODE_DISABLED; request_info.privacy_mode = PRIVACY_MODE_DISABLED;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1497,6 +1515,8 @@ TEST_F(HttpStreamFactoryTest, PrivacyModeUsesDifferentSocketPoolGroup) { ...@@ -1497,6 +1515,8 @@ TEST_F(HttpStreamFactoryTest, PrivacyModeUsesDifferentSocketPoolGroup) {
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.privacy_mode = PRIVACY_MODE_DISABLED; request_info.privacy_mode = PRIVACY_MODE_DISABLED;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1547,6 +1567,8 @@ TEST_F(HttpStreamFactoryTest, GetLoadState) { ...@@ -1547,6 +1567,8 @@ TEST_F(HttpStreamFactoryTest, GetLoadState) {
HttpRequestInfo request_info; HttpRequestInfo request_info;
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1577,6 +1599,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStream) { ...@@ -1577,6 +1599,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStream) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1626,6 +1650,8 @@ TEST_F(HttpStreamFactoryTest, ReprioritizeAfterStreamReceived) { ...@@ -1626,6 +1650,8 @@ TEST_F(HttpStreamFactoryTest, ReprioritizeAfterStreamReceived) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1671,6 +1697,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { ...@@ -1671,6 +1697,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1714,6 +1742,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverProxy) { ...@@ -1714,6 +1742,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverProxy) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1774,6 +1804,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverProxyWithPreconnects) { ...@@ -1774,6 +1804,8 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverProxyWithPreconnects) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
const int num_preconnects = 5; const int num_preconnects = 5;
...@@ -1843,6 +1875,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStream) { ...@@ -1843,6 +1875,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStream) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("ws://www.google.com"); request_info.url = GURL("ws://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1887,6 +1921,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverSSL) { ...@@ -1887,6 +1921,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverSSL) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("wss://www.google.com"); request_info.url = GURL("wss://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1929,6 +1965,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverProxy) { ...@@ -1929,6 +1965,8 @@ TEST_F(HttpStreamFactoryTest, RequestWebSocketBasicHandshakeStreamOverProxy) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("ws://www.google.com"); request_info.url = GURL("ws://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -1986,6 +2024,8 @@ TEST_F(HttpStreamFactoryTest, RequestSpdyHttpStreamHttpsURL) { ...@@ -1986,6 +2024,8 @@ TEST_F(HttpStreamFactoryTest, RequestSpdyHttpStreamHttpsURL) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -2043,6 +2083,8 @@ TEST_F(HttpStreamFactoryTest, RequestSpdyHttpStreamHttpURL) { ...@@ -2043,6 +2083,8 @@ TEST_F(HttpStreamFactoryTest, RequestSpdyHttpStreamHttpURL) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("http://www.google.com"); request_info.url = GURL("http://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -2129,6 +2171,8 @@ TEST_F(HttpStreamFactoryTest, NewSpdySessionCloseIdleH2Sockets) { ...@@ -2129,6 +2171,8 @@ TEST_F(HttpStreamFactoryTest, NewSpdySessionCloseIdleH2Sockets) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter1; StreamRequestWaiter waiter1;
...@@ -2184,6 +2228,8 @@ TEST_F(HttpStreamFactoryTest, TwoSpdyConnects) { ...@@ -2184,6 +2228,8 @@ TEST_F(HttpStreamFactoryTest, TwoSpdyConnects) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
// Request two streams at once and make sure they use the same connection. // Request two streams at once and make sure they use the same connection.
...@@ -2238,6 +2284,8 @@ TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) { ...@@ -2238,6 +2284,8 @@ TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -2427,6 +2475,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest, ...@@ -2427,6 +2475,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest,
request_info.method = "GET"; request_info.method = "GET";
request_info.url = default_url_; request_info.url = default_url_;
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
std::unique_ptr<HttpStreamRequest> request( std::unique_ptr<HttpStreamRequest> request(
...@@ -2492,6 +2542,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest, ...@@ -2492,6 +2542,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest,
request_info.method = "GET"; request_info.method = "GET";
request_info.url = default_url_; request_info.url = default_url_;
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
std::unique_ptr<HttpStreamRequest> request( std::unique_ptr<HttpStreamRequest> request(
...@@ -2554,6 +2606,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest, ...@@ -2554,6 +2606,8 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest,
request_info.method = "GET"; request_info.method = "GET";
request_info.url = default_url_; request_info.url = default_url_;
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
std::unique_ptr<HttpStreamRequest> request( std::unique_ptr<HttpStreamRequest> request(
...@@ -2620,6 +2674,8 @@ TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImplFailure) { ...@@ -2620,6 +2674,8 @@ TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImplFailure) {
request_info.method = "GET"; request_info.method = "GET";
request_info.url = GURL("https://www.google.com"); request_info.url = GURL("https://www.google.com");
request_info.load_flags = 0; request_info.load_flags = 0;
request_info.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter; StreamRequestWaiter waiter;
...@@ -2684,11 +2740,16 @@ TEST_F(HttpStreamFactoryTest, Tag) { ...@@ -2684,11 +2740,16 @@ TEST_F(HttpStreamFactoryTest, Tag) {
request_info1.url = GURL("https://example.org"); request_info1.url = GURL("https://example.org");
request_info1.load_flags = 0; request_info1.load_flags = 0;
request_info1.socket_tag = tag1; request_info1.socket_tag = tag1;
request_info1.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SocketTag tag2(getuid(), 0x87654321); SocketTag tag2(getuid(), 0x87654321);
HttpRequestInfo request_info2 = request_info1; HttpRequestInfo request_info2 = request_info1;
request_info2.socket_tag = tag2; request_info2.socket_tag = tag2;
request_info2.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// Verify one stream with one tag results in one session, group and socket. // Verify one stream with one tag results in one session, group and
// socket.
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter1; StreamRequestWaiter waiter1;
std::unique_ptr<HttpStreamRequest> request1( std::unique_ptr<HttpStreamRequest> request1(
...@@ -2841,9 +2902,13 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest, Tag) { ...@@ -2841,9 +2902,13 @@ TEST_P(HttpStreamFactoryBidirectionalQuicTest, Tag) {
request_info1.url = default_url_; request_info1.url = default_url_;
request_info1.load_flags = 0; request_info1.load_flags = 0;
request_info1.socket_tag = tag1; request_info1.socket_tag = tag1;
request_info1.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SocketTag tag2(getuid(), 0x87654321); SocketTag tag2(getuid(), 0x87654321);
HttpRequestInfo request_info2 = request_info1; HttpRequestInfo request_info2 = request_info1;
request_info2.socket_tag = tag2; request_info2.socket_tag = tag2;
request_info2.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// Verify one stream with one tag results in one QUIC session. // Verify one stream with one tag results in one QUIC session.
SSLConfig ssl_config; SSLConfig ssl_config;
...@@ -2940,16 +3005,23 @@ TEST_F(HttpStreamFactoryTest, ChangeSocketTag) { ...@@ -2940,16 +3005,23 @@ TEST_F(HttpStreamFactoryTest, ChangeSocketTag) {
request_info1.url = GURL("https://www.example.org"); request_info1.url = GURL("https://www.example.org");
request_info1.load_flags = 0; request_info1.load_flags = 0;
request_info1.socket_tag = tag1; request_info1.socket_tag = tag1;
request_info1.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SocketTag tag2(getuid(), 0x87654321); SocketTag tag2(getuid(), 0x87654321);
HttpRequestInfo request_info2 = request_info1; HttpRequestInfo request_info2 = request_info1;
request_info2.socket_tag = tag2; request_info2.socket_tag = tag2;
request_info2.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// Prepare another HttpRequestInfo with tag1 and a different host name. // Prepare another HttpRequestInfo with tag1 and a different host name.
HttpRequestInfo request_info3 = request_info1; HttpRequestInfo request_info3 = request_info1;
request_info3.url = GURL("https://foo.example.org"); request_info3.url = GURL("https://foo.example.org");
request_info3.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
// Verify one stream with one tag results in one session, group and socket. // Verify one stream with one tag results in one session, group and
// socket.
SSLConfig ssl_config; SSLConfig ssl_config;
StreamRequestWaiter waiter1; StreamRequestWaiter waiter1;
std::unique_ptr<HttpStreamRequest> request1( std::unique_ptr<HttpStreamRequest> request1(
...@@ -3135,6 +3207,8 @@ TEST_F(HttpStreamFactoryTest, MultiIPAliases) { ...@@ -3135,6 +3207,8 @@ TEST_F(HttpStreamFactoryTest, MultiIPAliases) {
request_info1.method = "GET"; request_info1.method = "GET";
request_info1.url = GURL("https://a.example.org"); request_info1.url = GURL("https://a.example.org");
request_info1.privacy_mode = PRIVACY_MODE_DISABLED; request_info1.privacy_mode = PRIVACY_MODE_DISABLED;
request_info1.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
HttpRequestInfo request_info1_alias = request_info1; HttpRequestInfo request_info1_alias = request_info1;
request_info1.url = GURL("https://b.example.org"); request_info1.url = GURL("https://b.example.org");
...@@ -3143,6 +3217,8 @@ TEST_F(HttpStreamFactoryTest, MultiIPAliases) { ...@@ -3143,6 +3217,8 @@ TEST_F(HttpStreamFactoryTest, MultiIPAliases) {
request_info2.method = "GET"; request_info2.method = "GET";
request_info2.url = GURL("https://a.example.org"); request_info2.url = GURL("https://a.example.org");
request_info2.privacy_mode = PRIVACY_MODE_ENABLED; request_info2.privacy_mode = PRIVACY_MODE_ENABLED;
request_info2.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
HttpRequestInfo request_info2_alias = request_info2; HttpRequestInfo request_info2_alias = request_info2;
request_info2.url = GURL("https://b.example.org"); request_info2.url = GURL("https://b.example.org");
......
...@@ -93,13 +93,12 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info, ...@@ -93,13 +93,12 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info,
} }
} }
// TODO(https://crbug.com/656607): Add proper annotation here.
int rv = stream_request_.StartRequest( int rv = stream_request_.StartRequest(
SPDY_REQUEST_RESPONSE_STREAM, spdy_session_, request_info_->url, priority, SPDY_REQUEST_RESPONSE_STREAM, spdy_session_, request_info_->url, priority,
request_info_->socket_tag, stream_net_log, request_info_->socket_tag, stream_net_log,
base::BindOnce(&SpdyHttpStream::OnStreamCreated, base::BindOnce(&SpdyHttpStream::OnStreamCreated,
weak_factory_.GetWeakPtr(), std::move(callback)), weak_factory_.GetWeakPtr(), std::move(callback)),
NO_TRAFFIC_ANNOTATION_BUG_656607); NetworkTrafficAnnotationTag(request_info->traffic_annotation));
if (rv == OK) { if (rv == OK) {
stream_ = stream_request_.ReleaseStream().get(); stream_ = stream_request_.ReleaseStream().get();
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "net/test/cert_test_util.h" #include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h" #include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h" #include "net/test/test_data_directory.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -196,6 +197,8 @@ TEST_F(SpdyHttpStreamTest, SendRequest) { ...@@ -196,6 +197,8 @@ TEST_F(SpdyHttpStreamTest, SendRequest) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "GET"; request.method = "GET";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
TestCompletionCallback callback; TestCompletionCallback callback;
HttpResponseInfo response; HttpResponseInfo response;
HttpRequestHeaders headers; HttpRequestHeaders headers;
...@@ -252,6 +255,8 @@ TEST_F(SpdyHttpStreamTest, RequestInfoDestroyedBeforeRead) { ...@@ -252,6 +255,8 @@ TEST_F(SpdyHttpStreamTest, RequestInfoDestroyedBeforeRead) {
std::make_unique<HttpRequestInfo>(); std::make_unique<HttpRequestInfo>();
request->method = "GET"; request->method = "GET";
request->url = url_; request->url = url_;
request->traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
TestCompletionCallback callback; TestCompletionCallback callback;
HttpResponseInfo response; HttpResponseInfo response;
HttpRequestHeaders headers; HttpRequestHeaders headers;
...@@ -313,6 +318,8 @@ TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) { ...@@ -313,6 +318,8 @@ TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) {
HttpRequestInfo request1; HttpRequestInfo request1;
request1.method = "GET"; request1.method = "GET";
request1.url = url_; request1.url = url_;
request1.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
TestCompletionCallback callback1; TestCompletionCallback callback1;
HttpResponseInfo response1; HttpResponseInfo response1;
HttpRequestHeaders headers1; HttpRequestHeaders headers1;
...@@ -323,6 +330,8 @@ TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) { ...@@ -323,6 +330,8 @@ TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) {
HttpRequestInfo request2; HttpRequestInfo request2;
request2.method = "GET"; request2.method = "GET";
request2.url = url_; request2.url = url_;
request2.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
TestCompletionCallback callback2; TestCompletionCallback callback2;
HttpResponseInfo response2; HttpResponseInfo response2;
HttpRequestHeaders headers2; HttpRequestHeaders headers2;
...@@ -413,6 +422,8 @@ TEST_F(SpdyHttpStreamTest, SendChunkedPost) { ...@@ -413,6 +422,8 @@ TEST_F(SpdyHttpStreamTest, SendChunkedPost) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -467,6 +478,8 @@ TEST_F(SpdyHttpStreamTest, SendChunkedPostLastEmpty) { ...@@ -467,6 +478,8 @@ TEST_F(SpdyHttpStreamTest, SendChunkedPostLastEmpty) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -520,6 +533,8 @@ TEST_F(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) { ...@@ -520,6 +533,8 @@ TEST_F(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -590,6 +605,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPost) { ...@@ -590,6 +605,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPost) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -685,6 +702,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) { ...@@ -685,6 +702,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -769,6 +788,8 @@ TEST_F(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) { ...@@ -769,6 +788,8 @@ TEST_F(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -833,6 +854,8 @@ TEST_F(SpdyHttpStreamTest, SpdyURLTest) { ...@@ -833,6 +854,8 @@ TEST_F(SpdyHttpStreamTest, SpdyURLTest) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "GET"; request.method = "GET";
request.url = GURL(full_url); request.url = GURL(full_url);
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
TestCompletionCallback callback; TestCompletionCallback callback;
HttpResponseInfo response; HttpResponseInfo response;
HttpRequestHeaders headers; HttpRequestHeaders headers;
...@@ -883,6 +906,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) { ...@@ -883,6 +906,8 @@ TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(),
...@@ -989,6 +1014,8 @@ TEST_F(SpdyHttpStreamTest, DataReadErrorSynchronous) { ...@@ -989,6 +1014,8 @@ TEST_F(SpdyHttpStreamTest, DataReadErrorSynchronous) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_data_stream; request.upload_data_stream = &upload_data_stream;
TestCompletionCallback callback; TestCompletionCallback callback;
...@@ -1042,6 +1069,8 @@ TEST_F(SpdyHttpStreamTest, DataReadErrorAsynchronous) { ...@@ -1042,6 +1069,8 @@ TEST_F(SpdyHttpStreamTest, DataReadErrorAsynchronous) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
request.upload_data_stream = &upload_data_stream; request.upload_data_stream = &upload_data_stream;
TestCompletionCallback callback; TestCompletionCallback callback;
...@@ -1079,6 +1108,8 @@ TEST_F(SpdyHttpStreamTest, RequestCallbackCancelsStream) { ...@@ -1079,6 +1108,8 @@ TEST_F(SpdyHttpStreamTest, RequestCallbackCancelsStream) {
HttpRequestInfo request; HttpRequestInfo request;
request.method = "POST"; request.method = "POST";
request.url = url_; request.url = url_;
request.traffic_annotation =
MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
ChunkedUploadDataStream upload_stream(0); ChunkedUploadDataStream upload_stream(0);
request.upload_data_stream = &upload_stream; request.upload_data_stream = &upload_stream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment