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

Side by Side Diff: components/policy/core/common/cloud/external_policy_data_fetcher.cc

Issue 2800653002: Network traffic annotation added to common/cloud. (Closed)
Patch Set: Annotation updated. Created 3 years, 7 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/core/common/cloud/external_policy_data_fetcher.h" 5 #include "components/policy/core/common/cloud/external_policy_data_fetcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "components/data_use_measurement/core/data_use_user_data.h" 17 #include "components/data_use_measurement/core/data_use_user_data.h"
18 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/traffic_annotation/network_traffic_annotation.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
23 24
24 namespace policy { 25 namespace policy {
25 26
26 namespace { 27 namespace {
27 28
28 // Helper that forwards the result of a fetch job from the thread that the 29 // Helper that forwards the result of a fetch job from the thread that the
29 // ExternalPolicyDataFetcherBackend runs on to the thread that the 30 // ExternalPolicyDataFetcherBackend runs on to the thread that the
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 std::unique_ptr<ExternalPolicyDataFetcher> 171 std::unique_ptr<ExternalPolicyDataFetcher>
171 ExternalPolicyDataFetcherBackend::CreateFrontend( 172 ExternalPolicyDataFetcherBackend::CreateFrontend(
172 scoped_refptr<base::SequencedTaskRunner> task_runner) { 173 scoped_refptr<base::SequencedTaskRunner> task_runner) {
173 return base::MakeUnique<ExternalPolicyDataFetcher>( 174 return base::MakeUnique<ExternalPolicyDataFetcher>(
174 task_runner, io_task_runner_, weak_factory_.GetWeakPtr()); 175 task_runner, io_task_runner_, weak_factory_.GetWeakPtr());
175 } 176 }
176 177
177 void ExternalPolicyDataFetcherBackend::StartJob( 178 void ExternalPolicyDataFetcherBackend::StartJob(
178 ExternalPolicyDataFetcher::Job* job) { 179 ExternalPolicyDataFetcher::Job* job) {
179 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 180 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
180 std::unique_ptr<net::URLFetcher> owned_fetcher = net::URLFetcher::Create( 181 net::NetworkTrafficAnnotationTag traffic_annotation =
181 ++last_fetch_id_, job->url, net::URLFetcher::GET, this); 182 net::DefineNetworkTrafficAnnotation("external_policy_fetcher", R"(
183 semantics {
184 sender: "Cloud Policy"
185 description:
186 "Used to fetch policy for extensions, policy-controlled wallpaper, "
187 "and custom terms of service."
188 trigger:
189 "Periodically loaded when a managed user is signed in to Chrome."
190 data:
191 "This request does not send any data. It loads external resources "
192 "by a unique URL provided by the admin."
193 destination: GOOGLE_OWNED_SERVICE
194 }
195 policy {
196 cookies_allowed: false
197 setting:
198 "This feature cannot be controlled by Chrome settings, but users "
199 "can sign out of Chrome to disable it."
200 policy_exception_justification:
201 "Not implemented, considered not useful. This request is part of "
202 "the policy fetcher itself."
203 })");
204 std::unique_ptr<net::URLFetcher> owned_fetcher =
205 net::URLFetcher::Create(++last_fetch_id_, job->url, net::URLFetcher::GET,
206 this, traffic_annotation);
182 net::URLFetcher* fetcher = owned_fetcher.get(); 207 net::URLFetcher* fetcher = owned_fetcher.get();
183 data_use_measurement::DataUseUserData::AttachToFetcher( 208 data_use_measurement::DataUseUserData::AttachToFetcher(
184 fetcher, data_use_measurement::DataUseUserData::POLICY); 209 fetcher, data_use_measurement::DataUseUserData::POLICY);
185 fetcher->SetRequestContext(request_context_.get()); 210 fetcher->SetRequestContext(request_context_.get());
186 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | 211 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
187 net::LOAD_DO_NOT_SAVE_COOKIES | 212 net::LOAD_DO_NOT_SAVE_COOKIES |
188 net::LOAD_DO_NOT_SEND_COOKIES | 213 net::LOAD_DO_NOT_SEND_COOKIES |
189 net::LOAD_DO_NOT_SEND_AUTH_DATA); 214 net::LOAD_DO_NOT_SEND_AUTH_DATA);
190 fetcher->SetAutomaticallyRetryOnNetworkChanges(3); 215 fetcher->SetAutomaticallyRetryOnNetworkChanges(3);
191 fetcher->Start(); 216 fetcher->Start();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ExternalPolicyDataFetcher::Job* job = it->second.job; 291 ExternalPolicyDataFetcher::Job* job = it->second.job;
267 int64_t max_size = job->max_size; 292 int64_t max_size = job->max_size;
268 if (current > max_size || total > max_size) { 293 if (current > max_size || total > max_size) {
269 job_map_.erase(it); 294 job_map_.erase(it);
270 job->callback.Run(job, ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED, 295 job->callback.Run(job, ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED,
271 std::unique_ptr<std::string>()); 296 std::unique_ptr<std::string>());
272 } 297 }
273 } 298 }
274 299
275 } // namespace policy 300 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698