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 #ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ |
6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/cookies/cookie_monster.h" | 11 #include "net/cookies/cookie_monster.h" |
12 #include "net/disk_cache/disk_cache.h" | 12 #include "net/disk_cache/disk_cache.h" |
13 #include "net/dns/host_resolver.h" | 13 #include "net/dns/host_resolver.h" |
14 #include "net/ftp/ftp_network_layer.h" | 14 #include "net/ftp/ftp_network_layer.h" |
15 #include "net/http/http_auth_handler_factory.h" | 15 #include "net/http/http_auth_handler_factory.h" |
16 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
17 #include "net/http/http_network_layer.h" | 17 #include "net/http/http_network_layer.h" |
18 #include "net/ssl/ssl_config_service_defaults.h" | 18 #include "net/ssl/ssl_config_service_defaults.h" |
19 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
20 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
21 #include "net/url_request/url_request_context_storage.h" | 21 #include "net/url_request/url_request_context_storage.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class MessageLoopProxy; | 24 class MessageLoopProxy; |
25 } | 25 } |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 class ProxyConfigService; | 28 class ProxyConfigService; |
29 } | 29 } |
30 | 30 |
31 // Subclass of net::URLRequestContext which can be used to store extra | |
32 // information for requests. This subclass is meant to be used in the service | |
33 // process where the profile is not available. | |
34 // | |
35 class ServiceURLRequestContext : public net::URLRequestContext { | |
36 public: | |
37 // This context takes ownership of |net_proxy_config_service|. | |
38 explicit ServiceURLRequestContext( | |
39 const std::string& user_agent, | |
40 net::ProxyConfigService* net_proxy_config_service); | |
41 | |
42 virtual ~ServiceURLRequestContext(); | |
43 | |
44 private: | |
45 net::URLRequestContextStorage storage_; | |
46 }; | |
47 | |
48 class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { | 31 class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { |
49 public: | 32 public: |
50 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; | 33 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; |
51 virtual scoped_refptr<base::SingleThreadTaskRunner> | 34 virtual scoped_refptr<base::SingleThreadTaskRunner> |
52 GetNetworkTaskRunner() const OVERRIDE; | 35 GetNetworkTaskRunner() const OVERRIDE; |
53 | 36 |
54 void set_user_agent(const std::string& ua) { | 37 void set_user_agent(const std::string& ua) { |
55 user_agent_ = ua; | 38 user_agent_ = ua; |
56 } | 39 } |
57 std::string user_agent() const { | 40 std::string user_agent() const { |
58 return user_agent_; | 41 return user_agent_; |
59 } | 42 } |
60 | 43 |
61 private: | 44 private: |
62 friend class ServiceProcess; | 45 friend class ServiceProcess; |
63 ServiceURLRequestContextGetter(); | 46 ServiceURLRequestContextGetter(); |
64 virtual ~ServiceURLRequestContextGetter(); | 47 virtual ~ServiceURLRequestContextGetter(); |
65 | 48 |
66 std::string user_agent_; | 49 std::string user_agent_; |
67 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
68 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 51 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
69 scoped_ptr<net::URLRequestContext> url_request_context_; | 52 scoped_ptr<net::URLRequestContext> url_request_context_; |
70 }; | 53 }; |
71 | 54 |
72 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 55 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ |
OLD | NEW |