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("url_fetcher_downloader", R"( | |
42 semantics { | |
43 sender: "Component Updater" | |
44 description: | |
45 "The component updater in Chrome is responsible for updating code " | |
46 "and data modules such as Flash, CrlSet, Origin Trials, etc. These " | |
47 "modules are updated on cycles independent of the Chrome release " | |
48 "tracks. It runs in the browser process and communicates with a " | |
49 "set of servers using the Omaha protocol to find the latest " | |
50 "versions of components, download them, and register them with the " | |
51 "rest of Chrome." | |
52 trigger: "Manual or automatic software updates." | |
53 data: | |
54 "The URL that refers to a component. It is obfuscated for most " | |
55 "components." | |
56 destination: GOOGLE_OWNED_SERVICE | |
57 } | |
58 policy { | |
59 cookies_allowed: false | |
60 setting: "This feature cannot be disabled." | |
waffles
2017/05/18 16:13:10
nit: the protocol buffer comments say to use "NA".
| |
61 chrome_policy { | |
62 ComponentUpdatesEnabled { | |
63 policy_options {mode: MANDATORY} | |
64 ComponentUpdatesEnabled: false | |
65 } | |
66 } | |
67 })"); | |
68 url_fetcher_ = net::URLFetcher::Create(0, url, net::URLFetcher::GET, this, | |
69 traffic_annotation); | |
40 url_fetcher_->SetRequestContext(context_getter_); | 70 url_fetcher_->SetRequestContext(context_getter_); |
41 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 71 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
42 net::LOAD_DO_NOT_SAVE_COOKIES | | 72 net::LOAD_DO_NOT_SAVE_COOKIES | |
43 net::LOAD_DISABLE_CACHE); | 73 net::LOAD_DISABLE_CACHE); |
44 url_fetcher_->SetAutomaticallyRetryOn5xx(false); | 74 url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
45 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); | 75 url_fetcher_->SaveResponseToTemporaryFile(task_runner()); |
46 data_use_measurement::DataUseUserData::AttachToFetcher( | 76 data_use_measurement::DataUseUserData::AttachToFetcher( |
47 url_fetcher_.get(), data_use_measurement::DataUseUserData::UPDATE_CLIENT); | 77 url_fetcher_.get(), data_use_measurement::DataUseUserData::UPDATE_CLIENT); |
48 | 78 |
49 VLOG(1) << "Starting background download: " << url.spec(); | 79 VLOG(1) << "Starting background download: " << url.spec(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 total_bytes_ = total; | 139 total_bytes_ = total; |
110 | 140 |
111 Result result; | 141 Result result; |
112 result.downloaded_bytes = downloaded_bytes_; | 142 result.downloaded_bytes = downloaded_bytes_; |
113 result.total_bytes = total_bytes_; | 143 result.total_bytes = total_bytes_; |
114 | 144 |
115 OnDownloadProgress(result); | 145 OnDownloadProgress(result); |
116 } | 146 } |
117 | 147 |
118 } // namespace update_client | 148 } // namespace update_client |
OLD | NEW |