| 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/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" | 
| 6 | 6 | 
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" | 
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" | 
| 9 #include "net/cert/cert_verifier.h" | 9 #include "net/cert/cert_verifier.h" | 
| 10 #include "net/dns/mock_host_resolver.h" | 10 #include "net/dns/mock_host_resolver.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29   QuicStreamFactoryTest() | 29   QuicStreamFactoryTest() | 
| 30       : clock_(new MockClock()), | 30       : clock_(new MockClock()), | 
| 31         factory_(&host_resolver_, &socket_factory_, | 31         factory_(&host_resolver_, &socket_factory_, | 
| 32                  base::WeakPtr<HttpServerProperties>(), | 32                  base::WeakPtr<HttpServerProperties>(), | 
| 33                  &crypto_client_stream_factory_, | 33                  &crypto_client_stream_factory_, | 
| 34                  &random_generator_, clock_), | 34                  &random_generator_, clock_), | 
| 35         host_port_proxy_pair_(HostPortPair("www.google.com", 443), | 35         host_port_proxy_pair_(HostPortPair("www.google.com", 443), | 
| 36                               ProxyServer::Direct()), | 36                               ProxyServer::Direct()), | 
| 37         is_https_(false), | 37         is_https_(false), | 
| 38         cert_verifier_(CertVerifier::CreateDefault()) { | 38         cert_verifier_(CertVerifier::CreateDefault()) { | 
|  | 39     factory_.set_require_confirmation(false); | 
| 39   } | 40   } | 
| 40 | 41 | 
| 41   scoped_ptr<QuicEncryptedPacket> ConstructRstPacket( | 42   scoped_ptr<QuicEncryptedPacket> ConstructRstPacket( | 
| 42       QuicPacketSequenceNumber num, | 43       QuicPacketSequenceNumber num, | 
| 43       QuicStreamId stream_id) { | 44       QuicStreamId stream_id) { | 
| 44     QuicPacketHeader header; | 45     QuicPacketHeader header; | 
| 45     header.public_header.guid = 0xDEADBEEF; | 46     header.public_header.guid = 0xDEADBEEF; | 
| 46     header.public_header.reset_flag = false; | 47     header.public_header.reset_flag = false; | 
| 47     header.public_header.version_flag = true; | 48     header.public_header.version_flag = true; | 
| 48     header.packet_sequence_number = num; | 49     header.packet_sequence_number = num; | 
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 336   scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 337   scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 
| 337   HttpRequestInfo request_info; | 338   HttpRequestInfo request_info; | 
| 338   EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 339   EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 
| 339                                          DEFAULT_PRIORITY, | 340                                          DEFAULT_PRIORITY, | 
| 340                                          net_log_, CompletionCallback())); | 341                                          net_log_, CompletionCallback())); | 
| 341 | 342 | 
| 342   // Change the IP address and verify that stream saw the error. | 343   // Change the IP address and verify that stream saw the error. | 
| 343   factory_.OnIPAddressChanged(); | 344   factory_.OnIPAddressChanged(); | 
| 344   EXPECT_EQ(ERR_NETWORK_CHANGED, | 345   EXPECT_EQ(ERR_NETWORK_CHANGED, | 
| 345             stream->ReadResponseHeaders(callback_.callback())); | 346             stream->ReadResponseHeaders(callback_.callback())); | 
|  | 347   EXPECT_TRUE(factory_.require_confirmation()); | 
| 346 | 348 | 
| 347   // Now attempting to request a stream to the same origin should create | 349   // Now attempting to request a stream to the same origin should create | 
| 348   // a new session. | 350   // a new session. | 
| 349 | 351 | 
| 350   QuicStreamRequest request2(&factory_); | 352   QuicStreamRequest request2(&factory_); | 
| 351   EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_, | 353   EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_, | 
| 352                                              cert_verifier_.get(), net_log_, | 354                                              cert_verifier_.get(), net_log_, | 
| 353                                              callback_.callback())); | 355                                              callback_.callback())); | 
| 354 | 356 | 
| 355   EXPECT_EQ(OK, callback_.WaitForResult()); | 357   EXPECT_EQ(OK, callback_.WaitForResult()); | 
| 356   stream = request2.ReleaseStream(); | 358   stream = request2.ReleaseStream(); | 
| 357   stream.reset();  // Will reset stream 3. | 359   stream.reset();  // Will reset stream 3. | 
| 358 | 360 | 
| 359   EXPECT_TRUE(socket_data.at_read_eof()); | 361   EXPECT_TRUE(socket_data.at_read_eof()); | 
| 360   EXPECT_TRUE(socket_data.at_write_eof()); | 362   EXPECT_TRUE(socket_data.at_write_eof()); | 
| 361   EXPECT_TRUE(socket_data2.at_read_eof()); | 363   EXPECT_TRUE(socket_data2.at_read_eof()); | 
| 362   EXPECT_TRUE(socket_data2.at_write_eof()); | 364   EXPECT_TRUE(socket_data2.at_write_eof()); | 
| 363 } | 365 } | 
| 364 | 366 | 
| 365 }  // namespace test | 367 }  // namespace test | 
| 366 }  // namespace net | 368 }  // namespace net | 
| OLD | NEW | 
|---|