OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
11 #include "net/base/upload_bytes_element_reader.h" | 11 #include "net/base/upload_bytes_element_reader.h" |
12 #include "net/base/upload_data_stream.h" | 12 #include "net/base/upload_data_stream.h" |
13 #include "net/cert/mock_cert_verifier.h" | 13 #include "net/cert/mock_cert_verifier.h" |
14 #include "net/dns/mapped_host_resolver.h" | 14 #include "net/dns/mapped_host_resolver.h" |
15 #include "net/dns/mock_host_resolver.h" | 15 #include "net/dns/mock_host_resolver.h" |
16 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
17 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
18 #include "net/http/http_network_transaction.h" | 18 #include "net/http/http_network_transaction.h" |
19 #include "net/http/http_server_properties_impl.h" | 19 #include "net/http/http_server_properties_impl.h" |
20 #include "net/http/http_transaction_unittest.h" | 20 #include "net/http/http_transaction_unittest.h" |
21 #include "net/http/transport_security_state.h" | 21 #include "net/http/transport_security_state.h" |
22 #include "net/proxy/proxy_service.h" | 22 #include "net/proxy/proxy_service.h" |
23 #include "net/ssl/ssl_config_service_defaults.h" | 23 #include "net/ssl/ssl_config_service_defaults.h" |
24 #include "net/tools/quic/quic_in_memory_cache.h" | 24 #include "net/tools/quic/quic_in_memory_cache.h" |
25 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" | 25 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |
26 #include "net/tools/quic/test_tools/server_thread.h" | 26 #include "net/tools/quic/test_tools/server_thread.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "testing/platform_test.h" | 28 #include "testing/platform_test.h" |
29 | 29 |
30 extern int FLAGS_fake_packet_loss_percentage; | |
31 | |
32 using base::StringPiece; | 30 using base::StringPiece; |
33 using net::tools::QuicInMemoryCache; | 31 using net::tools::QuicInMemoryCache; |
34 using net::tools::test::QuicInMemoryCachePeer; | 32 using net::tools::test::QuicInMemoryCachePeer; |
35 using net::tools::test::ServerThread; | 33 using net::tools::test::ServerThread; |
36 | 34 |
37 namespace net { | 35 namespace net { |
38 namespace test { | 36 namespace test { |
39 | 37 |
40 namespace { | 38 namespace { |
41 | 39 |
42 const char kResponseBody[] = "some arbitrary response body"; | 40 const char kResponseBody[] = "some arbitrary response body"; |
43 | 41 |
44 // Factory for creating HttpTransactions, used by TestTransactionConsumer. | 42 // Factory for creating HttpTransactions, used by TestTransactionConsumer. |
45 class TestTransactionFactory : public HttpTransactionFactory { | 43 class TestTransactionFactory : public HttpTransactionFactory { |
46 public: | 44 public: |
47 TestTransactionFactory(const HttpNetworkSession::Params& params) | 45 TestTransactionFactory(const HttpNetworkSession::Params& params) |
48 : session_(new HttpNetworkSession(params)) {} | 46 : session_(new HttpNetworkSession(params)) {} |
49 | 47 |
50 virtual ~TestTransactionFactory() { | 48 virtual ~TestTransactionFactory() { |
51 FLAGS_fake_packet_loss_percentage = 0; | |
52 } | 49 } |
53 | 50 |
54 // HttpTransactionFactory methods | 51 // HttpTransactionFactory methods |
55 virtual int CreateTransaction(RequestPriority priority, | 52 virtual int CreateTransaction(RequestPriority priority, |
56 scoped_ptr<HttpTransaction>* trans) OVERRIDE { | 53 scoped_ptr<HttpTransaction>* trans) OVERRIDE { |
57 trans->reset(new HttpNetworkTransaction(priority, session_)); | 54 trans->reset(new HttpNetworkTransaction(priority, session_)); |
58 return OK; | 55 return OK; |
59 } | 56 } |
60 | 57 |
61 virtual HttpCache* GetCache() OVERRIDE { | 58 virtual HttpCache* GetCache() OVERRIDE { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 base::MessageLoop::current()->Run(); | 296 base::MessageLoop::current()->Run(); |
300 | 297 |
301 for (size_t i = 0; i < num_requests; ++i) { | 298 for (size_t i = 0; i < num_requests; ++i) { |
302 CheckResponse(*consumers[i], "HTTP/1.1 200 OK", kResponseBody); | 299 CheckResponse(*consumers[i], "HTTP/1.1 200 OK", kResponseBody); |
303 } | 300 } |
304 STLDeleteElements(&consumers); | 301 STLDeleteElements(&consumers); |
305 } | 302 } |
306 | 303 |
307 } // namespace test | 304 } // namespace test |
308 } // namespace net | 305 } // namespace net |
OLD | NEW |