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

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: Created 3 years, 8 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("...", R"(
183 semantics {
184 sender: "..."
pastarmovj 2017/04/07 09:58:46 Cloud Policy
Ramin Halavati 2017/04/19 05:21:57 Done.
185 description: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:31 Used to fetch policy for extensions, policy-contro
Ramin Halavati 2017/04/19 05:21:58 Done.
186 trigger: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:31 Periodically loaded when a managed user is signed
Ramin Halavati 2017/04/19 05:21:58 Done.
187 data: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:31 Various data, supplied by the admin for the manage
Ramin Halavati 2017/04/19 05:21:57 Please elaborate.
Andrew T Wilson (Slow) 2017/04/25 13:48:01 This is used to fetch policy for extensions, which
Ramin Halavati 2017/04/26 05:28:06 Again, please confirm this is what this request se
Andrew T Wilson (Slow) 2017/04/26 09:34:11 This request sends no additional data - it is used
Ramin Halavati 2017/04/26 09:44:41 Done.
188 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
pastarmovj 2017/04/07 09:58:46 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/04/19 05:21:58 Done.
189 }
190 policy {
191 cookies_allowed: false/true
pastarmovj 2017/04/07 09:58:46 true?
Andrew T Wilson (Slow) 2017/04/18 12:01:31 true
Ramin Halavati 2017/04/19 05:21:58 Load flags disabled SAVE and SEND. Are they just l
Andrew T Wilson (Slow) 2017/04/25 13:48:01 I don't think we use them here so feel free to mar
Ramin Halavati 2017/04/26 05:28:06 Done.
192 cookies_store: "..."
pastarmovj 2017/04/07 09:58:46 system?
Andrew T Wilson (Slow) 2017/04/18 12:01:31 system
Ramin Halavati 2017/04/19 05:21:58 Acknowledged.
193 setting: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:31 none
Ramin Halavati 2017/04/19 05:21:58 Done.
194 chrome_policy {
pastarmovj 2017/04/07 09:58:46 empty?
Andrew T Wilson (Slow) 2017/04/18 12:01:31 empty
Ramin Halavati 2017/04/19 05:21:57 Done.
195 [POLICY_NAME] {
196 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
197 [POLICY_NAME]: ... //(value to disable it)
198 }
199 }
200 policy_exception_justification: "..."
pastarmovj 2017/04/07 09:58:46 This request is part of the policy fetcher itself.
Ramin Halavati 2017/04/19 05:21:57 Done.
201 })");
202 std::unique_ptr<net::URLFetcher> owned_fetcher =
203 net::URLFetcher::Create(++last_fetch_id_, job->url, net::URLFetcher::GET,
204 this, traffic_annotation);
182 net::URLFetcher* fetcher = owned_fetcher.get(); 205 net::URLFetcher* fetcher = owned_fetcher.get();
183 data_use_measurement::DataUseUserData::AttachToFetcher( 206 data_use_measurement::DataUseUserData::AttachToFetcher(
184 fetcher, data_use_measurement::DataUseUserData::POLICY); 207 fetcher, data_use_measurement::DataUseUserData::POLICY);
185 fetcher->SetRequestContext(request_context_.get()); 208 fetcher->SetRequestContext(request_context_.get());
186 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | 209 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
187 net::LOAD_DO_NOT_SAVE_COOKIES | 210 net::LOAD_DO_NOT_SAVE_COOKIES |
188 net::LOAD_DO_NOT_SEND_COOKIES | 211 net::LOAD_DO_NOT_SEND_COOKIES |
189 net::LOAD_DO_NOT_SEND_AUTH_DATA); 212 net::LOAD_DO_NOT_SEND_AUTH_DATA);
190 fetcher->SetAutomaticallyRetryOnNetworkChanges(3); 213 fetcher->SetAutomaticallyRetryOnNetworkChanges(3);
191 fetcher->Start(); 214 fetcher->Start();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ExternalPolicyDataFetcher::Job* job = it->second.job; 289 ExternalPolicyDataFetcher::Job* job = it->second.job;
267 int64_t max_size = job->max_size; 290 int64_t max_size = job->max_size;
268 if (current > max_size || total > max_size) { 291 if (current > max_size || total > max_size) {
269 job_map_.erase(it); 292 job_map_.erase(it);
270 job->callback.Run(job, ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED, 293 job->callback.Run(job, ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED,
271 std::unique_ptr<std::string>()); 294 std::unique_ptr<std::string>());
272 } 295 }
273 } 296 }
274 297
275 } // namespace policy 298 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698