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 // NOTE: lifted from src/platform/update_engine and tweaked for cashew | 5 // NOTE: lifted from src/platform/update_engine and tweaked for cashew |
6 // TODO(vlaviano): see http_fetcher.h | 6 // TODO(vlaviano): see http_fetcher.h |
7 | 7 |
8 #ifndef SRC_LIBCURL_HTTP_FETCHER_H_ | 8 #ifndef SRC_LIBCURL_HTTP_FETCHER_H_ |
9 #define SRC_LIBCURL_HTTP_FETCHER_H_ | 9 #define SRC_LIBCURL_HTTP_FETCHER_H_ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // if libcurl returns a -1 timeout here, it just means that libcurl | 60 // if libcurl returns a -1 timeout here, it just means that libcurl |
61 // currently has no stored timeout value. You must not wait too long | 61 // currently has no stored timeout value. You must not wait too long |
62 // (more than a few seconds perhaps) before you call | 62 // (more than a few seconds perhaps) before you call |
63 // curl_multi_perform() again. | 63 // curl_multi_perform() again. |
64 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; } | 64 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; } |
65 | 65 |
66 // Sets the retry timeout. Useful for testing. | 66 // Sets the retry timeout. Useful for testing. |
67 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; } | 67 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; } |
68 | 68 |
69 private: | 69 private: |
| 70 // Asks libcurl for the http response code and stores it in the object. |
| 71 void GetHttpResponseCode(); |
| 72 |
70 // Resumes a transfer where it left off. This will use the | 73 // Resumes a transfer where it left off. This will use the |
71 // HTTP Range: header to make a new connection from where the last | 74 // HTTP Range: header to make a new connection from where the last |
72 // left off. | 75 // left off. |
73 virtual void ResumeTransfer(const std::string& url); | 76 virtual void ResumeTransfer(const std::string& url); |
74 | 77 |
75 // These two methods are for glib main loop callbacks. They are called | 78 // These two methods are for glib main loop callbacks. They are called |
76 // when either a file descriptor is ready for work or when a timer | 79 // when either a file descriptor is ready for work or when a timer |
77 // has fired. The static versions are shims for libcurl which has a C API. | 80 // has fired. The static versions are shims for libcurl which has a C API. |
78 bool FDCallback(GIOChannel *source, GIOCondition condition); | 81 bool FDCallback(GIOChannel *source, GIOCondition condition); |
79 static gboolean StaticFDCallback(GIOChannel *source, | 82 static gboolean StaticFDCallback(GIOChannel *source, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 153 |
151 // Seconds to wait before asking libcurl to "perform". | 154 // Seconds to wait before asking libcurl to "perform". |
152 int idle_seconds_; | 155 int idle_seconds_; |
153 | 156 |
154 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); | 157 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); |
155 }; | 158 }; |
156 | 159 |
157 } // namespace cashew | 160 } // namespace cashew |
158 | 161 |
159 #endif // SRC_LIBCURL_HTTP_FETCHER_H_ | 162 #endif // SRC_LIBCURL_HTTP_FETCHER_H_ |
OLD | NEW |