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

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

Issue 11931024: Removed static factories for data, ftp, file, and about jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r198785) Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_context.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 // populated with "sane" default values. Read through the comments to figure out 11 // populated with "sane" default values. Read through the comments to figure out
12 // what these are. 12 // what these are.
13 13
14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
16 16
17 #include <string> 17 #include <string>
18 18
19 #include "base/basictypes.h" 19 #include "base/basictypes.h"
20 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "net/base/net_export.h" 24 #include "net/base/net_export.h"
25 25
26 namespace net { 26 namespace net {
27 27
28 class FtpTransactionFactory;
28 class HostMappingRules; 29 class HostMappingRules;
29 class ProxyConfigService; 30 class ProxyConfigService;
30 class URLRequestContext; 31 class URLRequestContext;
31 class NetworkDelegate; 32 class NetworkDelegate;
32 33
33 class NET_EXPORT URLRequestContextBuilder { 34 class NET_EXPORT URLRequestContextBuilder {
34 public: 35 public:
35 struct NET_EXPORT HttpCacheParams { 36 struct NET_EXPORT HttpCacheParams {
36 enum Type { 37 enum Type {
37 IN_MEMORY, 38 IN_MEMORY,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // Call these functions to specify hard-coded Accept-Language 76 // Call these functions to specify hard-coded Accept-Language
76 // or User-Agent header values for all requests that don't 77 // or User-Agent header values for all requests that don't
77 // have the headers already set. 78 // have the headers already set.
78 void set_accept_language(const std::string& accept_language) { 79 void set_accept_language(const std::string& accept_language) {
79 accept_language_ = accept_language; 80 accept_language_ = accept_language;
80 } 81 }
81 void set_user_agent(const std::string& user_agent) { 82 void set_user_agent(const std::string& user_agent) {
82 user_agent_ = user_agent; 83 user_agent_ = user_agent;
83 } 84 }
84 85
85 // By default it's disabled. 86 // Control support for data:// requests. By default it's disabled.
87 void set_data_enabled(bool enable) {
88 data_enabled_ = enable;
89 }
90
91 // Control support for file:// requests. By default it's disabled.
92 void set_file_enabled(bool enable) {
93 file_enabled_ = enable;
94 }
95
96 #if !defined(DISABLE_FTP_SUPPORT)
97 // Control support for ftp:// requests. By default it's disabled.
86 void set_ftp_enabled(bool enable) { 98 void set_ftp_enabled(bool enable) {
87 ftp_enabled_ = enable; 99 ftp_enabled_ = enable;
88 } 100 }
101 #endif
89 102
90 // Uses BasicNetworkDelegate by default. Note that calling Build will unset 103 // Uses BasicNetworkDelegate by default. Note that calling Build will unset
91 // any custom delegate in builder, so this must be called each time before 104 // any custom delegate in builder, so this must be called each time before
92 // Build is called. 105 // Build is called.
93 void set_network_delegate(NetworkDelegate* delegate) { 106 void set_network_delegate(NetworkDelegate* delegate) {
94 network_delegate_.reset(delegate); 107 network_delegate_.reset(delegate);
95 } 108 }
96 109
97 // By default HttpCache is enabled with a default constructed HttpCacheParams. 110 // By default HttpCache is enabled with a default constructed HttpCacheParams.
98 void EnableHttpCache(const HttpCacheParams& params) { 111 void EnableHttpCache(const HttpCacheParams& params) {
99 http_cache_params_ = params; 112 http_cache_params_ = params;
100 } 113 }
101 114
102 void DisableHttpCache() { 115 void DisableHttpCache() {
103 http_cache_params_ = HttpCacheParams(); 116 http_cache_params_ = HttpCacheParams();
104 } 117 }
105 118
106 // Override default net::HttpNetworkSession::Params settings. 119 // Override default net::HttpNetworkSession::Params settings.
107 void set_http_network_session_params( 120 void set_http_network_session_params(
108 const HttpNetworkSessionParams& http_network_session_params) { 121 const HttpNetworkSessionParams& http_network_session_params) {
109 http_network_session_params_ = http_network_session_params; 122 http_network_session_params_ = http_network_session_params;
110 } 123 }
111 124
112 URLRequestContext* Build(); 125 URLRequestContext* Build();
113 126
114 private: 127 private:
115 std::string accept_language_; 128 std::string accept_language_;
116 std::string user_agent_; 129 std::string user_agent_;
130 // Include support for data:// requests.
131 bool data_enabled_;
132 // Include support for file:// requests.
133 bool file_enabled_;
134 #if !defined(DISABLE_FTP_SUPPORT)
135 // Include support for ftp:// requests.
117 bool ftp_enabled_; 136 bool ftp_enabled_;
137 #endif
118 bool http_cache_enabled_; 138 bool http_cache_enabled_;
119 HttpCacheParams http_cache_params_; 139 HttpCacheParams http_cache_params_;
120 HttpNetworkSessionParams http_network_session_params_; 140 HttpNetworkSessionParams http_network_session_params_;
121 #if defined(OS_LINUX) || defined(OS_ANDROID) 141 #if defined(OS_LINUX) || defined(OS_ANDROID)
122 scoped_ptr<ProxyConfigService> proxy_config_service_; 142 scoped_ptr<ProxyConfigService> proxy_config_service_;
123 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 143 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
124 scoped_ptr<NetworkDelegate> network_delegate_; 144 scoped_ptr<NetworkDelegate> network_delegate_;
145 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
125 146
126 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); 147 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
127 }; 148 };
128 149
129 } // namespace net 150 } // namespace net
130 151
131 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 152 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_context.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