Chromium Code Reviews| 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/sync/engine_impl/attachments/attachment_downloader_impl.h" | 5 #include "components/sync/engine_impl/attachments/attachment_downloader_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "components/data_use_measurement/core/data_use_user_data.h" | 20 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 21 #include "components/sync/engine/attachments/attachment_util.h" | 21 #include "components/sync/engine/attachments/attachment_util.h" |
| 22 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" | 22 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" |
| 23 #include "components/sync/protocol/sync.pb.h" | 23 #include "components/sync/protocol/sync.pb.h" |
| 24 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 25 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_status_code.h" | 26 #include "net/http/http_status_code.h" |
| 27 #include "net/http/http_util.h" | 27 #include "net/http/http_util.h" |
| 28 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 28 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
| 29 #include "net/url_request/url_request_status.h" | 30 #include "net/url_request/url_request_status.h" |
| 30 | 31 |
| 31 namespace syncer { | 32 namespace syncer { |
| 32 | 33 |
| 33 struct AttachmentDownloaderImpl::DownloadState { | 34 struct AttachmentDownloaderImpl::DownloadState { |
| 34 public: | 35 public: |
| 35 DownloadState(const AttachmentId& attachment_id, | 36 DownloadState(const AttachmentId& attachment_id, |
| 36 const AttachmentUrl& attachment_url); | 37 const AttachmentUrl& attachment_url); |
| 37 | 38 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } else if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) { | 208 } else if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) { |
| 208 result = DOWNLOAD_TRANSIENT_ERROR; | 209 result = DOWNLOAD_TRANSIENT_ERROR; |
| 209 } | 210 } |
| 210 ReportResult(download_state, result, attachment_data); | 211 ReportResult(download_state, result, attachment_data); |
| 211 state_map_.erase(iter); | 212 state_map_.erase(iter); |
| 212 } | 213 } |
| 213 | 214 |
| 214 std::unique_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher( | 215 std::unique_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher( |
| 215 const AttachmentUrl& url, | 216 const AttachmentUrl& url, |
| 216 const std::string& access_token) { | 217 const std::string& access_token) { |
| 217 std::unique_ptr<net::URLFetcher> url_fetcher = | 218 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 218 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this); | 219 net::DefineNetworkTrafficAnnotation("...", R"( |
|
Nicolas Zea
2017/03/03 22:39:56
same as the http bridge
Ramin Halavati
2017/03/06 06:55:45
Done.
| |
| 220 semantics { | |
| 221 sender: "..." | |
| 222 description: "..." | |
| 223 trigger: "..." | |
| 224 data: "..." | |
| 225 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 226 } | |
| 227 policy { | |
| 228 cookies_allowed: false/true | |
| 229 cookies_store: "..." | |
| 230 setting: "..." | |
| 231 policy { | |
| 232 [POLICY_NAME] { | |
| 233 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 234 value: ... | |
| 235 } | |
| 236 } | |
| 237 policy_exception_justification: "..." | |
| 238 })"); | |
| 239 std::unique_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( | |
| 240 GURL(url), net::URLFetcher::GET, this, traffic_annotation); | |
| 219 AttachmentUploaderImpl::ConfigureURLFetcherCommon( | 241 AttachmentUploaderImpl::ConfigureURLFetcherCommon( |
| 220 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, | 242 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, |
| 221 url_request_context_getter_.get()); | 243 url_request_context_getter_.get()); |
| 222 data_use_measurement::DataUseUserData::AttachToFetcher( | 244 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 223 url_fetcher.get(), data_use_measurement::DataUseUserData::SYNC); | 245 url_fetcher.get(), data_use_measurement::DataUseUserData::SYNC); |
| 224 return url_fetcher; | 246 return url_fetcher; |
| 225 } | 247 } |
| 226 | 248 |
| 227 void AttachmentDownloaderImpl::RequestAccessToken( | 249 void AttachmentDownloaderImpl::RequestAccessToken( |
| 228 DownloadState* download_state) { | 250 DownloadState* download_state) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 | 308 |
| 287 if (crc32c_raw.size() != sizeof(*crc32c)) | 309 if (crc32c_raw.size() != sizeof(*crc32c)) |
| 288 return false; | 310 return false; |
| 289 | 311 |
| 290 *crc32c = | 312 *crc32c = |
| 291 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); | 313 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); |
| 292 return true; | 314 return true; |
| 293 } | 315 } |
| 294 | 316 |
| 295 } // namespace syncer | 317 } // namespace syncer |
| OLD | NEW |