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

Side by Side Diff: components/update_client/ping_manager.cc

Issue 1740333002: Allow fallback from https to http for component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 #include "components/update_client/ping_manager.h" 5 #include "components/update_client/ping_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // ownership and they self-delete upon completion. One instance of this class 172 // ownership and they self-delete upon completion. One instance of this class
173 // can send only one ping. 173 // can send only one ping.
174 class PingSender { 174 class PingSender {
175 public: 175 public:
176 explicit PingSender(const scoped_refptr<Configurator>& config); 176 explicit PingSender(const scoped_refptr<Configurator>& config);
177 ~PingSender(); 177 ~PingSender();
178 178
179 bool SendPing(const CrxUpdateItem* item); 179 bool SendPing(const CrxUpdateItem* item);
180 180
181 private: 181 private:
182 void OnRequestSenderComplete(int error, const std::string& response); 182 void OnRequestSenderComplete(int error,
183 const std::string& response,
184 int retry_after_sec);
183 185
184 const scoped_refptr<Configurator> config_; 186 const scoped_refptr<Configurator> config_;
185 scoped_ptr<RequestSender> request_sender_; 187 scoped_ptr<RequestSender> request_sender_;
186 base::ThreadChecker thread_checker_; 188 base::ThreadChecker thread_checker_;
187 189
188 DISALLOW_COPY_AND_ASSIGN(PingSender); 190 DISALLOW_COPY_AND_ASSIGN(PingSender);
189 }; 191 };
190 192
191 PingSender::PingSender(const scoped_refptr<Configurator>& config) 193 PingSender::PingSender(const scoped_refptr<Configurator>& config)
192 : config_(config) {} 194 : config_(config) {}
193 195
194 PingSender::~PingSender() { 196 PingSender::~PingSender() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 197 DCHECK(thread_checker_.CalledOnValidThread());
196 } 198 }
197 199
198 void PingSender::OnRequestSenderComplete(int error, 200 void PingSender::OnRequestSenderComplete(int error,
199 const std::string& response) { 201 const std::string& response,
202 int retry_after_sec) {
200 DCHECK(thread_checker_.CalledOnValidThread()); 203 DCHECK(thread_checker_.CalledOnValidThread());
201 delete this; 204 delete this;
202 } 205 }
203 206
204 bool PingSender::SendPing(const CrxUpdateItem* item) { 207 bool PingSender::SendPing(const CrxUpdateItem* item) {
205 DCHECK(item); 208 DCHECK(item);
206 DCHECK(thread_checker_.CalledOnValidThread()); 209 DCHECK(thread_checker_.CalledOnValidThread());
207 210
208 std::vector<GURL> urls(config_->PingUrl()); 211 auto urls(config_->PingUrl());
212 if (item->component.requires_network_encryption)
213 RemoveUnsecureUrls(&urls);
209 214
210 if (urls.empty()) 215 if (urls.empty())
211 return false; 216 return false;
212 217
213 request_sender_.reset(new RequestSender(config_)); 218 request_sender_.reset(new RequestSender(config_));
214 request_sender_->Send( 219 request_sender_->Send(
215 false, BuildPing(*config_, item), urls, 220 false, BuildPing(*config_, item), urls,
216 base::Bind(&PingSender::OnRequestSenderComplete, base::Unretained(this))); 221 base::Bind(&PingSender::OnRequestSenderComplete, base::Unretained(this)));
217 return true; 222 return true;
218 } 223 }
219 224
220 } // namespace 225 } // namespace
221 226
222 PingManager::PingManager(const scoped_refptr<Configurator>& config) 227 PingManager::PingManager(const scoped_refptr<Configurator>& config)
223 : config_(config) {} 228 : config_(config) {}
224 229
225 PingManager::~PingManager() { 230 PingManager::~PingManager() {
226 } 231 }
227 232
228 // Sends a fire and forget ping when the updates are complete. The ping 233 bool PingManager::SendPing(const CrxUpdateItem* item) {
229 // sender object self-deletes after sending the ping has completed asynchrously. 234 scoped_ptr<PingSender> ping_sender(new PingSender(config_));
230 void PingManager::SendPing(const CrxUpdateItem* item) {
231 PingSender* ping_sender(new PingSender(config_));
232 if (!ping_sender->SendPing(item)) 235 if (!ping_sender->SendPing(item))
233 delete ping_sender; 236 return false;
237
238 // The ping sender object self-deletes after sending the ping asynchrously.
239 ping_sender.release();
240 return true;
234 } 241 }
235 242
236 } // namespace update_client 243 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/ping_manager.h ('k') | components/update_client/ping_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698