| 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_context_builder.h" | 5 #include "net/url_request/url_request_context_builder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_util.h" |
| 12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 14 #include "net/base/cert_verifier.h" | 15 #include "net/base/cert_verifier.h" |
| 15 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/base/network_delegate.h" | 18 #include "net/base/network_delegate.h" |
| 18 #include "net/base/ssl_config_service_defaults.h" | 19 #include "net/base/ssl_config_service_defaults.h" |
| 19 #include "net/base/transport_security_state.h" | 20 #include "net/base/transport_security_state.h" |
| 20 #include "net/cookies/cookie_monster.h" | 21 #include "net/cookies/cookie_monster.h" |
| 21 #include "net/ftp/ftp_network_layer.h" | 22 #include "net/ftp/ftp_network_layer.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void StartFileThread() { | 147 void StartFileThread() { |
| 147 file_thread_.StartWithOptions( | 148 file_thread_.StartWithOptions( |
| 148 base::Thread::Options(MessageLoop::TYPE_DEFAULT, 0)); | 149 base::Thread::Options(MessageLoop::TYPE_DEFAULT, 0)); |
| 149 } | 150 } |
| 150 | 151 |
| 151 MessageLoop* file_message_loop() { | 152 MessageLoop* file_message_loop() { |
| 152 DCHECK(file_thread_.IsRunning()); | 153 DCHECK(file_thread_.IsRunning()); |
| 153 return file_thread_.message_loop(); | 154 return file_thread_.message_loop(); |
| 154 } | 155 } |
| 155 | 156 |
| 156 virtual const std::string& GetUserAgent( | |
| 157 const GURL& /* url */) const OVERRIDE { | |
| 158 return user_agent_; | |
| 159 } | |
| 160 | |
| 161 protected: | 157 protected: |
| 162 virtual ~BasicURLRequestContext() {} | 158 virtual ~BasicURLRequestContext() {} |
| 163 | 159 |
| 164 private: | 160 private: |
| 165 std::string user_agent_; | 161 std::string user_agent_; |
| 166 base::Thread cache_thread_; | 162 base::Thread cache_thread_; |
| 167 base::Thread file_thread_; | 163 base::Thread file_thread_; |
| 168 URLRequestContextStorage storage_; | 164 URLRequestContextStorage storage_; |
| 169 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); | 165 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); |
| 170 }; | 166 }; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 201 void URLRequestContextBuilder::set_proxy_config_service( | 197 void URLRequestContextBuilder::set_proxy_config_service( |
| 202 ProxyConfigService* proxy_config_service) { | 198 ProxyConfigService* proxy_config_service) { |
| 203 proxy_config_service_.reset(proxy_config_service); | 199 proxy_config_service_.reset(proxy_config_service); |
| 204 } | 200 } |
| 205 #endif // defined(OS_LINUX) | 201 #endif // defined(OS_LINUX) |
| 206 | 202 |
| 207 URLRequestContext* URLRequestContextBuilder::Build() { | 203 URLRequestContext* URLRequestContextBuilder::Build() { |
| 208 BasicURLRequestContext* context = new BasicURLRequestContext; | 204 BasicURLRequestContext* context = new BasicURLRequestContext; |
| 209 URLRequestContextStorage* storage = context->storage(); | 205 URLRequestContextStorage* storage = context->storage(); |
| 210 | 206 |
| 211 context->set_user_agent(user_agent_); | 207 storage->set_http_user_agent_settings(new ConstHttpUserAgentSettings( |
| 208 EmptyString(), EmptyString(), user_agent_)); |
| 212 | 209 |
| 213 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; | 210 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; |
| 214 storage->set_network_delegate(network_delegate); | 211 storage->set_network_delegate(network_delegate); |
| 215 | 212 |
| 216 net::HostResolver* host_resolver = net::CreateSystemHostResolver( | 213 net::HostResolver* host_resolver = net::CreateSystemHostResolver( |
| 217 host_resolver_params_.parallelism, | 214 host_resolver_params_.parallelism, |
| 218 host_resolver_params_.retry_attempts, | 215 host_resolver_params_.retry_attempts, |
| 219 NULL /* no NetLog */); | 216 NULL /* no NetLog */); |
| 220 storage->set_host_resolver(host_resolver); | 217 storage->set_host_resolver(host_resolver); |
| 221 | 218 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 http_transaction_factory = new HttpNetworkLayer(network_session); | 299 http_transaction_factory = new HttpNetworkLayer(network_session); |
| 303 } | 300 } |
| 304 storage->set_http_transaction_factory(http_transaction_factory); | 301 storage->set_http_transaction_factory(http_transaction_factory); |
| 305 | 302 |
| 306 // TODO(willchan): Support sdch. | 303 // TODO(willchan): Support sdch. |
| 307 | 304 |
| 308 return context; | 305 return context; |
| 309 } | 306 } |
| 310 | 307 |
| 311 } // namespace net | 308 } // namespace net |
| OLD | NEW |