OLD | NEW |
---|---|
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/url_fetcher_downloader.h" | 5 #include "components/update_client/url_fetcher_downloader.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
15 #include "components/data_use_measurement/core/data_use_user_data.h" | 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
16 #include "components/update_client/utils.h" | 16 #include "components/update_client/utils.h" |
17 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
18 #include "net/traffic_annotation/network_traffic_annotation.h" | |
18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace update_client { | 22 namespace update_client { |
22 | 23 |
23 UrlFetcherDownloader::UrlFetcherDownloader( | 24 UrlFetcherDownloader::UrlFetcherDownloader( |
24 std::unique_ptr<CrxDownloader> successor, | 25 std::unique_ptr<CrxDownloader> successor, |
25 net::URLRequestContextGetter* context_getter, | 26 net::URLRequestContextGetter* context_getter, |
26 const scoped_refptr<base::SequencedTaskRunner>& task_runner) | 27 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
27 : CrxDownloader(task_runner, std::move(successor)), | 28 : CrxDownloader(task_runner, std::move(successor)), |
28 context_getter_(context_getter), | 29 context_getter_(context_getter), |
29 downloaded_bytes_(-1), | 30 downloaded_bytes_(-1), |
30 total_bytes_(-1) {} | 31 total_bytes_(-1) {} |
31 | 32 |
32 UrlFetcherDownloader::~UrlFetcherDownloader() { | 33 UrlFetcherDownloader::~UrlFetcherDownloader() { |
33 DCHECK(thread_checker_.CalledOnValidThread()); | 34 DCHECK(thread_checker_.CalledOnValidThread()); |
34 } | 35 } |
35 | 36 |
36 void UrlFetcherDownloader::DoStartDownload(const GURL& url) { | 37 void UrlFetcherDownloader::DoStartDownload(const GURL& url) { |
37 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
38 | 39 |
39 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); | 40 net::NetworkTrafficAnnotationTag traffic_annotation = |
41 net::DefineNetworkTrafficAnnotation("...", R"( | |
42 semantics { | |
43 sender: "..." | |
Sorin Jianu
2017/04/19 21:40:39
Component Updater
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
44 description: "..." | |
Sorin Jianu
2017/04/19 21:40:39
The component updater in Chrome is responsible for
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
45 trigger: "..." | |
Sorin Jianu
2017/04/19 21:40:39
Manual or automatic software updates.
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
46 data: "..." | |
Sorin Jianu
2017/04/19 21:40:39
A CRX representing the specific update payload.
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
47 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
Sorin Jianu
2017/04/19 21:40:39
GOOGLE_OWNED_SERVICE
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
48 } | |
49 policy { | |
50 cookies_allowed: false | |
51 setting: "..." | |
Sorin Jianu
2017/04/19 21:40:39
This feature can't be disabled.
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
52 chrome_policy { | |
53 [POLICY_NAME] { | |
Sorin Jianu
2017/04/19 21:40:39
There is no policy associated with this feature.
Ramin Halavati
2017/04/20 07:36:13
Done.
| |
54 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
55 [POLICY_NAME]: ... //(value to disable it) | |
56 } | |
57 } | |
58 policy_exception_justification: "..." | |
59 })"); | |
60 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this, | |
61 traffic_annotation); | |
40 url_fetcher_->SetRequestContext(context_getter_); | 62 url_fetcher_->SetRequestContext(context_getter_); |
41 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 63 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
42 net::LOAD_DO_NOT_SAVE_COOKIES | | 64 net::LOAD_DO_NOT_SAVE_COOKIES | |
43 net::LOAD_DISABLE_CACHE); | 65 net::LOAD_DISABLE_CACHE); |
44 url_fetcher_->SetAutomaticallyRetryOn5xx(false); | 66 url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
45 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); | 67 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); |
46 data_use_measurement::DataUseUserData::AttachToFetcher( | 68 data_use_measurement::DataUseUserData::AttachToFetcher( |
47 url_fetcher_.get(), data_use_measurement::DataUseUserData::UPDATE_CLIENT); | 69 url_fetcher_.get(), data_use_measurement::DataUseUserData::UPDATE_CLIENT); |
48 | 70 |
49 VLOG(1) << "Starting background download: " << url.spec(); | 71 VLOG(1) << "Starting background download: " << url.spec(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 total_bytes_ = total; | 131 total_bytes_ = total; |
110 | 132 |
111 Result result; | 133 Result result; |
112 result.downloaded_bytes = downloaded_bytes_; | 134 result.downloaded_bytes = downloaded_bytes_; |
113 result.total_bytes = total_bytes_; | 135 result.total_bytes = total_bytes_; |
114 | 136 |
115 OnDownloadProgress(result); | 137 OnDownloadProgress(result); |
116 } | 138 } |
117 | 139 |
118 } // namespace update_client | 140 } // namespace update_client |
OLD | NEW |