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 StaticSocketDataProvider socket_data; | |
| 1524 socket_data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); | |
| 1525 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | |
| 1526 | |
| 1527 std::unique_ptr<HttpNetworkSession> session( | |
| 1528 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | |
| 1529 | |
| 1530 // Now request a stream. It should succeed using the second proxy in the | |
| 1531 // list. | |
| 1532 HttpRequestInfo request_info; | |
| 1533 request_info.method = "GET"; | |
| 1534 request_info.url = GURL("http://www.google.com"); | |
| 1535 request_info.load_flags = 0; | |
| 1536 | |
| 1537 SSLConfig ssl_config; | |
| 1538 StreamRequestWaiter waiter; | |
| 1539 std::unique_ptr<HttpStreamRequest> request( | |
| 1540 session->http_stream_factory()->RequestStream( | |
| 1541 request_info, LOWEST, ssl_config, ssl_config, &waiter, | |
| 1542 NetLogWithSource())); | |
| 1543 EXPECT_FALSE(waiter.stream_done()); | |
| 1544 | |
| 1545 // Test to confirm that a SetPriority received after the stream is created | |
| 1546 // does not crash. | |
|
mmenke
2017/01/18 20:37:26
Hrm...Is there some way we can verify the stream w
Randy Smith (Not in Mondays)
2017/01/22 21:37:00
I've modified the test to confirm that a session h
| |
| 1547 request->SetPriority(HIGHEST); | |
| 1548 | |
| 1549 waiter.WaitForStream(); | |
| 1550 EXPECT_TRUE(waiter.stream_done()); | |
| 1551 ASSERT_TRUE(nullptr != waiter.stream()); | |
|
mmenke
2017/01/18 20:37:26
I believe you can ASSERT_TRUE(waiter.stream()); no
Randy Smith (Not in Mondays)
2017/01/22 21:37:00
Done.
| |
| 1552 EXPECT_TRUE(nullptr == waiter.websocket_stream()); | |
|
mmenke
2017/01/18 20:37:27
Same as above (Except EXPECT_FALSE)
Randy Smith (Not in Mondays)
2017/01/22 21:37:00
Done.
| |
| 1553 } | |
| 1554 | |
| 1517 TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { | 1555 TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { |
| 1518 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); | 1556 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| 1519 | 1557 |
| 1520 MockRead mock_read(ASYNC, OK); | 1558 MockRead mock_read(ASYNC, OK); |
| 1521 StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); | 1559 StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); |
| 1522 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | 1560 socket_data.set_connect_data(MockConnect(ASYNC, OK)); |
| 1523 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | 1561 session_deps.socket_factory->AddSocketDataProvider(&socket_data); |
| 1524 | 1562 |
| 1525 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); | 1563 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); |
| 1526 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); | 1564 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2512 session->GetTransportSocketPool( | 2550 session->GetTransportSocketPool( |
| 2513 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2551 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2514 EXPECT_EQ(1, GetSocketPoolGroupCount( | 2552 EXPECT_EQ(1, GetSocketPoolGroupCount( |
| 2515 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2553 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2516 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 2554 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 2517 } | 2555 } |
| 2518 | 2556 |
| 2519 } // namespace | 2557 } // namespace |
| 2520 | 2558 |
| 2521 } // namespace net | 2559 } // namespace net |
| OLD | NEW |