OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class ChannelIDService; | 49 class ChannelIDService; |
50 class CookieStore; | 50 class CookieStore; |
51 class CTVerifier; | 51 class CTVerifier; |
52 class HttpAuthHandlerFactory; | 52 class HttpAuthHandlerFactory; |
53 class HttpServerProperties; | 53 class HttpServerProperties; |
54 class NetworkQualityEstimator; | 54 class NetworkQualityEstimator; |
55 class ProxyConfigService; | 55 class ProxyConfigService; |
56 class URLRequestContext; | 56 class URLRequestContext; |
57 class URLRequestInterceptor; | 57 class URLRequestInterceptor; |
58 | 58 |
| 59 // A URLRequestContextBuilder creates a single URLRequestContext. It provides |
| 60 // methods to manage various URLRequestContext components which should be called |
| 61 // before creating the Context. Once configuration is complete, calling Build() |
| 62 // will create a URLRequestContext with the specified configuration. Components |
| 63 // that are not explicitly configured will use reasonable in-memory defaults. |
| 64 // |
| 65 // The returned URLRequestContext is self-contained: Deleting it will safely |
| 66 // shut down all of the URLRequests owned by its internal components, and then |
| 67 // tear down those components. The only exception to this are objects not owned |
| 68 // by URLRequestContext. This includes components passed in to the methods that |
| 69 // take raw pointers, and objects that components passed in to the Builder have |
| 70 // raw pointers to. |
| 71 // |
| 72 // A Builder should be destroyed after calling Build, and there is no need to |
| 73 // keep it around for the lifetime of the created URLRequestContext. Each |
| 74 // Builder may be used to create only a single URLRequestContext. |
59 class NET_EXPORT URLRequestContextBuilder { | 75 class NET_EXPORT URLRequestContextBuilder { |
60 public: | 76 public: |
61 struct NET_EXPORT HttpCacheParams { | 77 struct NET_EXPORT HttpCacheParams { |
62 enum Type { | 78 enum Type { |
63 // In-memory cache. | 79 // In-memory cache. |
64 IN_MEMORY, | 80 IN_MEMORY, |
65 // Disk cache using "default" backend. | 81 // Disk cache using "default" backend. |
66 DISK, | 82 DISK, |
67 // Disk cache using "simple" backend (SimpleBackendImpl). | 83 // Disk cache using "simple" backend (SimpleBackendImpl). |
68 DISK_SIMPLE, | 84 DISK_SIMPLE, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // result will be "Content-Encoding: sdch" advertisements, but no | 323 // result will be "Content-Encoding: sdch" advertisements, but no |
308 // dictionaries fetches and no specific dictionaries advertised. | 324 // dictionaries fetches and no specific dictionaries advertised. |
309 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 325 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
310 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 326 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
311 | 327 |
312 // Sets a specific HttpServerProperties for use in the | 328 // Sets a specific HttpServerProperties for use in the |
313 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. | 329 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. |
314 void SetHttpServerProperties( | 330 void SetHttpServerProperties( |
315 std::unique_ptr<HttpServerProperties> http_server_properties); | 331 std::unique_ptr<HttpServerProperties> http_server_properties); |
316 | 332 |
| 333 // Creates a mostly self-contained URLRequestContext. May only be called once |
| 334 // per URLRequestContextBuilder. After this is called, the Builder can be |
| 335 // safely destroyed. |
317 std::unique_ptr<URLRequestContext> Build(); | 336 std::unique_ptr<URLRequestContext> Build(); |
318 | 337 |
319 protected: | 338 protected: |
320 // Lets subclasses override ProxyService creation, using a ProxyService that | 339 // Lets subclasses override ProxyService creation, using a ProxyService that |
321 // uses the URLRequestContext itself to get PAC scripts. When this method is | 340 // uses the URLRequestContext itself to get PAC scripts. When this method is |
322 // invoked, the URLRequestContext is not yet ready to service requests. | 341 // invoked, the URLRequestContext is not yet ready to service requests. |
323 virtual std::unique_ptr<ProxyService> CreateProxyService( | 342 virtual std::unique_ptr<ProxyService> CreateProxyService( |
324 std::unique_ptr<ProxyConfigService> proxy_config_service, | 343 std::unique_ptr<ProxyConfigService> proxy_config_service, |
325 URLRequestContext* url_request_context, | 344 URLRequestContext* url_request_context, |
326 HostResolver* host_resolver, | 345 HostResolver* host_resolver, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 std::unique_ptr<HttpServerProperties> http_server_properties_; | 389 std::unique_ptr<HttpServerProperties> http_server_properties_; |
371 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>> | 390 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>> |
372 protocol_handlers_; | 391 protocol_handlers_; |
373 | 392 |
374 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 393 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
375 }; | 394 }; |
376 | 395 |
377 } // namespace net | 396 } // namespace net |
378 | 397 |
379 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 398 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
OLD | NEW |