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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // or User-Agent header values for all requests that don't 78 // or User-Agent header values for all requests that don't
79 // have the headers already set. 79 // have the headers already set.
80 void set_accept_language(const std::string& accept_language) { 80 void set_accept_language(const std::string& accept_language) {
81 accept_language_ = accept_language; 81 accept_language_ = accept_language;
82 } 82 }
83 void set_user_agent(const std::string& user_agent) { 83 void set_user_agent(const std::string& user_agent) {
84 user_agent_ = user_agent; 84 user_agent_ = user_agent;
85 } 85 }
86 86
87 // Control support for data:// requests. By default it's disabled. 87 // Control support for data:// requests. By default it's disabled.
88 void set_data_enabled(bool enable) { 88 void set_data_enabled(bool enable) { data_enabled_ = enable; }
89 data_enabled_ = enable;
90 }
91 89
92 // Control support for file:// requests. By default it's disabled. 90 // Control support for file:// requests. By default it's disabled.
93 void set_file_enabled(bool enable) { 91 void set_file_enabled(bool enable) { file_enabled_ = enable; }
94 file_enabled_ = enable;
95 }
96 92
97 #if !defined(DISABLE_FTP_SUPPORT) 93 #if !defined(DISABLE_FTP_SUPPORT)
98 // Control support for ftp:// requests. By default it's disabled. 94 // Control support for ftp:// requests. By default it's disabled.
99 void set_ftp_enabled(bool enable) { 95 void set_ftp_enabled(bool enable) { ftp_enabled_ = enable; }
100 ftp_enabled_ = enable;
101 }
102 #endif 96 #endif
103 97
104 // By default host_resolver is constructed with CreateDefaultResolver. 98 // By default host_resolver is constructed with CreateDefaultResolver.
105 void set_host_resolver(HostResolver* host_resolver) { 99 void set_host_resolver(HostResolver* host_resolver) {
106 host_resolver_.reset(host_resolver); 100 host_resolver_.reset(host_resolver);
107 } 101 }
108 102
109 // Uses BasicNetworkDelegate by default. Note that calling Build will unset 103 // Uses BasicNetworkDelegate by default. Note that calling Build will unset
110 // 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
111 // Build is called. 105 // Build is called.
112 void set_network_delegate(NetworkDelegate* delegate) { 106 void set_network_delegate(NetworkDelegate* delegate) {
113 network_delegate_.reset(delegate); 107 network_delegate_.reset(delegate);
114 } 108 }
115 109
116
117 // Adds additional auth handler factories to be used in addition to what is 110 // Adds additional auth handler factories to be used in addition to what is
118 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme| 111 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme|
119 // and |factory| are provided. The builder takes ownership of the factory and 112 // and |factory| are provided. The builder takes ownership of the factory and
120 // Build() must be called after this method. 113 // Build() must be called after this method.
121 void add_http_auth_handler_factory(const std::string& scheme, 114 void add_http_auth_handler_factory(const std::string& scheme,
122 net::HttpAuthHandlerFactory* factory) { 115 net::HttpAuthHandlerFactory* factory) {
123 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory)); 116 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory));
124 } 117 }
125 118
126 // By default HttpCache is enabled with a default constructed HttpCacheParams. 119 // By default HttpCache is enabled with a default constructed HttpCacheParams.
127 void EnableHttpCache(const HttpCacheParams& params) { 120 void EnableHttpCache(const HttpCacheParams& params) {
128 http_cache_enabled_ = true; 121 http_cache_enabled_ = true;
129 http_cache_params_ = params; 122 http_cache_params_ = params;
130 } 123 }
131 124
132 void DisableHttpCache() { 125 void DisableHttpCache() {
133 http_cache_enabled_ = false; 126 http_cache_enabled_ = false;
134 http_cache_params_ = HttpCacheParams(); 127 http_cache_params_ = HttpCacheParams();
135 } 128 }
136 129
137 // Override default net::HttpNetworkSession::Params settings. 130 // Override default net::HttpNetworkSession::Params settings.
138 void set_http_network_session_params( 131 void set_http_network_session_params(
139 const HttpNetworkSessionParams& http_network_session_params) { 132 const HttpNetworkSessionParams& http_network_session_params) {
140 http_network_session_params_ = http_network_session_params; 133 http_network_session_params_ = http_network_session_params;
141 } 134 }
142 135
143 URLRequestContext* Build(); 136 URLRequestContext* Build();
144 137
145 private: 138 private:
146
147 struct SchemeFactory { 139 struct SchemeFactory {
148 SchemeFactory(const std::string& scheme, 140 SchemeFactory(const std::string& scheme,
149 net::HttpAuthHandlerFactory* factory); 141 net::HttpAuthHandlerFactory* factory);
150 ~SchemeFactory(); 142 ~SchemeFactory();
151 143
152 std::string scheme; 144 std::string scheme;
153 net::HttpAuthHandlerFactory* factory; 145 net::HttpAuthHandlerFactory* factory;
154 }; 146 };
155 147
156 std::string accept_language_; 148 std::string accept_language_;
(...skipping 14 matching lines...) Expand all
171 scoped_ptr<NetworkDelegate> network_delegate_; 163 scoped_ptr<NetworkDelegate> network_delegate_;
172 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; 164 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
173 std::vector<SchemeFactory> extra_http_auth_handlers_; 165 std::vector<SchemeFactory> extra_http_auth_handlers_;
174 166
175 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); 167 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
176 }; 168 };
177 169
178 } // namespace net 170 } // namespace net
179 171
180 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 172 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698