Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: libcurl_http_fetcher.h

Issue 5009009: AU: Fix potential issues with premature destruction of HTTP fetchers. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « http_fetcher_unittest.cc ('k') | libcurl_http_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 terminate_requested_(false) {} 41 terminate_requested_(false) {}
42 42
43 // Cleans up all internal state. Does not notify delegate 43 // Cleans up all internal state. Does not notify delegate
44 ~LibcurlHttpFetcher(); 44 ~LibcurlHttpFetcher();
45 45
46 void SetOffset(off_t offset) { bytes_downloaded_ = offset; } 46 void SetOffset(off_t offset) { bytes_downloaded_ = offset; }
47 47
48 // Begins the transfer if it hasn't already begun. 48 // Begins the transfer if it hasn't already begun.
49 virtual void BeginTransfer(const std::string& url); 49 virtual void BeginTransfer(const std::string& url);
50 50
51 // If the transfer is in progress, aborts the transfer early. 51 // If the transfer is in progress, aborts the transfer early. The transfer
52 // The transfer cannot be resumed. 52 // cannot be resumed.
53 virtual void TerminateTransfer(); 53 virtual void TerminateTransfer();
54 54
55 // Suspend the transfer by calling curl_easy_pause(CURLPAUSE_ALL). 55 // Suspend the transfer by calling curl_easy_pause(CURLPAUSE_ALL).
56 virtual void Pause(); 56 virtual void Pause();
57 57
58 // Resume the transfer by calling curl_easy_pause(CURLPAUSE_CONT). 58 // Resume the transfer by calling curl_easy_pause(CURLPAUSE_CONT).
59 virtual void Unpause(); 59 virtual void Unpause();
60 60
61 // Libcurl sometimes asks to be called back after some time while 61 // Libcurl sometimes asks to be called back after some time while
62 // leaving that time unspecified. In that case, we pick a reasonable 62 // leaving that time unspecified. In that case, we pick a reasonable
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 static size_t StaticLibcurlWrite(void *ptr, size_t size, 129 static size_t StaticLibcurlWrite(void *ptr, size_t size,
130 size_t nmemb, void *stream) { 130 size_t nmemb, void *stream) {
131 return reinterpret_cast<LibcurlHttpFetcher*>(stream)-> 131 return reinterpret_cast<LibcurlHttpFetcher*>(stream)->
132 LibcurlWrite(ptr, size, nmemb); 132 LibcurlWrite(ptr, size, nmemb);
133 } 133 }
134 134
135 // Cleans up the following if they are non-null: 135 // Cleans up the following if they are non-null:
136 // curl(m) handles, io_channels_, timeout_source_. 136 // curl(m) handles, io_channels_, timeout_source_.
137 void CleanUp(); 137 void CleanUp();
138 138
139 // Force terminate the transfer. This will invoke the delegate's (if any)
140 // TransferTerminated callback so, after returning, this fetcher instance may
141 // be destroyed.
142 void ForceTransferTermination();
143
139 // Returns whether or not the current network connection is considered 144 // Returns whether or not the current network connection is considered
140 // expensive. 145 // expensive.
141 bool ConnectionIsExpensive() const; 146 bool ConnectionIsExpensive() const;
142 147
143 // Returns whether or not the current build is official. 148 // Returns whether or not the current build is official.
144 bool IsOfficialBuild() const; 149 bool IsOfficialBuild() const;
145 150
146 // Handles for the libcurl library 151 // Handles for the libcurl library
147 CURLM *curl_multi_handle_; 152 CURLM *curl_multi_handle_;
148 CURL *curl_handle_; 153 CURL *curl_handle_;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // We can't clean everything up while we're in a write callback, so 202 // We can't clean everything up while we're in a write callback, so
198 // if we get a terminate request, queue it until we can handle it. 203 // if we get a terminate request, queue it until we can handle it.
199 bool terminate_requested_; 204 bool terminate_requested_;
200 205
201 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); 206 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher);
202 }; 207 };
203 208
204 } // namespace chromeos_update_engine 209 } // namespace chromeos_update_engine
205 210
206 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ 211 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__
OLDNEW
« no previous file with comments | « http_fetcher_unittest.cc ('k') | libcurl_http_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698