OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "components/data_use_measurement/core/data_use_user_data.h" |
13 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
18 | 19 |
19 namespace policy { | 20 namespace policy { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return make_scoped_ptr(new ExternalPolicyDataFetcher( | 167 return make_scoped_ptr(new ExternalPolicyDataFetcher( |
167 task_runner, io_task_runner_, weak_factory_.GetWeakPtr())); | 168 task_runner, io_task_runner_, weak_factory_.GetWeakPtr())); |
168 } | 169 } |
169 | 170 |
170 void ExternalPolicyDataFetcherBackend::StartJob( | 171 void ExternalPolicyDataFetcherBackend::StartJob( |
171 ExternalPolicyDataFetcher::Job* job) { | 172 ExternalPolicyDataFetcher::Job* job) { |
172 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 173 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
173 net::URLFetcher* fetcher = | 174 net::URLFetcher* fetcher = |
174 net::URLFetcher::Create(++last_fetch_id_, job->url, net::URLFetcher::GET, | 175 net::URLFetcher::Create(++last_fetch_id_, job->url, net::URLFetcher::GET, |
175 this).release(); | 176 this).release(); |
| 177 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 178 fetcher, data_use_measurement::DataUseUserData::POLICY); |
176 fetcher->SetRequestContext(request_context_.get()); | 179 fetcher->SetRequestContext(request_context_.get()); |
177 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 180 fetcher->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
178 net::LOAD_DO_NOT_SAVE_COOKIES | | 181 net::LOAD_DO_NOT_SAVE_COOKIES | |
179 net::LOAD_DO_NOT_SEND_COOKIES | | 182 net::LOAD_DO_NOT_SEND_COOKIES | |
180 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 183 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
181 fetcher->SetAutomaticallyRetryOnNetworkChanges(3); | 184 fetcher->SetAutomaticallyRetryOnNetworkChanges(3); |
182 fetcher->Start(); | 185 fetcher->Start(); |
183 job_map_[fetcher] = job; | 186 job_map_[fetcher] = job; |
184 } | 187 } |
185 | 188 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ExternalPolicyDataFetcher::Job* job = it->second; | 262 ExternalPolicyDataFetcher::Job* job = it->second; |
260 delete it->first; | 263 delete it->first; |
261 job_map_.erase(it); | 264 job_map_.erase(it); |
262 job->callback.Run(job, | 265 job->callback.Run(job, |
263 ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED, | 266 ExternalPolicyDataFetcher::MAX_SIZE_EXCEEDED, |
264 scoped_ptr<std::string>()); | 267 scoped_ptr<std::string>()); |
265 } | 268 } |
266 } | 269 } |
267 | 270 |
268 } // namespace policy | 271 } // namespace policy |
OLD | NEW |