Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <curl/curl.h> | 10 #include <curl/curl.h> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 : HttpFetcher(proxy_resolver), | 26 : HttpFetcher(proxy_resolver), |
| 27 curl_multi_handle_(NULL), | 27 curl_multi_handle_(NULL), |
| 28 curl_handle_(NULL), | 28 curl_handle_(NULL), |
| 29 timeout_source_(NULL), | 29 timeout_source_(NULL), |
| 30 transfer_in_progress_(false), | 30 transfer_in_progress_(false), |
| 31 transfer_size_(0), | 31 transfer_size_(0), |
| 32 bytes_downloaded_(0), | 32 bytes_downloaded_(0), |
| 33 resume_offset_(0), | 33 resume_offset_(0), |
| 34 retry_count_(0), | 34 retry_count_(0), |
| 35 retry_seconds_(60), | 35 retry_seconds_(60), |
| 36 no_network_retry_count_(0), | |
| 37 no_network_max_retries_(0), | |
| 36 idle_seconds_(1), | 38 idle_seconds_(1), |
| 37 force_connection_type_(false), | 39 force_connection_type_(false), |
| 38 forced_expensive_connection_(false), | 40 forced_expensive_connection_(false), |
| 39 force_build_type_(false), | 41 force_build_type_(false), |
| 40 forced_official_build_(false), | 42 forced_official_build_(false), |
| 41 in_write_callback_(false), | 43 in_write_callback_(false), |
| 42 sent_byte_(false), | 44 sent_byte_(false), |
| 43 terminate_requested_(false) {} | 45 terminate_requested_(false) {} |
| 44 | 46 |
| 45 // Cleans up all internal state. Does not notify delegate | 47 // Cleans up all internal state. Does not notify delegate |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 67 // From http://curl.haxx.se/libcurl/c/curl_multi_timeout.html: | 69 // From http://curl.haxx.se/libcurl/c/curl_multi_timeout.html: |
| 68 // if libcurl returns a -1 timeout here, it just means that libcurl | 70 // if libcurl returns a -1 timeout here, it just means that libcurl |
| 69 // currently has no stored timeout value. You must not wait too long | 71 // currently has no stored timeout value. You must not wait too long |
| 70 // (more than a few seconds perhaps) before you call | 72 // (more than a few seconds perhaps) before you call |
| 71 // curl_multi_perform() again. | 73 // curl_multi_perform() again. |
| 72 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; } | 74 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; } |
| 73 | 75 |
| 74 // Sets the retry timeout. Useful for testing. | 76 // Sets the retry timeout. Useful for testing. |
| 75 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; } | 77 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; } |
| 76 | 78 |
| 79 void set_no_network_max_retries(int retries) { | |
| 80 no_network_max_retries_ = retries; | |
| 81 } | |
| 82 | |
| 77 void SetConnectionAsExpensive(bool is_expensive) { | 83 void SetConnectionAsExpensive(bool is_expensive) { |
| 78 force_connection_type_ = true; | 84 force_connection_type_ = true; |
| 79 forced_expensive_connection_ = is_expensive; | 85 forced_expensive_connection_ = is_expensive; |
| 80 } | 86 } |
| 81 | 87 |
| 82 void SetBuildType(bool is_official) { | 88 void SetBuildType(bool is_official) { |
| 83 force_build_type_ = true; | 89 force_build_type_ = true; |
| 84 forced_official_build_ = is_official; | 90 forced_official_build_ = is_official; |
| 85 } | 91 } |
| 86 | 92 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // In this class, resume refers to resuming a dropped HTTP connection, | 184 // In this class, resume refers to resuming a dropped HTTP connection, |
| 179 // not to resuming an interrupted download. | 185 // not to resuming an interrupted download. |
| 180 off_t resume_offset_; | 186 off_t resume_offset_; |
| 181 | 187 |
| 182 // Number of resumes performed. | 188 // Number of resumes performed. |
| 183 int retry_count_; | 189 int retry_count_; |
| 184 | 190 |
| 185 // Seconds to wait before retrying a resume. | 191 // Seconds to wait before retrying a resume. |
| 186 int retry_seconds_; | 192 int retry_seconds_; |
| 187 | 193 |
| 194 // Number of resumes due to HTTP response code 0. | |
|
adlr
2010/11/29 21:23:28
... due to no network (i.e., HTTP response code 0)
petkov
2010/11/29 21:28:19
Done.
| |
| 195 int no_network_retry_count_; | |
| 196 int no_network_max_retries_; | |
| 197 | |
| 188 // Seconds to wait before asking libcurl to "perform". | 198 // Seconds to wait before asking libcurl to "perform". |
| 189 int idle_seconds_; | 199 int idle_seconds_; |
| 190 | 200 |
| 191 // If true, assume the network is expensive or not, according to | 201 // If true, assume the network is expensive or not, according to |
| 192 // forced_expensive_connection_. (Useful for testing). | 202 // forced_expensive_connection_. (Useful for testing). |
| 193 bool force_connection_type_; | 203 bool force_connection_type_; |
| 194 bool forced_expensive_connection_; | 204 bool forced_expensive_connection_; |
| 195 | 205 |
| 196 // If true, assume the build is official or not, according to | 206 // If true, assume the build is official or not, according to |
| 197 // forced_official_build_. Useful for testing. | 207 // forced_official_build_. Useful for testing. |
| 198 bool force_build_type_; | 208 bool force_build_type_; |
| 199 bool forced_official_build_; | 209 bool forced_official_build_; |
| 200 | 210 |
| 201 // If true, we are currently performing a write callback on the delegate. | 211 // If true, we are currently performing a write callback on the delegate. |
| 202 bool in_write_callback_; | 212 bool in_write_callback_; |
| 203 | 213 |
| 204 // If true, we have returned at least one byte in the write callback | 214 // If true, we have returned at least one byte in the write callback |
| 205 // to the delegate. | 215 // to the delegate. |
| 206 bool sent_byte_; | 216 bool sent_byte_; |
| 207 | 217 |
| 208 // We can't clean everything up while we're in a write callback, so | 218 // We can't clean everything up while we're in a write callback, so |
| 209 // if we get a terminate request, queue it until we can handle it. | 219 // if we get a terminate request, queue it until we can handle it. |
| 210 bool terminate_requested_; | 220 bool terminate_requested_; |
| 211 | 221 |
| 212 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); | 222 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); |
| 213 }; | 223 }; |
| 214 | 224 |
| 215 } // namespace chromeos_update_engine | 225 } // namespace chromeos_update_engine |
| 216 | 226 |
| 217 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ | 227 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ |
| OLD | NEW |