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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // These two methods are for glib main loop callbacks. They are called | 62 // These two methods are for glib main loop callbacks. They are called |
63 // when either a file descriptor is ready for work or when a timer | 63 // when either a file descriptor is ready for work or when a timer |
64 // has fired. The static versions are shims for libcurl which has a C API. | 64 // has fired. The static versions are shims for libcurl which has a C API. |
65 bool FDCallback(GIOChannel *source, GIOCondition condition); | 65 bool FDCallback(GIOChannel *source, GIOCondition condition); |
66 static gboolean StaticFDCallback(GIOChannel *source, | 66 static gboolean StaticFDCallback(GIOChannel *source, |
67 GIOCondition condition, | 67 GIOCondition condition, |
68 gpointer data) { | 68 gpointer data) { |
69 return reinterpret_cast<LibcurlHttpFetcher*>(data)->FDCallback(source, | 69 return reinterpret_cast<LibcurlHttpFetcher*>(data)->FDCallback(source, |
70 condition); | 70 condition); |
71 } | 71 } |
72 bool TimeoutCallback(); | 72 gboolean TimeoutCallback(); |
73 static gboolean StaticTimeoutCallback(gpointer data) { | 73 static gboolean StaticTimeoutCallback(gpointer data) { |
74 return reinterpret_cast<LibcurlHttpFetcher*>(data)->TimeoutCallback(); | 74 return reinterpret_cast<LibcurlHttpFetcher*>(data)->TimeoutCallback(); |
75 } | 75 } |
76 | 76 |
77 // Calls into curl_multi_perform to let libcurl do its work. Returns after | 77 // Calls into curl_multi_perform to let libcurl do its work. Returns after |
78 // curl_multi_perform is finished, which may actually be after more than | 78 // curl_multi_perform is finished, which may actually be after more than |
79 // one call to curl_multi_perform. This method will set up the glib run | 79 // one call to curl_multi_perform. This method will set up the glib run |
80 // loop with sources for future work that libcurl will do. | 80 // loop with sources for future work that libcurl will do. |
81 // This method will not block. | 81 // This method will not block. |
82 void CurlPerformOnce(); | 82 // Returns true if we should resume immediately after this call. |
| 83 bool CurlPerformOnce(); |
83 | 84 |
84 // Sets up glib main loop sources as needed by libcurl. This is generally | 85 // Sets up glib main loop sources as needed by libcurl. This is generally |
85 // the file descriptor of the socket and a timer in case nothing happens | 86 // the file descriptor of the socket and a timer in case nothing happens |
86 // on the fds. | 87 // on the fds. |
87 void SetupMainloopSources(); | 88 void SetupMainloopSources(); |
88 | 89 |
89 // Callback called by libcurl when new data has arrived on the transfer | 90 // Callback called by libcurl when new data has arrived on the transfer |
90 size_t LibcurlWrite(void *ptr, size_t size, size_t nmemb); | 91 size_t LibcurlWrite(void *ptr, size_t size, size_t nmemb); |
91 static size_t StaticLibcurlWrite(void *ptr, size_t size, | 92 static size_t StaticLibcurlWrite(void *ptr, size_t size, |
92 size_t nmemb, void *stream) { | 93 size_t nmemb, void *stream) { |
(...skipping 30 matching lines...) Expand all Loading... |
123 // new connection. 0 otherwise. | 124 // new connection. 0 otherwise. |
124 off_t resume_offset_; | 125 off_t resume_offset_; |
125 | 126 |
126 long idle_ms_; | 127 long idle_ms_; |
127 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); | 128 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); |
128 }; | 129 }; |
129 | 130 |
130 } // namespace chromeos_update_engine | 131 } // namespace chromeos_update_engine |
131 | 132 |
132 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ | 133 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ |
OLD | NEW |