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

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

Issue 598303002: Chromecast: adds CastNetworkDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uploads CastNetworkDelegate :) 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ 5 #ifndef CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
6 #define CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ 6 #define CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
7 7
8 #include "content/public/browser/content_browser_client.h" 8 #include "content/public/browser/content_browser_client.h"
9 #include "net/http/http_network_session.h" 9 #include "net/http/http_network_session.h"
10 10
11 namespace net { 11 namespace net {
12 class HttpTransactionFactory; 12 class HttpTransactionFactory;
13 class HttpUserAgentSettings; 13 class HttpUserAgentSettings;
14 class ProxyConfigService; 14 class ProxyConfigService;
15 class URLRequestJobFactory; 15 class URLRequestJobFactory;
16 } // namespace net 16 } // namespace net
17 17
18 namespace chromecast { 18 namespace chromecast {
19 class CastNetworkDelegate;
20
19 namespace shell { 21 namespace shell {
20 22
21 class URLRequestContextFactory { 23 class URLRequestContextFactory {
22 public: 24 public:
23 URLRequestContextFactory(); 25 URLRequestContextFactory();
24 ~URLRequestContextFactory(); 26 ~URLRequestContextFactory();
25 27
26 // Some members must be initialized on UI thread. 28 // Some members must be initialized on UI thread.
27 void InitializeOnUIThread(); 29 void InitializeOnUIThread();
28 30
29 // Since main context requires a bunch of input params, if these get called 31 // Since main context requires a bunch of input params, if these get called
30 // multiple times, either multiple main contexts should be supported/managed 32 // multiple times, either multiple main contexts should be supported/managed
31 // or the input params need to be the same as before. So to be safe, 33 // or the input params need to be the same as before. So to be safe,
32 // the CreateMainGetter function currently DCHECK to make sure it is not 34 // the CreateMainGetter function currently DCHECK to make sure it is not
33 // called more than once. 35 // called more than once.
34 // The media and system getters however, do not need input, so it is actually 36 // The media and system getters however, do not need input, so it is actually
35 // safe to call these multiple times. The impl create only 1 getter of each 37 // safe to call these multiple times. The impl create only 1 getter of each
36 // type and return the same instance each time the methods are called, thus 38 // type and return the same instance each time the methods are called, thus
37 // the name difference. 39 // the name difference.
38 net::URLRequestContextGetter* GetSystemGetter(); 40 net::URLRequestContextGetter* GetSystemGetter();
39 net::URLRequestContextGetter* CreateMainGetter( 41 net::URLRequestContextGetter* CreateMainGetter(
40 content::BrowserContext* browser_context, 42 content::BrowserContext* browser_context,
41 content::ProtocolHandlerMap* protocol_handlers, 43 content::ProtocolHandlerMap* protocol_handlers,
42 content::URLRequestInterceptorScopedVector request_interceptors); 44 content::URLRequestInterceptorScopedVector request_interceptors);
43 net::URLRequestContextGetter* GetMainGetter(); 45 net::URLRequestContextGetter* GetMainGetter();
44 net::URLRequestContextGetter* GetMediaGetter(); 46 net::URLRequestContextGetter* GetMediaGetter();
45 47
48 CastNetworkDelegate* app_network_delegate() const {
49 return app_network_delegate_.get();
50 }
51
52 // Initialize the CastNetworkDelegate objects. This needs to be done
53 // after the CastService is created, but before any URL requests are made.
54 void InitializeNetworkDelegates();
55
46 private: 56 private:
47 class URLRequestContextGetter; 57 class URLRequestContextGetter;
48 class MainURLRequestContextGetter; 58 class MainURLRequestContextGetter;
49 friend class URLRequestContextGetter; 59 friend class URLRequestContextGetter;
50 friend class MainURLRequestContextGetter; 60 friend class MainURLRequestContextGetter;
51 61
52 void InitializeSystemContextDependencies(); 62 void InitializeSystemContextDependencies();
53 void InitializeMainContextDependencies( 63 void InitializeMainContextDependencies(
54 net::HttpTransactionFactory* factory, 64 net::HttpTransactionFactory* factory,
55 content::ProtocolHandlerMap* protocol_handlers, 65 content::ProtocolHandlerMap* protocol_handlers,
56 content::URLRequestInterceptorScopedVector request_interceptors); 66 content::URLRequestInterceptorScopedVector request_interceptors);
57 void InitializeMediaContextDependencies(net::HttpTransactionFactory* factory); 67 void InitializeMediaContextDependencies(net::HttpTransactionFactory* factory);
58 68
59 void PopulateNetworkSessionParams(bool ignore_certificate_errors, 69 void PopulateNetworkSessionParams(bool ignore_certificate_errors,
60 net::HttpNetworkSession::Params* params); 70 net::HttpNetworkSession::Params* params);
61 71
62 // These are called by the RequestContextGetters to create each 72 // These are called by the RequestContextGetters to create each
63 // RequestContext. 73 // RequestContext.
64 // They must be called on the IO thread. 74 // They must be called on the IO thread.
65 net::URLRequestContext* CreateSystemRequestContext(); 75 net::URLRequestContext* CreateSystemRequestContext();
66 net::URLRequestContext* CreateMediaRequestContext(); 76 net::URLRequestContext* CreateMediaRequestContext();
67 net::URLRequestContext* CreateMainRequestContext( 77 net::URLRequestContext* CreateMainRequestContext(
68 content::BrowserContext* browser_context, 78 content::BrowserContext* browser_context,
69 content::ProtocolHandlerMap* protocol_handlers, 79 content::ProtocolHandlerMap* protocol_handlers,
70 content::URLRequestInterceptorScopedVector request_interceptors); 80 content::URLRequestInterceptorScopedVector request_interceptors);
71 81
72 scoped_refptr<net::URLRequestContextGetter> system_getter_; 82 scoped_refptr<net::URLRequestContextGetter> system_getter_;
73 scoped_refptr<net::URLRequestContextGetter> media_getter_; 83 scoped_refptr<net::URLRequestContextGetter> media_getter_;
74 scoped_refptr<net::URLRequestContextGetter> main_getter_; 84 scoped_refptr<net::URLRequestContextGetter> main_getter_;
85 scoped_ptr<CastNetworkDelegate> app_network_delegate_;
86 scoped_ptr<CastNetworkDelegate> system_network_delegate_;
75 87
76 // Shared objects for all contexts. 88 // Shared objects for all contexts.
77 // The URLRequestContextStorage class is not used as owner to these objects 89 // The URLRequestContextStorage class is not used as owner to these objects
78 // since they are shared between the different URLRequestContexts. 90 // since they are shared between the different URLRequestContexts.
79 // The URLRequestContextStorage class manages dependent resources for a single 91 // The URLRequestContextStorage class manages dependent resources for a single
80 // instance of URLRequestContext only. 92 // instance of URLRequestContext only.
81 bool system_dependencies_initialized_; 93 bool system_dependencies_initialized_;
82 scoped_ptr<net::HostResolver> host_resolver_; 94 scoped_ptr<net::HostResolver> host_resolver_;
83 scoped_ptr<net::ChannelIDService> channel_id_service_; 95 scoped_ptr<net::ChannelIDService> channel_id_service_;
84 scoped_ptr<net::CertVerifier> cert_verifier_; 96 scoped_ptr<net::CertVerifier> cert_verifier_;
(...skipping 11 matching lines...) Expand all
96 scoped_ptr<net::URLRequestJobFactory> main_job_factory_; 108 scoped_ptr<net::URLRequestJobFactory> main_job_factory_;
97 109
98 bool media_dependencies_initialized_; 110 bool media_dependencies_initialized_;
99 scoped_ptr<net::HttpTransactionFactory> media_transaction_factory_; 111 scoped_ptr<net::HttpTransactionFactory> media_transaction_factory_;
100 }; 112 };
101 113
102 } // namespace shell 114 } // namespace shell
103 } // namespace chromecast 115 } // namespace chromecast
104 116
105 #endif // CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_ 117 #endif // CHROMECAST_SHELL_BROWSER_URL_REQUEST_CONTEXT_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698