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

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

Issue 808773005: Move most of the component updater artifacts to update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/component_updater/request_sender.h ('k') | components/component_updater/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "components/component_updater/component_updater_configurator.h"
14 #include "components/component_updater/component_updater_utils.h"
15 #include "net/url_request/url_fetcher.h"
16
17 namespace component_updater {
18
19 RequestSender::RequestSender(const Configurator& config) : config_(config) {
20 }
21
22 RequestSender::~RequestSender() {
23 DCHECK(thread_checker_.CalledOnValidThread());
24 }
25
26 void RequestSender::Send(const std::string& request_string,
27 const std::vector<GURL>& urls,
28 const RequestSenderCallback& request_sender_callback) {
29 DCHECK(thread_checker_.CalledOnValidThread());
30 if (urls.empty()) {
31 request_sender_callback.Run(NULL);
32 return;
33 }
34
35 request_string_ = request_string;
36 urls_ = urls;
37 request_sender_callback_ = request_sender_callback;
38
39 cur_url_ = urls_.begin();
40
41 SendInternal();
42 }
43
44 void RequestSender::SendInternal() {
45 DCHECK(cur_url_ != urls_.end());
46 DCHECK(cur_url_->is_valid());
47 DCHECK(thread_checker_.CalledOnValidThread());
48
49 url_fetcher_.reset(SendProtocolRequest(
50 *cur_url_, request_string_, this, config_.RequestContext()));
51 }
52
53 void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) {
54 DCHECK(thread_checker_.CalledOnValidThread());
55 if (GetFetchError(*source) == 0) {
56 request_sender_callback_.Run(source);
57 return;
58 }
59
60 if (++cur_url_ != urls_.end() &&
61 base::ThreadTaskRunnerHandle::Get()->PostTask(
62 FROM_HERE,
63 base::Bind(&RequestSender::SendInternal, base::Unretained(this)))) {
64 return;
65 }
66
67 request_sender_callback_.Run(source);
68 }
69
70 } // namespace component_updater
OLDNEW
« no previous file with comments | « components/component_updater/request_sender.h ('k') | components/component_updater/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698