| 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 "sync/internal_api/public/attachments/attachment_downloader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_downloader_impl.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/sys_byteorder.h" | 13 #include "base/sys_byteorder.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 17 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 20 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
| 21 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 22 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
| 22 #include "sync/internal_api/public/attachments/attachment_util.h" | 23 #include "sync/internal_api/public/attachments/attachment_util.h" |
| 23 #include "sync/protocol/sync.pb.h" | 24 #include "sync/protocol/sync.pb.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 202 } |
| 202 ReportResult(download_state, result, attachment_data); | 203 ReportResult(download_state, result, attachment_data); |
| 203 state_map_.erase(iter); | 204 state_map_.erase(iter); |
| 204 } | 205 } |
| 205 | 206 |
| 206 scoped_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher( | 207 scoped_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher( |
| 207 const AttachmentUrl& url, | 208 const AttachmentUrl& url, |
| 208 const std::string& access_token) { | 209 const std::string& access_token) { |
| 209 scoped_ptr<net::URLFetcher> url_fetcher = | 210 scoped_ptr<net::URLFetcher> url_fetcher = |
| 210 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this); | 211 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this); |
| 212 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 213 url_fetcher.get(), data_use_measurement::DataUseUserData::SYNC); |
| 211 AttachmentUploaderImpl::ConfigureURLFetcherCommon( | 214 AttachmentUploaderImpl::ConfigureURLFetcherCommon( |
| 212 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, | 215 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, |
| 213 url_request_context_getter_.get()); | 216 url_request_context_getter_.get()); |
| 214 return url_fetcher.Pass(); | 217 return url_fetcher.Pass(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 void AttachmentDownloaderImpl::RequestAccessToken( | 220 void AttachmentDownloaderImpl::RequestAccessToken( |
| 218 DownloadState* download_state) { | 221 DownloadState* download_state) { |
| 219 requests_waiting_for_access_token_.push_back(download_state); | 222 requests_waiting_for_access_token_.push_back(download_state); |
| 220 // Start access token request if there is no active one. | 223 // Start access token request if there is no active one. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 280 |
| 278 if (crc32c_raw.size() != sizeof(*crc32c)) | 281 if (crc32c_raw.size() != sizeof(*crc32c)) |
| 279 return false; | 282 return false; |
| 280 | 283 |
| 281 *crc32c = | 284 *crc32c = |
| 282 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); | 285 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); |
| 283 return true; | 286 return true; |
| 284 } | 287 } |
| 285 | 288 |
| 286 } // namespace syncer | 289 } // namespace syncer |
| OLD | NEW |