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

Side by Side Diff: components/component_updater/request_sender.cc

Issue 565363002: Implement support for fallback update check urls in the component updater (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/component_updater/request_sender.h"
6
7 #include "base/location.h"
8 #include "base/logging.h"
9 #include "base/sequenced_task_runner.h"
10 #include "components/component_updater/component_updater_configurator.h"
11 #include "components/component_updater/component_updater_utils.h"
12
13 namespace component_updater {
14
15 RequestSender::RequestSender(const Configurator& config) : config_(config) {
16 }
17
18 RequestSender::~RequestSender() {
19 }
20
21 void RequestSender::Send(const std::string& request_string,
22 const std::vector<GURL>& urls,
23 const RequestSenderCallback& request_sender_callback) {
24 if (urls.empty()) {
25 request_sender_callback.Run(NULL);
26 return;
27 }
28
29 request_string_ = request_string;
30 urls_ = urls;
31 request_sender_callback_ = request_sender_callback;
32
33 cur_url_ = urls_.begin();
34
35 SendInternal();
36 }
37
38 void RequestSender::SendInternal() {
39 DCHECK(cur_url_ != urls_.end());
40 DCHECK(cur_url_->is_valid());
41
42 url_fetcher_.reset(SendProtocolRequest(
43 *cur_url_, request_string_, this, config_.RequestContext()));
44 }
45
46 void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) {
47 if (GetFetchError(*source) == 0) {
48 request_sender_callback_.Run(source);
49 return;
50 }
51
52 if (++cur_url_ != urls_.end() &&
53 config_.GetSequencedTaskRunner()->PostTask(
54 FROM_HERE,
55 base::Bind(&RequestSender::SendInternal, base::Unretained(this)))) {
erikwright (departed) 2014/09/15 18:37:11 include base/bind.h and base/bind_helpers.h
erikwright (departed) 2014/09/16 17:38:11 ping.
Sorin Jianu 2014/09/16 19:53:31 Done.
56 return;
57 }
58
59 request_sender_callback_.Run(source);
60 }
61
62 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698