OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ | |
6 #define CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ | |
7 | |
8 #include "content/public/browser/content_browser_client.h" | |
9 #include "net/http/http_network_session.h" | |
10 | |
11 namespace net { | |
12 class CertVerifier; | |
13 class HostResolver; | |
14 class HttpAuthHandlerFactory; | |
15 class HttpServerProperties; | |
16 class HttpTransactionFactory; | |
17 class HttpUserAgentSettings; | |
18 class ProxyService; | |
19 class ServerBoundCertService; | |
20 class SSLConfigService; | |
21 class URLRequestContext; | |
22 class URLRequestContextGetter; | |
23 class URLRequestJobFactoryImpl; | |
24 } // namespace net | |
jam
2014/07/01 21:56:10
don't need most (or all) of these
lcwu1
2014/07/02 23:30:33
Done.
| |
25 | |
26 namespace chromecast { | |
27 namespace shell { | |
28 | |
29 class URLRequestContextFactory { | |
30 public: | |
31 URLRequestContextFactory(); | |
32 ~URLRequestContextFactory(); | |
33 | |
34 // Some members must be initialized on UI thread. | |
35 void InitializeOnUIThread(); | |
36 | |
37 // Since main context requires a bunch of input params, if these get called | |
38 // multiple times, we would either need to manage multiple main contexts or | |
39 // make sure that the input params are the same as before. So to be safe, | |
40 // the CreateMainGetter function currently DCHECK to make sure it is not | |
41 // called more than once. | |
42 // The media and system getters however, do not need input, so it is actually | |
43 // safe to call these multiple times. The impl create only 1 getter of each | |
44 // type and return the same instance each time the methods are called, thus | |
45 // the name difference. | |
46 net::URLRequestContextGetter* GetSystemGetter(); | |
47 net::URLRequestContextGetter* CreateMainGetter( | |
48 content::BrowserContext* browser_context, | |
49 content::ProtocolHandlerMap* protocol_handlers); | |
50 net::URLRequestContextGetter* GetMainGetter(); | |
51 net::URLRequestContextGetter* GetMediaGetter(); | |
52 | |
53 private: | |
54 class URLRequestContextGetter; | |
55 class MainURLRequestContextGetter; | |
56 friend class URLRequestContextGetter; | |
57 friend class MainURLRequestContextGetter; | |
58 | |
59 void InitializeSystemContextDependencies(); | |
60 void InitializeMainContextDependencies( | |
61 net::HttpTransactionFactory* factory, | |
62 content::ProtocolHandlerMap* protocol_handlers); | |
63 void InitializeMediaContextDependencies(net::HttpTransactionFactory* factory); | |
64 | |
65 void PopulateNetworkSessionParams(bool ignore_certificate_errors, | |
66 net::HttpNetworkSession::Params* params); | |
67 | |
68 // These are called by the RequestContextGetters to create each | |
69 // RequestContext. | |
70 // They must be called on the IO thread. | |
71 net::URLRequestContext* CreateSystemRequestContext(); | |
72 net::URLRequestContext* CreateMediaRequestContext(); | |
73 net::URLRequestContext* CreateMainRequestContext( | |
74 content::BrowserContext* browser_context, | |
75 content::ProtocolHandlerMap* protocol_handlers); | |
76 | |
77 scoped_refptr<net::URLRequestContextGetter> system_getter_; | |
78 scoped_refptr<net::URLRequestContextGetter> media_getter_; | |
79 scoped_refptr<net::URLRequestContextGetter> main_getter_; | |
80 | |
81 // Shared objects for all contexts | |
82 // We do not use the URLRequestContextStorage class as owner to these objects | |
83 // since they are shared between the different URLRequestContexts. | |
84 // The URLRequestContextStorage class manages dependent resources for a single | |
85 // instance of URLRequestContext only. | |
86 bool system_dependencies_initialized_; | |
87 scoped_ptr<net::HostResolver> host_resolver_; | |
88 scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_; | |
89 scoped_ptr<net::CertVerifier> cert_verifier_; | |
90 scoped_refptr<net::SSLConfigService> ssl_config_service_; | |
91 scoped_ptr<net::TransportSecurityState> transport_security_state_; | |
92 scoped_ptr<net::ProxyService> proxy_service_; | |
93 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; | |
94 scoped_ptr<net::HttpServerProperties> http_server_properties_; | |
95 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_; | |
96 scoped_ptr<net::HttpTransactionFactory> system_transaction_factory_; | |
97 | |
98 bool main_dependencies_initialized_; | |
99 scoped_ptr<net::HttpTransactionFactory> main_transaction_factory_; | |
100 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory_; | |
101 | |
102 bool media_dependencies_initialized_; | |
103 scoped_ptr<net::HttpTransactionFactory> media_transaction_factory_; | |
104 }; | |
105 | |
106 } // namespace shell | |
107 } // namespace chromecast | |
108 | |
109 #endif // CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ | |
OLD | NEW |