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

Side by Side Diff: libcurl_http_fetcher.h

Issue 4004004: AU: Restrict to HTTPS for official builds. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 months 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 17 matching lines...) Expand all
28 timeout_source_(NULL), 28 timeout_source_(NULL),
29 transfer_in_progress_(false), 29 transfer_in_progress_(false),
30 transfer_size_(0), 30 transfer_size_(0),
31 bytes_downloaded_(0), 31 bytes_downloaded_(0),
32 resume_offset_(0), 32 resume_offset_(0),
33 retry_count_(0), 33 retry_count_(0),
34 retry_seconds_(60), 34 retry_seconds_(60),
35 idle_seconds_(1), 35 idle_seconds_(1),
36 force_connection_type_(false), 36 force_connection_type_(false),
37 forced_expensive_connection_(false), 37 forced_expensive_connection_(false),
38 force_build_type_(false),
39 forced_official_build_(false),
38 in_write_callback_(false), 40 in_write_callback_(false),
39 terminate_requested_(false) {} 41 terminate_requested_(false) {}
40 42
41 // Cleans up all internal state. Does not notify delegate 43 // Cleans up all internal state. Does not notify delegate
42 ~LibcurlHttpFetcher(); 44 ~LibcurlHttpFetcher();
43 45
44 void SetOffset(off_t offset) { bytes_downloaded_ = offset; } 46 void SetOffset(off_t offset) { bytes_downloaded_ = offset; }
45 47
46 // Begins the transfer if it hasn't already begun. 48 // Begins the transfer if it hasn't already begun.
47 virtual void BeginTransfer(const std::string& url); 49 virtual void BeginTransfer(const std::string& url);
(...skipping 14 matching lines...) Expand all
62 // primarily useful for testing. 64 // primarily useful for testing.
63 // From http://curl.haxx.se/libcurl/c/curl_multi_timeout.html: 65 // From http://curl.haxx.se/libcurl/c/curl_multi_timeout.html:
64 // if libcurl returns a -1 timeout here, it just means that libcurl 66 // if libcurl returns a -1 timeout here, it just means that libcurl
65 // currently has no stored timeout value. You must not wait too long 67 // currently has no stored timeout value. You must not wait too long
66 // (more than a few seconds perhaps) before you call 68 // (more than a few seconds perhaps) before you call
67 // curl_multi_perform() again. 69 // curl_multi_perform() again.
68 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; } 70 void set_idle_seconds(int seconds) { idle_seconds_ = seconds; }
69 71
70 // Sets the retry timeout. Useful for testing. 72 // Sets the retry timeout. Useful for testing.
71 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; } 73 void set_retry_seconds(int seconds) { retry_seconds_ = seconds; }
72 74
73 void SetConnectionAsExpensive(bool is_expensive) { 75 void SetConnectionAsExpensive(bool is_expensive) {
74 force_connection_type_ = true; 76 force_connection_type_ = true;
75 forced_expensive_connection_ = is_expensive; 77 forced_expensive_connection_ = is_expensive;
76 } 78 }
77 79
80 void SetBuildType(bool is_official) {
81 force_build_type_ = true;
82 forced_official_build_ = is_official;
83 }
84
78 private: 85 private:
79 // Asks libcurl for the http response code and stores it in the object. 86 // Asks libcurl for the http response code and stores it in the object.
80 void GetHttpResponseCode(); 87 void GetHttpResponseCode();
81 88
82 // Resumes a transfer where it left off. This will use the 89 // Resumes a transfer where it left off. This will use the
83 // HTTP Range: header to make a new connection from where the last 90 // HTTP Range: header to make a new connection from where the last
84 // left off. 91 // left off.
85 virtual void ResumeTransfer(const std::string& url); 92 virtual void ResumeTransfer(const std::string& url);
86 93
87 // These two methods are for glib main loop callbacks. They are called 94 // These two methods are for glib main loop callbacks. They are called
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 133 }
127 134
128 // Cleans up the following if they are non-null: 135 // Cleans up the following if they are non-null:
129 // curl(m) handles, io_channels_, timeout_source_. 136 // curl(m) handles, io_channels_, timeout_source_.
130 void CleanUp(); 137 void CleanUp();
131 138
132 // Returns whether or not the current network connection is considered 139 // Returns whether or not the current network connection is considered
133 // expensive. 140 // expensive.
134 bool ConnectionIsExpensive() const; 141 bool ConnectionIsExpensive() const;
135 142
143 // Returns whether or not the current build is official.
144 bool IsOfficialBuild() const;
145
136 // Handles for the libcurl library 146 // Handles for the libcurl library
137 CURLM *curl_multi_handle_; 147 CURLM *curl_multi_handle_;
138 CURL *curl_handle_; 148 CURL *curl_handle_;
139 149
140 // a list of all file descriptors that we're waiting on from the 150 // a list of all file descriptors that we're waiting on from the
141 // glib main loop 151 // glib main loop
142 typedef std::map<int, std::pair<GIOChannel*, guint> > IOChannels; 152 typedef std::map<int, std::pair<GIOChannel*, guint> > IOChannels;
143 IOChannels io_channels_; 153 IOChannels io_channels_;
144 154
145 // if non-NULL, a timer we're waiting on. glib main loop will call us back 155 // if non-NULL, a timer we're waiting on. glib main loop will call us back
(...skipping 15 matching lines...) Expand all
161 off_t resume_offset_; 171 off_t resume_offset_;
162 172
163 // Number of resumes performed. 173 // Number of resumes performed.
164 int retry_count_; 174 int retry_count_;
165 175
166 // Seconds to wait before retrying a resume. 176 // Seconds to wait before retrying a resume.
167 int retry_seconds_; 177 int retry_seconds_;
168 178
169 // Seconds to wait before asking libcurl to "perform". 179 // Seconds to wait before asking libcurl to "perform".
170 int idle_seconds_; 180 int idle_seconds_;
171 181
172 // If true, assume the network is expensive or not, according to 182 // If true, assume the network is expensive or not, according to
173 // forced_expensive_connection_. (Useful for testing). 183 // forced_expensive_connection_. (Useful for testing).
174 bool force_connection_type_; 184 bool force_connection_type_;
175 bool forced_expensive_connection_; 185 bool forced_expensive_connection_;
176 186
187 // If true, assume the build is official or not, according to
188 // forced_official_build_. Useful for testing.
189 bool force_build_type_;
190 bool forced_official_build_;
191
177 // If true, we are currently performing a write callback on the delegate. 192 // If true, we are currently performing a write callback on the delegate.
178 bool in_write_callback_; 193 bool in_write_callback_;
179 194
180 // We can't clean everything up while we're in a write callback, so 195 // We can't clean everything up while we're in a write callback, so
181 // if we get a terminate request, queue it until we can handle it. 196 // if we get a terminate request, queue it until we can handle it.
182 bool terminate_requested_; 197 bool terminate_requested_;
183 198
184 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher); 199 DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher);
185 }; 200 };
186 201
187 } // namespace chromeos_update_engine 202 } // namespace chromeos_update_engine
188 203
189 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H__ 204 #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