Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / browser / url_request_context_factory.h
blobc0d881d83f9c01415761ff08ca15c79a80a8e0c2
1 // Copyright 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.
5 #ifndef CHROMECAST_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
6 #define CHROMECAST_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
8 #include "content/public/browser/content_browser_client.h"
9 #include "net/http/http_network_session.h"
11 namespace net {
12 class HttpTransactionFactory;
13 class HttpUserAgentSettings;
14 class NetLog;
15 class ProxyConfigService;
16 class URLRequestJobFactory;
17 } // namespace net
19 namespace chromecast {
20 namespace shell {
21 class CastNetworkDelegate;
23 class URLRequestContextFactory {
24 public:
25 URLRequestContextFactory();
26 ~URLRequestContextFactory();
28 // Some members must be initialized on UI thread.
29 void InitializeOnUIThread(net::NetLog* net_log);
31 // Since main context requires a bunch of input params, if these get called
32 // multiple times, either multiple main contexts should be supported/managed
33 // or the input params need to be the same as before. So to be safe,
34 // the CreateMainGetter function currently DCHECK to make sure it is not
35 // called more than once.
36 // The media and system getters however, do not need input, so it is actually
37 // safe to call these multiple times. The impl create only 1 getter of each
38 // type and return the same instance each time the methods are called, thus
39 // the name difference.
40 net::URLRequestContextGetter* GetSystemGetter();
41 net::URLRequestContextGetter* CreateMainGetter(
42 content::BrowserContext* browser_context,
43 content::ProtocolHandlerMap* protocol_handlers,
44 content::URLRequestInterceptorScopedVector request_interceptors);
45 net::URLRequestContextGetter* GetMainGetter();
46 net::URLRequestContextGetter* GetMediaGetter();
48 CastNetworkDelegate* app_network_delegate() const {
49 return app_network_delegate_.get();
52 net::HostResolver* host_resolver() const {
53 return host_resolver_.get();
56 // Initialize the CastNetworkDelegate objects. This needs to be done
57 // after the CastService is created, but before any URL requests are made.
58 void InitializeNetworkDelegates();
60 private:
61 class URLRequestContextGetter;
62 class MainURLRequestContextGetter;
63 friend class URLRequestContextGetter;
64 friend class MainURLRequestContextGetter;
66 void InitializeSystemContextDependencies();
67 void InitializeMainContextDependencies(
68 net::HttpTransactionFactory* factory,
69 content::ProtocolHandlerMap* protocol_handlers,
70 content::URLRequestInterceptorScopedVector request_interceptors);
71 void InitializeMediaContextDependencies(net::HttpTransactionFactory* factory);
73 void PopulateNetworkSessionParams(bool ignore_certificate_errors,
74 net::HttpNetworkSession::Params* params);
76 // These are called by the RequestContextGetters to create each
77 // RequestContext.
78 // They must be called on the IO thread.
79 net::URLRequestContext* CreateSystemRequestContext();
80 net::URLRequestContext* CreateMediaRequestContext();
81 net::URLRequestContext* CreateMainRequestContext(
82 content::BrowserContext* browser_context,
83 content::ProtocolHandlerMap* protocol_handlers,
84 content::URLRequestInterceptorScopedVector request_interceptors);
86 scoped_refptr<net::URLRequestContextGetter> system_getter_;
87 scoped_refptr<net::URLRequestContextGetter> media_getter_;
88 scoped_refptr<net::URLRequestContextGetter> main_getter_;
89 scoped_ptr<CastNetworkDelegate> app_network_delegate_;
90 scoped_ptr<CastNetworkDelegate> system_network_delegate_;
92 // Shared objects for all contexts.
93 // The URLRequestContextStorage class is not used as owner to these objects
94 // since they are shared between the different URLRequestContexts.
95 // The URLRequestContextStorage class manages dependent resources for a single
96 // instance of URLRequestContext only.
97 bool system_dependencies_initialized_;
98 scoped_ptr<net::HostResolver> host_resolver_;
99 scoped_ptr<net::ChannelIDService> channel_id_service_;
100 scoped_ptr<net::CertVerifier> cert_verifier_;
101 scoped_refptr<net::SSLConfigService> ssl_config_service_;
102 scoped_ptr<net::TransportSecurityState> transport_security_state_;
103 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
104 scoped_ptr<net::ProxyService> proxy_service_;
105 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_;
106 scoped_ptr<net::HttpServerProperties> http_server_properties_;
107 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_;
108 scoped_ptr<net::HttpTransactionFactory> system_transaction_factory_;
109 scoped_ptr<net::URLRequestJobFactory> system_job_factory_;
111 bool main_dependencies_initialized_;
112 scoped_ptr<net::HttpTransactionFactory> main_transaction_factory_;
113 scoped_ptr<net::URLRequestJobFactory> main_job_factory_;
115 bool media_dependencies_initialized_;
116 scoped_ptr<net::HttpTransactionFactory> media_transaction_factory_;
118 net::NetLog* net_log_;
121 } // namespace shell
122 } // namespace chromecast
124 #endif // CHROMECAST_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_