| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 std::string trusted_spdy_proxy; | 65 std::string trusted_spdy_proxy; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 URLRequestContextBuilder(); | 68 URLRequestContextBuilder(); |
| 69 ~URLRequestContextBuilder(); | 69 ~URLRequestContextBuilder(); |
| 70 | 70 |
| 71 #if defined(OS_LINUX) || defined(OS_ANDROID) | 71 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 72 void set_proxy_config_service(ProxyConfigService* proxy_config_service); | 72 void set_proxy_config_service(ProxyConfigService* proxy_config_service); |
| 73 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 73 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 74 | 74 |
| 75 // Call this function to specify a hard-coded User-Agent for all requests that | 75 // Call these functions to specify hard-coded Accept-Language, |
| 76 // don't have a User-Agent already set. | 76 // Accept-Charset, or User-Agent header values for all requests that don't |
| 77 // have the headers already set. |
| 78 void set_accept_language(const std::string& accept_language) { |
| 79 accept_language_ = accept_language; |
| 80 } |
| 81 void set_accept_charset(const std::string& accept_charset) { |
| 82 accept_charset_ = accept_charset; |
| 83 } |
| 77 void set_user_agent(const std::string& user_agent) { | 84 void set_user_agent(const std::string& user_agent) { |
| 78 user_agent_ = user_agent; | 85 user_agent_ = user_agent; |
| 79 } | 86 } |
| 80 | 87 |
| 81 // By default it's disabled. | 88 // By default it's disabled. |
| 82 void set_ftp_enabled(bool enable) { | 89 void set_ftp_enabled(bool enable) { |
| 83 ftp_enabled_ = enable; | 90 ftp_enabled_ = enable; |
| 84 } | 91 } |
| 85 | 92 |
| 86 // Uses BasicNetworkDelegate by default. Note that calling Build will unset | 93 // Uses BasicNetworkDelegate by default. Note that calling Build will unset |
| (...skipping 14 matching lines...) Expand all Loading... |
| 101 | 108 |
| 102 // Override default net::HttpNetworkSession::Params settings. | 109 // Override default net::HttpNetworkSession::Params settings. |
| 103 void set_http_network_session_params( | 110 void set_http_network_session_params( |
| 104 const HttpNetworkSessionParams& http_network_session_params) { | 111 const HttpNetworkSessionParams& http_network_session_params) { |
| 105 http_network_session_params_ = http_network_session_params; | 112 http_network_session_params_ = http_network_session_params; |
| 106 } | 113 } |
| 107 | 114 |
| 108 URLRequestContext* Build(); | 115 URLRequestContext* Build(); |
| 109 | 116 |
| 110 private: | 117 private: |
| 118 std::string accept_language_; |
| 119 std::string accept_charset_; |
| 111 std::string user_agent_; | 120 std::string user_agent_; |
| 112 bool ftp_enabled_; | 121 bool ftp_enabled_; |
| 113 bool http_cache_enabled_; | 122 bool http_cache_enabled_; |
| 114 HttpCacheParams http_cache_params_; | 123 HttpCacheParams http_cache_params_; |
| 115 HttpNetworkSessionParams http_network_session_params_; | 124 HttpNetworkSessionParams http_network_session_params_; |
| 116 #if defined(OS_LINUX) || defined(OS_ANDROID) | 125 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 117 scoped_ptr<ProxyConfigService> proxy_config_service_; | 126 scoped_ptr<ProxyConfigService> proxy_config_service_; |
| 118 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 127 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 119 scoped_ptr<NetworkDelegate> network_delegate_; | 128 scoped_ptr<NetworkDelegate> network_delegate_; |
| 120 | 129 |
| 121 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 130 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 122 }; | 131 }; |
| 123 | 132 |
| 124 } // namespace net | 133 } // namespace net |
| 125 | 134 |
| 126 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 135 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |