OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/service/net/service_url_request_context.h" | 5 #include "chrome/service/net/service_url_request_context.h" |
6 | 6 |
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
8 #include <sys/utsname.h> | 8 #include <sys/utsname.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 http_auth_handler_factory_, | 132 http_auth_handler_factory_, |
133 NULL /* network_delegate */, | 133 NULL /* network_delegate */, |
134 NULL /* net_log */), | 134 NULL /* net_log */), |
135 net::HttpCache::DefaultBackend::InMemory(0)); | 135 net::HttpCache::DefaultBackend::InMemory(0)); |
136 // In-memory cookie store. | 136 // In-memory cookie store. |
137 cookie_store_ = new net::CookieMonster(NULL, NULL); | 137 cookie_store_ = new net::CookieMonster(NULL, NULL); |
138 accept_language_ = "en-us,fr"; | 138 accept_language_ = "en-us,fr"; |
139 accept_charset_ = "iso-8859-1,*,utf-8"; | 139 accept_charset_ = "iso-8859-1,*,utf-8"; |
140 } | 140 } |
141 | 141 |
| 142 const std::string& ServiceURLRequestContext::GetUserAgent( |
| 143 const GURL& url) const { |
| 144 // If the user agent is set explicitly return that, otherwise call the |
| 145 // base class method to return default value. |
| 146 return user_agent_.empty() ? |
| 147 URLRequestContext::GetUserAgent(url) : user_agent_; |
| 148 } |
| 149 |
142 ServiceURLRequestContext::~ServiceURLRequestContext() { | 150 ServiceURLRequestContext::~ServiceURLRequestContext() { |
143 delete ftp_transaction_factory_; | 151 delete ftp_transaction_factory_; |
144 delete http_transaction_factory_; | 152 delete http_transaction_factory_; |
145 delete http_auth_handler_factory_; | 153 delete http_auth_handler_factory_; |
146 delete dnsrr_resolver_; | 154 delete dnsrr_resolver_; |
147 } | 155 } |
148 | 156 |
149 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() | 157 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() |
150 : io_message_loop_proxy_( | 158 : io_message_loop_proxy_( |
151 g_service_process->io_thread()->message_loop_proxy()) { | 159 g_service_process->io_thread()->message_loop_proxy()) { |
152 // Build the default user agent. | 160 // Build the default user agent. |
153 user_agent_ = MakeUserAgentForServiceProcess(); | 161 user_agent_ = MakeUserAgentForServiceProcess(); |
154 } | 162 } |
155 | 163 |
156 URLRequestContext* | 164 URLRequestContext* |
157 ServiceURLRequestContextGetter::GetURLRequestContext() { | 165 ServiceURLRequestContextGetter::GetURLRequestContext() { |
158 if (!url_request_context_) | 166 if (!url_request_context_) |
159 url_request_context_ = new ServiceURLRequestContext(user_agent_); | 167 url_request_context_ = new ServiceURLRequestContext(user_agent_); |
160 return url_request_context_; | 168 return url_request_context_; |
161 } | 169 } |
162 | 170 |
163 scoped_refptr<base::MessageLoopProxy> | 171 scoped_refptr<base::MessageLoopProxy> |
164 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { | 172 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { |
165 return io_message_loop_proxy_; | 173 return io_message_loop_proxy_; |
166 } | 174 } |
167 | 175 |
168 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 176 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
OLD | NEW |