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("attachment_downloader", R"( |
|
msramek
2017/03/09 12:02:32
Ditto.
Ramin Halavati
2017/03/09 12:31:20
Acknowledged.
| |
| 220 semantics { | |
| 221 sender: "Chrome Sync" | |
| 222 description: | |
| 223 "Chrome Sync synchronizes profile data between Chromium clients " | |
| 224 "and Google for a given user account." | |
| 225 trigger: | |
| 226 "User makes a change to syncable profile data after enabling sync " | |
| 227 "on the device." | |
| 228 data: | |
| 229 "The device and user identifiers, along with any profile data that " | |
| 230 "is changing." | |
| 231 destination: GOOGLE_OWNED_SERVICE | |
| 232 } | |
| 233 policy { | |
| 234 cookies_allowed: false | |
| 235 setting: | |
| 236 "Users can disable Chrome Sync by going into the profile settings " | |
| 237 "and choosing to Sign Out." | |
| 238 policy { | |
| 239 SyncDisabled { | |
| 240 policy_options {mode: MANDATORY} | |
| 241 SyncDisabled: true | |
| 242 } | |
| 243 } | |
| 244 })"); | |
| 245 std::unique_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( | |
| 246 GURL(url), net::URLFetcher::GET, this, traffic_annotation); | |
| 219 AttachmentUploaderImpl::ConfigureURLFetcherCommon( | 247 AttachmentUploaderImpl::ConfigureURLFetcherCommon( |
| 220 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, | 248 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, |
| 221 url_request_context_getter_.get()); | 249 url_request_context_getter_.get()); |
| 222 data_use_measurement::DataUseUserData::AttachToFetcher( | 250 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 223 url_fetcher.get(), data_use_measurement::DataUseUserData::SYNC); | 251 url_fetcher.get(), data_use_measurement::DataUseUserData::SYNC); |
| 224 return url_fetcher; | 252 return url_fetcher; |
| 225 } | 253 } |
| 226 | 254 |
| 227 void AttachmentDownloaderImpl::RequestAccessToken( | 255 void AttachmentDownloaderImpl::RequestAccessToken( |
| 228 DownloadState* download_state) { | 256 DownloadState* download_state) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 | 314 |
| 287 if (crc32c_raw.size() != sizeof(*crc32c)) | 315 if (crc32c_raw.size() != sizeof(*crc32c)) |
| 288 return false; | 316 return false; |
| 289 | 317 |
| 290 *crc32c = | 318 *crc32c = |
| 291 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); | 319 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); |
| 292 return true; | 320 return true; |
| 293 } | 321 } |
| 294 | 322 |
| 295 } // namespace syncer | 323 } // namespace syncer |
| OLD | NEW |