Chromium Code Reviews| 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 "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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1507 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool( | 1507 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool( |
| 1508 HttpNetworkSession::NORMAL_SOCKET_POOL))); | 1508 HttpNetworkSession::NORMAL_SOCKET_POOL))); |
| 1509 EXPECT_EQ(0, GetSocketPoolGroupCount( | 1509 EXPECT_EQ(0, GetSocketPoolGroupCount( |
| 1510 session->GetTransportSocketPool( | 1510 session->GetTransportSocketPool( |
| 1511 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 1511 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 1512 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool( | 1512 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool( |
| 1513 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 1513 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 1514 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 1514 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 // Test the race of SetPriority versus stream completion where SetPriority | |
| 1518 // may be called on an HttpStreamFactoryImpl::Job after the stream | |
| 1519 // has been created by the job. | |
| 1520 TEST_F(HttpStreamFactoryTest, ReprioritizeAfterStreamReceived) { | |
| 1521 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); | |
| 1522 | |
| 1523 MockRead mock_read(SYNCHRONOUS, OK); | |
|
mmenke
2017/01/24 17:30:34
OK -> ERR_IO_PENDING? I don't think we want to re
Randy Smith (Not in Mondays)
2017/02/16 23:22:18
Oh, that makes some sense of some of my debugging
| |
| 1524 StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); | |
| 1525 socket_data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); | |
| 1526 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | |
| 1527 | |
| 1528 SSLSocketDataProvider ssl_socket_data(SYNCHRONOUS, OK); | |
| 1529 ssl_socket_data.next_proto = kProtoHTTP2; | |
| 1530 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); | |
| 1531 | |
| 1532 std::unique_ptr<HttpNetworkSession> session( | |
| 1533 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | |
| 1534 | |
| 1535 // Now request a stream. | |
| 1536 HttpRequestInfo request_info; | |
| 1537 request_info.method = "GET"; | |
| 1538 request_info.url = GURL("https://www.google.com"); | |
| 1539 request_info.load_flags = 0; | |
| 1540 | |
| 1541 SSLConfig ssl_config; | |
| 1542 StreamRequestWaiter waiter; | |
| 1543 EXPECT_EQ(0, GetSpdySessionCount(session.get())); | |
| 1544 std::unique_ptr<HttpStreamRequest> request( | |
| 1545 session->http_stream_factory()->RequestStream( | |
| 1546 request_info, LOWEST, ssl_config, ssl_config, &waiter, | |
| 1547 NetLogWithSource())); | |
| 1548 EXPECT_FALSE(waiter.stream_done()); | |
| 1549 | |
| 1550 // Confirm a stream has been created by asserting that a new session | |
| 1551 // has been created. (The stream is only created at the SPDY level on | |
| 1552 // first write, which happens after the request has returned a stream). | |
| 1553 ASSERT_EQ(1, GetSpdySessionCount(session.get())); | |
| 1554 | |
| 1555 // Test to confirm that a SetPriority received after the stream is created | |
| 1556 // but before the request returns it does not crash. | |
| 1557 request->SetPriority(HIGHEST); | |
| 1558 | |
| 1559 waiter.WaitForStream(); | |
| 1560 EXPECT_TRUE(waiter.stream_done()); | |
| 1561 ASSERT_TRUE(waiter.stream()); | |
| 1562 EXPECT_FALSE(waiter.websocket_stream()); | |
| 1563 } | |
| 1564 | |
| 1517 TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { | 1565 TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { |
| 1518 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); | 1566 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| 1519 | 1567 |
| 1520 MockRead mock_read(ASYNC, OK); | 1568 MockRead mock_read(ASYNC, OK); |
| 1521 StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); | 1569 StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); |
| 1522 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | 1570 socket_data.set_connect_data(MockConnect(ASYNC, OK)); |
| 1523 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | 1571 session_deps.socket_factory->AddSocketDataProvider(&socket_data); |
| 1524 | 1572 |
| 1525 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); | 1573 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); |
| 1526 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); | 1574 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2512 session->GetTransportSocketPool( | 2560 session->GetTransportSocketPool( |
| 2513 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2561 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2514 EXPECT_EQ(1, GetSocketPoolGroupCount( | 2562 EXPECT_EQ(1, GetSocketPoolGroupCount( |
| 2515 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2563 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2516 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 2564 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 2517 } | 2565 } |
| 2518 | 2566 |
| 2519 } // namespace | 2567 } // namespace |
| 2520 | 2568 |
| 2521 } // namespace net | 2569 } // namespace net |
| OLD | NEW |