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/url_request/url_request_test_util.h" | 5 #include "net/url_request/url_request_test_util.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "net/base/cert_verifier.h" | 11 #include "net/base/cert_verifier.h" |
| 12 #include "net/base/default_server_bound_cert_store.h" | 12 #include "net/base/default_server_bound_cert_store.h" |
| 13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/server_bound_cert_service.h" | 14 #include "net/base/server_bound_cert_service.h" |
| 15 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
| 16 #include "net/http/http_server_properties_impl.h" | 16 #include "net/http/http_server_properties_impl.h" |
| 17 #include "net/url_request/url_request_job_factory.h" | 17 #include "net/url_request/url_request_job_factory.h" |
| 18 #include "net/url_request/url_request_throttler_manager.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // These constants put the net::NetworkDelegate events of TestNetworkDelegate | 23 // These constants put the net::NetworkDelegate events of TestNetworkDelegate |
| 23 // into an order. They are used in conjunction with | 24 // into an order. They are used in conjunction with |
| 24 // |TestNetworkDelegate::next_states_| to check that we do not send | 25 // |TestNetworkDelegate::next_states_| to check that we do not send |
| 25 // events in the wrong order. | 26 // events in the wrong order. |
| 26 const int kStageBeforeURLRequest = 1 << 0; | 27 const int kStageBeforeURLRequest = 1 << 0; |
| 27 const int kStageBeforeSendHeaders = 1 << 1; | 28 const int kStageBeforeSendHeaders = 1 << 1; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 context_storage_.set_server_bound_cert_service( | 150 context_storage_.set_server_bound_cert_service( |
| 150 new net::ServerBoundCertService( | 151 new net::ServerBoundCertService( |
| 151 new net::DefaultServerBoundCertStore(NULL))); | 152 new net::DefaultServerBoundCertStore(NULL))); |
| 152 } | 153 } |
| 153 if (accept_language().empty()) | 154 if (accept_language().empty()) |
| 154 set_accept_language("en-us,fr"); | 155 set_accept_language("en-us,fr"); |
| 155 if (accept_charset().empty()) | 156 if (accept_charset().empty()) |
| 156 set_accept_charset("iso-8859-1,*,utf-8"); | 157 set_accept_charset("iso-8859-1,*,utf-8"); |
| 157 if (!job_factory()) | 158 if (!job_factory()) |
| 158 context_storage_.set_job_factory(new net::URLRequestJobFactory); | 159 context_storage_.set_job_factory(new net::URLRequestJobFactory); |
| 160 if (!throttler_manager()) | |
|
eroman
2012/04/24 19:05:57
nit: i strongly recommend putting multi-line state
Jói
2012/04/27 13:20:26
Done, and I totally agree, that's my usual style.
| |
| 161 context_storage_.set_throttler_manager( | |
| 162 new net::URLRequestThrottlerManager()); | |
| 159 } | 163 } |
| 160 | 164 |
| 161 | 165 |
| 162 TestURLRequest::TestURLRequest(const GURL& url, Delegate* delegate) | 166 TestURLRequest::TestURLRequest(const GURL& url, Delegate* delegate) |
| 163 : net::URLRequest(url, delegate) { | 167 : net::URLRequest(url, delegate) { |
| 164 set_context(new TestURLRequestContext()); | 168 set_context(new TestURLRequestContext()); |
| 165 } | 169 } |
| 166 | 170 |
| 167 TestURLRequest::~TestURLRequest() {} | 171 TestURLRequest::~TestURLRequest() {} |
| 168 | 172 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 | 541 |
| 538 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { | 542 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { |
| 539 DCHECK_EQ(value_, new_value_); | 543 DCHECK_EQ(value_, new_value_); |
| 540 value_ = old_value_; | 544 value_ = old_value_; |
| 541 } | 545 } |
| 542 | 546 |
| 543 // static | 547 // static |
| 544 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { | 548 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { |
| 545 return value_; | 549 return value_; |
| 546 } | 550 } |
| OLD | NEW |