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

Side by Side Diff: net/url_request/url_request_context_builder.h

Issue 1303493002: Make UrlRequestContextBuilder take scoped_ptr's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync and fix tiny resulting build failure Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This class is useful for building a simple URLRequestContext. Most creators 5 // This class is useful for building a simple URLRequestContext. Most creators
6 // of new URLRequestContexts should use this helper class to construct it. Call 6 // of new URLRequestContexts should use this helper class to construct it. Call
7 // any configuration params, and when done, invoke Build() to construct the 7 // any configuration params, and when done, invoke Build() to construct the
8 // URLRequestContext. This URLRequestContext will own all its own storage. 8 // URLRequestContext. This URLRequestContext will own all its own storage.
9 // 9 //
10 // URLRequestContextBuilder and its associated params classes are initially 10 // URLRequestContextBuilder and its associated params classes are initially
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Extracts the component pointers required to construct an HttpNetworkSession 93 // Extracts the component pointers required to construct an HttpNetworkSession
94 // and copies them into the Params used to create the session. This function 94 // and copies them into the Params used to create the session. This function
95 // should be used to ensure that a context and its associated 95 // should be used to ensure that a context and its associated
96 // HttpNetworkSession are consistent. 96 // HttpNetworkSession are consistent.
97 static void SetHttpNetworkSessionComponents( 97 static void SetHttpNetworkSessionComponents(
98 const URLRequestContext* context, 98 const URLRequestContext* context,
99 HttpNetworkSession::Params* params); 99 HttpNetworkSession::Params* params);
100 100
101 // These functions are mutually exclusive. The ProxyConfigService, if 101 // These functions are mutually exclusive. The ProxyConfigService, if
102 // set, will be used to construct a ProxyService. 102 // set, will be used to construct a ProxyService.
103 void set_proxy_config_service(ProxyConfigService* proxy_config_service) { 103 void set_proxy_config_service(
104 proxy_config_service_.reset(proxy_config_service); 104 scoped_ptr<ProxyConfigService> proxy_config_service) {
105 proxy_config_service_ = proxy_config_service.Pass();
105 } 106 }
106 void set_proxy_service(ProxyService* proxy_service) { 107 void set_proxy_service(scoped_ptr<ProxyService> proxy_service) {
107 proxy_service_.reset(proxy_service); 108 proxy_service_ = proxy_service.Pass();
108 } 109 }
109 110
110 // Call these functions to specify hard-coded Accept-Language 111 // Call these functions to specify hard-coded Accept-Language
111 // or User-Agent header values for all requests that don't 112 // or User-Agent header values for all requests that don't
112 // have the headers already set. 113 // have the headers already set.
113 void set_accept_language(const std::string& accept_language) { 114 void set_accept_language(const std::string& accept_language) {
114 accept_language_ = accept_language; 115 accept_language_ = accept_language;
115 } 116 }
116 void set_user_agent(const std::string& user_agent) { 117 void set_user_agent(const std::string& user_agent) {
117 user_agent_ = user_agent; 118 user_agent_ = user_agent;
(...skipping 11 matching lines...) Expand all
129 } 130 }
130 #endif 131 #endif
131 132
132 #if !defined(DISABLE_FTP_SUPPORT) 133 #if !defined(DISABLE_FTP_SUPPORT)
133 // Control support for ftp:// requests. By default it's disabled. 134 // Control support for ftp:// requests. By default it's disabled.
134 void set_ftp_enabled(bool enable) { 135 void set_ftp_enabled(bool enable) {
135 ftp_enabled_ = enable; 136 ftp_enabled_ = enable;
136 } 137 }
137 #endif 138 #endif
138 139
140 // Unlike the other setters, the builder does not take ownership of the
141 // NetLog.
139 // TODO(mmenke): Probably makes sense to get rid of this, and have consumers 142 // TODO(mmenke): Probably makes sense to get rid of this, and have consumers
140 // set their own NetLog::Observers instead. 143 // set their own NetLog::Observers instead.
141 void set_net_log(NetLog* net_log) { 144 void set_net_log(NetLog* net_log) { net_log_ = net_log; }
142 net_log_.reset(net_log);
143 }
144 145
145 // By default host_resolver is constructed with CreateDefaultResolver. 146 // By default host_resolver is constructed with CreateDefaultResolver.
146 void set_host_resolver(HostResolver* host_resolver) { 147 void set_host_resolver(scoped_ptr<HostResolver> host_resolver) {
147 host_resolver_.reset(host_resolver); 148 host_resolver_ = host_resolver.Pass();
148 } 149 }
149 150
150 // Uses BasicNetworkDelegate by default. Note that calling Build will unset 151 // Uses BasicNetworkDelegate by default. Note that calling Build will unset
151 // any custom delegate in builder, so this must be called each time before 152 // any custom delegate in builder, so this must be called each time before
152 // Build is called. 153 // Build is called.
153 void set_network_delegate(NetworkDelegate* delegate) { 154 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) {
154 network_delegate_.reset(delegate); 155 network_delegate_ = delegate.Pass();
155 } 156 }
156 157
157 // Adds additional auth handler factories to be used in addition to what is 158 // Adds additional auth handler factories to be used in addition to what is
158 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme| 159 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme|
159 // and |factory| are provided. The builder takes ownership of the factory and 160 // and |factory| are provided. The builder takes ownership of the factory and
160 // Build() must be called after this method. 161 // Build() must be called after this method.
161 void add_http_auth_handler_factory(const std::string& scheme, 162 void add_http_auth_handler_factory(const std::string& scheme,
162 HttpAuthHandlerFactory* factory) { 163 HttpAuthHandlerFactory* factory) {
163 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory)); 164 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory));
164 } 165 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // result will be "Content-Encoding: sdch" advertisements, but no 225 // result will be "Content-Encoding: sdch" advertisements, but no
225 // dictionaries fetches and no specific dictionaries advertised. 226 // dictionaries fetches and no specific dictionaries advertised.
226 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. 227 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object.
227 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } 228 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; }
228 229
229 // Sets a specific HttpServerProperties for use in the 230 // Sets a specific HttpServerProperties for use in the
230 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. 231 // URLRequestContext rather than creating a default HttpServerPropertiesImpl.
231 void SetHttpServerProperties( 232 void SetHttpServerProperties(
232 scoped_ptr<HttpServerProperties> http_server_properties); 233 scoped_ptr<HttpServerProperties> http_server_properties);
233 234
234 URLRequestContext* Build(); 235 scoped_ptr<URLRequestContext> Build();
235 236
236 private: 237 private:
237 struct NET_EXPORT SchemeFactory { 238 struct NET_EXPORT SchemeFactory {
238 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory); 239 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory);
239 ~SchemeFactory(); 240 ~SchemeFactory();
240 241
241 std::string scheme; 242 std::string scheme;
242 HttpAuthHandlerFactory* factory; 243 HttpAuthHandlerFactory* factory;
243 }; 244 };
244 245
(...skipping 11 matching lines...) Expand all
256 #endif 257 #endif
257 bool http_cache_enabled_; 258 bool http_cache_enabled_;
258 bool throttling_enabled_; 259 bool throttling_enabled_;
259 bool backoff_enabled_; 260 bool backoff_enabled_;
260 bool sdch_enabled_; 261 bool sdch_enabled_;
261 262
262 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 263 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
263 HttpCacheParams http_cache_params_; 264 HttpCacheParams http_cache_params_;
264 HttpNetworkSessionParams http_network_session_params_; 265 HttpNetworkSessionParams http_network_session_params_;
265 base::FilePath transport_security_persister_path_; 266 base::FilePath transport_security_persister_path_;
266 scoped_ptr<NetLog> net_log_; 267 NetLog* net_log_;
267 scoped_ptr<HostResolver> host_resolver_; 268 scoped_ptr<HostResolver> host_resolver_;
268 scoped_ptr<ChannelIDService> channel_id_service_; 269 scoped_ptr<ChannelIDService> channel_id_service_;
269 scoped_ptr<ProxyConfigService> proxy_config_service_; 270 scoped_ptr<ProxyConfigService> proxy_config_service_;
270 scoped_ptr<ProxyService> proxy_service_; 271 scoped_ptr<ProxyService> proxy_service_;
271 scoped_ptr<NetworkDelegate> network_delegate_; 272 scoped_ptr<NetworkDelegate> network_delegate_;
272 scoped_refptr<CookieStore> cookie_store_; 273 scoped_refptr<CookieStore> cookie_store_;
273 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; 274 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
274 std::vector<SchemeFactory> extra_http_auth_handlers_; 275 std::vector<SchemeFactory> extra_http_auth_handlers_;
275 ScopedVector<URLRequestInterceptor> url_request_interceptors_; 276 ScopedVector<URLRequestInterceptor> url_request_interceptors_;
276 scoped_ptr<HttpServerProperties> http_server_properties_; 277 scoped_ptr<HttpServerProperties> http_server_properties_;
277 278
278 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); 279 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
279 }; 280 };
280 281
281 } // namespace net 282 } // namespace net
282 283
283 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 284 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
OLDNEW
« no previous file with comments | « net/tools/get_server_time/get_server_time.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698