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

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,
16 const std::vector<GURL>& urls)
17 : config_(config), urls_(urls) {
18 }
19
20 void RequestSender::Send(const std::string& request_string,
21 const RequestSenderCallback& request_sender_callback) {
22 if (urls_.empty()) {
23 request_sender_callback.Run(NULL);
24 return;
25 }
26
27 request_sender_callback_ = request_sender_callback;
28 request_string_ = request_string;
29
30 cur_url_ = urls_.begin();
31
32 SendInternal();
33 }
34
35 void RequestSender::SendInternal() {
36 DCHECK(cur_url_ != urls_.end());
37 DCHECK(cur_url_->is_valid());
38
39 url_fetcher_.reset(SendProtocolRequest(
40 *cur_url_, request_string_, this, config_.RequestContext()));
41 }
42
43 void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) {
waffles 2014/09/12 22:38:26 What thread does this occur on? Is it OK to .Run t
Sorin Jianu 2014/09/12 23:24:00 The fetcher is thread safe, the call will occur on
44 if (GetFetchError(*source) == 0) {
45 request_sender_callback_.Run(source);
46 return;
47 }
48
49 if (++cur_url_ != urls_.end() &&
50 config_.GetSequencedTaskRunner()->PostTask(
51 FROM_HERE,
52 base::Bind(&RequestSender::SendInternal, base::Unretained(this)))) {
53 return;
54 }
55
56 request_sender_callback_.Run(source);
57 }
58
59 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698