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