Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chromecast/shell/browser/url_request_context_factory.h

Issue 638803002: Reorganizes Chromecast code to better reflect functional dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extra DEPS: chromecast/crash/android --> chromecast/common Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
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 HttpTransactionFactory;
13 class HttpUserAgentSettings;
14 class ProxyConfigService;
15 class URLRequestJobFactory;
16 } // namespace net
17
18 namespace chromecast {
19 namespace shell {
20 class CastNetworkDelegate;
21
22 class URLRequestContextFactory {
23 public:
24 URLRequestContextFactory();
25 ~URLRequestContextFactory();
26
27 // Some members must be initialized on UI thread.
28 void InitializeOnUIThread();
29
30 // Since main context requires a bunch of input params, if these get called
31 // multiple times, either multiple main contexts should be supported/managed
32 // or the input params need to be the same as before. So to be safe,
33 // the CreateMainGetter function currently DCHECK to make sure it is not
34 // called more than once.
35 // The media and system getters however, do not need input, so it is actually
36 // safe to call these multiple times. The impl create only 1 getter of each
37 // type and return the same instance each time the methods are called, thus
38 // the name difference.
39 net::URLRequestContextGetter* GetSystemGetter();
40 net::URLRequestContextGetter* CreateMainGetter(
41 content::BrowserContext* browser_context,
42 content::ProtocolHandlerMap* protocol_handlers,
43 content::URLRequestInterceptorScopedVector request_interceptors);
44 net::URLRequestContextGetter* GetMainGetter();
45 net::URLRequestContextGetter* GetMediaGetter();
46
47 CastNetworkDelegate* app_network_delegate() const {
48 return app_network_delegate_.get();
49 }
50
51 // Initialize the CastNetworkDelegate objects. This needs to be done
52 // after the CastService is created, but before any URL requests are made.
53 void InitializeNetworkDelegates();
54
55 private:
56 class URLRequestContextGetter;
57 class MainURLRequestContextGetter;
58 friend class URLRequestContextGetter;
59 friend class MainURLRequestContextGetter;
60
61 void InitializeSystemContextDependencies();
62 void InitializeMainContextDependencies(
63 net::HttpTransactionFactory* factory,
64 content::ProtocolHandlerMap* protocol_handlers,
65 content::URLRequestInterceptorScopedVector request_interceptors);
66 void InitializeMediaContextDependencies(net::HttpTransactionFactory* factory);
67
68 void PopulateNetworkSessionParams(bool ignore_certificate_errors,
69 net::HttpNetworkSession::Params* params);
70
71 // These are called by the RequestContextGetters to create each
72 // RequestContext.
73 // They must be called on the IO thread.
74 net::URLRequestContext* CreateSystemRequestContext();
75 net::URLRequestContext* CreateMediaRequestContext();
76 net::URLRequestContext* CreateMainRequestContext(
77 content::BrowserContext* browser_context,
78 content::ProtocolHandlerMap* protocol_handlers,
79 content::URLRequestInterceptorScopedVector request_interceptors);
80
81 scoped_refptr<net::URLRequestContextGetter> system_getter_;
82 scoped_refptr<net::URLRequestContextGetter> media_getter_;
83 scoped_refptr<net::URLRequestContextGetter> main_getter_;
84 scoped_ptr<CastNetworkDelegate> app_network_delegate_;
85 scoped_ptr<CastNetworkDelegate> system_network_delegate_;
86
87 // Shared objects for all contexts.
88 // The URLRequestContextStorage class is not used as owner to these objects
89 // since they are shared between the different URLRequestContexts.
90 // The URLRequestContextStorage class manages dependent resources for a single
91 // instance of URLRequestContext only.
92 bool system_dependencies_initialized_;
93 scoped_ptr<net::HostResolver> host_resolver_;
94 scoped_ptr<net::ChannelIDService> channel_id_service_;
95 scoped_ptr<net::CertVerifier> cert_verifier_;
96 scoped_refptr<net::SSLConfigService> ssl_config_service_;
97 scoped_ptr<net::TransportSecurityState> transport_security_state_;
98 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
99 scoped_ptr<net::ProxyService> proxy_service_;
100 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_;
101 scoped_ptr<net::HttpServerProperties> http_server_properties_;
102 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_;
103 scoped_ptr<net::HttpTransactionFactory> system_transaction_factory_;
104 scoped_ptr<net::URLRequestJobFactory> system_job_factory_;
105
106 bool main_dependencies_initialized_;
107 scoped_ptr<net::HttpTransactionFactory> main_transaction_factory_;
108 scoped_ptr<net::URLRequestJobFactory> main_job_factory_;
109
110 bool media_dependencies_initialized_;
111 scoped_ptr<net::HttpTransactionFactory> media_transaction_factory_;
112 };
113
114 } // namespace shell
115 } // namespace chromecast
116
117 #endif // CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698