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

Side by Side Diff: multi_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, 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 | « libcurl_http_fetcher.cc ('k') | no next file » | 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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 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_MULTI_HTTP_FETCHER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_HTTP_FETCHER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_HTTP_FETCHER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_HTTP_FETCHER_H__
7 7
8 #include <tr1/memory> 8 #include <tr1/memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void Pause() { 66 void Pause() {
67 if (current_index_ < fetchers_.size()) 67 if (current_index_ < fetchers_.size())
68 fetchers_[current_index_]->Pause(); 68 fetchers_[current_index_]->Pause();
69 } 69 }
70 70
71 void Unpause() { 71 void Unpause() {
72 if (current_index_ < fetchers_.size()) 72 if (current_index_ < fetchers_.size())
73 fetchers_[current_index_]->Unpause(); 73 fetchers_[current_index_]->Unpause();
74 } 74 }
75 75
76 // These two function are overloaded in LibcurlHttp fetcher to speed 76 // These functions are overloaded in LibcurlHttp fetcher for testing purposes.
77 // testing.
78 void set_idle_seconds(int seconds) { 77 void set_idle_seconds(int seconds) {
79 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator 78 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator
80 it = fetchers_.begin(), 79 it = fetchers_.begin(),
81 e = fetchers_.end(); it != e; ++it) { 80 e = fetchers_.end(); it != e; ++it) {
82 (*it)->set_idle_seconds(seconds); 81 (*it)->set_idle_seconds(seconds);
83 } 82 }
84 } 83 }
85 void set_retry_seconds(int seconds) { 84 void set_retry_seconds(int seconds) {
86 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator 85 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator
87 it = fetchers_.begin(), 86 it = fetchers_.begin(),
88 e = fetchers_.end(); it != e; ++it) { 87 e = fetchers_.end(); it != e; ++it) {
89 (*it)->set_retry_seconds(seconds); 88 (*it)->set_retry_seconds(seconds);
90 } 89 }
91 } 90 }
91 void SetConnectionAsExpensive(bool is_expensive) {
92 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator
93 it = fetchers_.begin(),
94 e = fetchers_.end(); it != e; ++it) {
95 (*it)->SetConnectionAsExpensive(is_expensive);
96 }
97 }
98 void SetBuildType(bool is_official) {
99 for (typename std::vector<std::tr1::shared_ptr<BaseHttpFetcher> >::iterator
100 it = fetchers_.begin(),
101 e = fetchers_.end(); it != e; ++it) {
102 (*it)->SetBuildType(is_official);
103 }
104 }
92 105
93 private: 106 private:
94 void SendTransferComplete(HttpFetcher* fetcher, bool successful) { 107 void SendTransferComplete(HttpFetcher* fetcher, bool successful) {
95 if (sent_transfer_complete_) 108 if (sent_transfer_complete_)
96 return; 109 return;
97 LOG(INFO) << "Sending transfer complete"; 110 LOG(INFO) << "Sending transfer complete";
98 sent_transfer_complete_ = true; 111 sent_transfer_complete_ = true;
99 http_response_code_ = fetcher->http_response_code(); 112 http_response_code_ = fetcher->http_response_code();
100 if (delegate_) 113 if (delegate_)
101 delegate_->TransferComplete(this, successful); 114 delegate_->TransferComplete(this, successful);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 LOG(WARNING) << "Received insufficient bytes from fetcher. " 179 LOG(WARNING) << "Received insufficient bytes from fetcher. "
167 << "Ending early"; 180 << "Ending early";
168 SendTransferComplete(fetcher, false); 181 SendTransferComplete(fetcher, false);
169 return; 182 return;
170 } else { 183 } else {
171 LOG(INFO) << "Got spurious TransferComplete. Ingoring."; 184 LOG(INFO) << "Got spurious TransferComplete. Ingoring.";
172 } 185 }
173 } 186 }
174 187
175 // If true, do not send any more data or TransferComplete to the delegate. 188 // If true, do not send any more data or TransferComplete to the delegate.
176 bool sent_transfer_complete_; 189 bool sent_transfer_complete_;
177 190
178 RangesVect ranges_; 191 RangesVect ranges_;
179 std::vector<std::tr1::shared_ptr<BaseHttpFetcher> > fetchers_; 192 std::vector<std::tr1::shared_ptr<BaseHttpFetcher> > fetchers_;
180 193
181 RangesVect::size_type current_index_; // index into ranges_, fetchers_ 194 RangesVect::size_type current_index_; // index into ranges_, fetchers_
182 off_t bytes_received_this_fetcher_; 195 off_t bytes_received_this_fetcher_;
183 196
184 private: 197 private:
185 DISALLOW_COPY_AND_ASSIGN(MultiHttpFetcher); 198 DISALLOW_COPY_AND_ASSIGN(MultiHttpFetcher);
186 }; 199 };
187 200
188 } // namespace chromeos_update_engine 201 } // namespace chromeos_update_engine
189 202
190 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_HTTP_FETCHER_H__ 203 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_HTTP_FETCHER_H__
OLDNEW
« no previous file with comments | « libcurl_http_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698