Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: net/url_request/url_request_test_util.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change to returning strings by value Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/threading/worker_pool.h" 11 #include "base/threading/worker_pool.h"
12 #include "net/base/cert_verifier.h" 12 #include "net/base/cert_verifier.h"
13 #include "net/base/default_server_bound_cert_store.h" 13 #include "net/base/default_server_bound_cert_store.h"
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/base/mock_host_resolver.h" 15 #include "net/base/mock_host_resolver.h"
16 #include "net/base/server_bound_cert_service.h" 16 #include "net/base/server_bound_cert_service.h"
17 #include "net/http/http_network_session.h" 17 #include "net/http/http_network_session.h"
18 #include "net/http/http_server_properties_impl.h" 18 #include "net/http/http_server_properties_impl.h"
19 #include "net/url_request/const_http_user_agent_settings.h"
19 #include "net/url_request/url_request_job_factory_impl.h" 20 #include "net/url_request/url_request_job_factory_impl.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace { 23 namespace {
23 24
24 // These constants put the net::NetworkDelegate events of TestNetworkDelegate 25 // These constants put the net::NetworkDelegate events of TestNetworkDelegate
25 // into an order. They are used in conjunction with 26 // into an order. They are used in conjunction with
26 // |TestNetworkDelegate::next_states_| to check that we do not send 27 // |TestNetworkDelegate::next_states_| to check that we do not send
27 // events in the wrong order. 28 // events in the wrong order.
28 const int kStageBeforeURLRequest = 1 << 0; 29 const int kStageBeforeURLRequest = 1 << 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // In-memory cookie store. 102 // In-memory cookie store.
102 if (!cookie_store()) 103 if (!cookie_store())
103 context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); 104 context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
104 // In-memory origin bound cert service. 105 // In-memory origin bound cert service.
105 if (!server_bound_cert_service()) { 106 if (!server_bound_cert_service()) {
106 context_storage_.set_server_bound_cert_service( 107 context_storage_.set_server_bound_cert_service(
107 new net::ServerBoundCertService( 108 new net::ServerBoundCertService(
108 new net::DefaultServerBoundCertStore(NULL), 109 new net::DefaultServerBoundCertStore(NULL),
109 base::WorkerPool::GetTaskRunner(true))); 110 base::WorkerPool::GetTaskRunner(true)));
110 } 111 }
111 if (accept_language().empty()) 112 if (GetAcceptLanguage().empty()) {
112 set_accept_language("en-us,fr"); 113 context_storage_.set_http_user_agent_settings(
113 if (accept_charset().empty()) 114 new net::ConstHttpUserAgentSettings(
114 set_accept_charset("iso-8859-1,*,utf-8"); 115 "en-us,fr", GetAcceptCharset(), EmptyString()));
116 }
117 if (GetAcceptCharset().empty()) {
118 context_storage_.set_http_user_agent_settings(
119 new net::ConstHttpUserAgentSettings(
120 GetAcceptLanguage(), "iso-8859-1,*,utf-8", EmptyString()));
121 }
mmenke 2012/10/05 20:08:51 This isn't quite equivalent to the old code, since
115 if (!job_factory()) 122 if (!job_factory())
116 context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl); 123 context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl);
117 } 124 }
118 125
119 TestURLRequest::TestURLRequest(const GURL& url, 126 TestURLRequest::TestURLRequest(const GURL& url,
120 Delegate* delegate, 127 Delegate* delegate,
121 TestURLRequestContext* context) 128 TestURLRequestContext* context)
122 : net::URLRequest(url, delegate, context) { 129 : net::URLRequest(url, delegate, context) {
123 } 130 }
124 131
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 528
522 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { 529 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() {
523 DCHECK_EQ(value_, new_value_); 530 DCHECK_EQ(value_, new_value_);
524 value_ = old_value_; 531 value_ = old_value_;
525 } 532 }
526 533
527 // static 534 // static
528 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { 535 const std::string& ScopedCustomUrlRequestTestHttpHost::value() {
529 return value_; 536 return value_;
530 } 537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698