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

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

Issue 1685323002: Implement CUP signing in UpdateClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and remove duplicated code comment. Created 4 years, 10 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
« no previous file with comments | « components/update_client/configurator.h ('k') | components/update_client/request_sender.h » ('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 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(const net::URLFetcher* source); 182 void OnRequestSenderComplete(int error, const std::string& response);
183 183
184 const scoped_refptr<Configurator> config_; 184 const scoped_refptr<Configurator> config_;
185 scoped_ptr<RequestSender> request_sender_; 185 scoped_ptr<RequestSender> request_sender_;
186 base::ThreadChecker thread_checker_; 186 base::ThreadChecker thread_checker_;
187 187
188 DISALLOW_COPY_AND_ASSIGN(PingSender); 188 DISALLOW_COPY_AND_ASSIGN(PingSender);
189 }; 189 };
190 190
191 PingSender::PingSender(const scoped_refptr<Configurator>& config) 191 PingSender::PingSender(const scoped_refptr<Configurator>& config)
192 : config_(config) {} 192 : config_(config) {}
193 193
194 PingSender::~PingSender() { 194 PingSender::~PingSender() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 195 DCHECK(thread_checker_.CalledOnValidThread());
196 } 196 }
197 197
198 void PingSender::OnRequestSenderComplete(const net::URLFetcher* source) { 198 void PingSender::OnRequestSenderComplete(int error,
199 const std::string& response) {
199 DCHECK(thread_checker_.CalledOnValidThread()); 200 DCHECK(thread_checker_.CalledOnValidThread());
200 delete this; 201 delete this;
201 } 202 }
202 203
203 bool PingSender::SendPing(const CrxUpdateItem* item) { 204 bool PingSender::SendPing(const CrxUpdateItem* item) {
204 DCHECK(item); 205 DCHECK(item);
205 DCHECK(thread_checker_.CalledOnValidThread()); 206 DCHECK(thread_checker_.CalledOnValidThread());
206 207
207 std::vector<GURL> urls(config_->PingUrl()); 208 std::vector<GURL> urls(config_->PingUrl());
208 209
209 if (urls.empty()) 210 if (urls.empty())
210 return false; 211 return false;
211 212
212 request_sender_.reset(new RequestSender(config_)); 213 request_sender_.reset(new RequestSender(config_));
213 request_sender_->Send( 214 request_sender_->Send(
214 BuildPing(*config_, item), urls, 215 false, BuildPing(*config_, item), urls,
215 base::Bind(&PingSender::OnRequestSenderComplete, base::Unretained(this))); 216 base::Bind(&PingSender::OnRequestSenderComplete, base::Unretained(this)));
216 return true; 217 return true;
217 } 218 }
218 219
219 } // namespace 220 } // namespace
220 221
221 PingManager::PingManager(const scoped_refptr<Configurator>& config) 222 PingManager::PingManager(const scoped_refptr<Configurator>& config)
222 : config_(config) {} 223 : config_(config) {}
223 224
224 PingManager::~PingManager() { 225 PingManager::~PingManager() {
225 } 226 }
226 227
227 // Sends a fire and forget ping when the updates are complete. The ping 228 // Sends a fire and forget ping when the updates are complete. The ping
228 // sender object self-deletes after sending the ping has completed asynchrously. 229 // sender object self-deletes after sending the ping has completed asynchrously.
229 void PingManager::SendPing(const CrxUpdateItem* item) { 230 void PingManager::SendPing(const CrxUpdateItem* item) {
230 PingSender* ping_sender(new PingSender(config_)); 231 PingSender* ping_sender(new PingSender(config_));
231 if (!ping_sender->SendPing(item)) 232 if (!ping_sender->SendPing(item))
232 delete ping_sender; 233 delete ping_sender;
233 } 234 }
234 235
235 } // namespace update_client 236 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/configurator.h ('k') | components/update_client/request_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698