| 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 #include "update_engine/libcurl_http_fetcher.h" | 5 #include "update_engine/libcurl_http_fetcher.h" |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include "chromeos/obsolete_logging.h" | 7 #include "chromeos/obsolete_logging.h" |
| 8 | 8 |
| 9 using std::max; | 9 using std::max; |
| 10 using std::make_pair; | 10 using std::make_pair; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (delegate_) | 112 if (delegate_) |
| 113 delegate_->TransferComplete(this, false); // success | 113 delegate_->TransferComplete(this, false); // success |
| 114 } else { | 114 } else { |
| 115 g_timeout_add(5 * 1000, | 115 g_timeout_add(5 * 1000, |
| 116 &LibcurlHttpFetcher::StaticRetryTimeoutCallback, | 116 &LibcurlHttpFetcher::StaticRetryTimeoutCallback, |
| 117 this); | 117 this); |
| 118 } | 118 } |
| 119 return false; | 119 return false; |
| 120 } else { | 120 } else { |
| 121 if (delegate_) { | 121 if (delegate_) { |
| 122 // success is when http_response_code is 200 | 122 // success is when http_response_code is 2xx |
| 123 delegate_->TransferComplete(this, http_response_code == 200); | 123 bool success = (http_response_code >= 200) && |
| 124 (http_response_code < 300); |
| 125 delegate_->TransferComplete(this, success); |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 } else { | 128 } else { |
| 127 // set up callback | 129 // set up callback |
| 128 SetupMainloopSources(); | 130 SetupMainloopSources(); |
| 129 } | 131 } |
| 130 return false; | 132 return false; |
| 131 } | 133 } |
| 132 | 134 |
| 133 size_t LibcurlHttpFetcher::LibcurlWrite(void *ptr, size_t size, size_t nmemb) { | 135 size_t LibcurlHttpFetcher::LibcurlWrite(void *ptr, size_t size, size_t nmemb) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 curl_handle_ = NULL; | 294 curl_handle_ = NULL; |
| 293 } | 295 } |
| 294 if (curl_multi_handle_) { | 296 if (curl_multi_handle_) { |
| 295 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK); | 297 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK); |
| 296 curl_multi_handle_ = NULL; | 298 curl_multi_handle_ = NULL; |
| 297 } | 299 } |
| 298 transfer_in_progress_ = false; | 300 transfer_in_progress_ = false; |
| 299 } | 301 } |
| 300 | 302 |
| 301 } // namespace chromeos_update_engine | 303 } // namespace chromeos_update_engine |
| OLD | NEW |