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

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/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "base/sequenced_task_runner.h"
12 #include "components/component_updater/component_updater_configurator.h"
13 #include "components/component_updater/component_updater_utils.h"
14 #include "net/url_request/url_fetcher.h"
15
16 namespace component_updater {
17
18 RequestSender::RequestSender(const Configurator& config) : config_(config) {
19 }
20
21 RequestSender::~RequestSender() {
22 }
23
24 void RequestSender::Send(const std::string& request_string,
25 const std::vector<GURL>& urls,
26 const RequestSenderCallback& request_sender_callback) {
27 if (urls.empty()) {
28 request_sender_callback.Run(NULL);
29 return;
30 }
31
32 request_string_ = request_string;
33 urls_ = urls;
34 request_sender_callback_ = request_sender_callback;
35
36 cur_url_ = urls_.begin();
37
38 SendInternal();
39 }
40
41 void RequestSender::SendInternal() {
42 DCHECK(cur_url_ != urls_.end());
43 DCHECK(cur_url_->is_valid());
44
45 url_fetcher_.reset(SendProtocolRequest(
46 *cur_url_, request_string_, this, config_.RequestContext()));
47 }
48
49 void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) {
50 if (GetFetchError(*source) == 0) {
51 request_sender_callback_.Run(source);
52 return;
53 }
54
55 if (++cur_url_ != urls_.end() &&
56 config_.GetSequencedTaskRunner()->PostTask(
57 FROM_HERE,
58 base::Bind(&RequestSender::SendInternal, base::Unretained(this)))) {
59 return;
60 }
61
62 request_sender_callback_.Run(source);
63 }
64
65 } // namespace component_updater
OLDNEW
« no previous file with comments | « components/component_updater/request_sender.h ('k') | components/component_updater/test/component_patcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698