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/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "components/sync/engine/attachments/attachment_util.h" | 20 #include "components/sync/engine/attachments/attachment_util.h" |
20 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" | 21 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" |
21 #include "components/sync/protocol/sync.pb.h" | 22 #include "components/sync/protocol/sync.pb.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 233 |
233 void AttachmentDownloaderImpl::ReportResult( | 234 void AttachmentDownloaderImpl::ReportResult( |
234 const DownloadState& download_state, | 235 const DownloadState& download_state, |
235 const DownloadResult& result, | 236 const DownloadResult& result, |
236 const scoped_refptr<base::RefCountedString>& attachment_data) { | 237 const scoped_refptr<base::RefCountedString>& attachment_data) { |
237 std::vector<DownloadCallback>::const_iterator iter; | 238 std::vector<DownloadCallback>::const_iterator iter; |
238 for (iter = download_state.user_callbacks.begin(); | 239 for (iter = download_state.user_callbacks.begin(); |
239 iter != download_state.user_callbacks.end(); ++iter) { | 240 iter != download_state.user_callbacks.end(); ++iter) { |
240 std::unique_ptr<Attachment> attachment; | 241 std::unique_ptr<Attachment> attachment; |
241 if (result == DOWNLOAD_SUCCESS) { | 242 if (result == DOWNLOAD_SUCCESS) { |
242 attachment.reset(new Attachment(Attachment::CreateFromParts( | 243 attachment = base::MakeUnique<Attachment>(Attachment::CreateFromParts( |
243 download_state.attachment_id, attachment_data))); | 244 download_state.attachment_id, attachment_data)); |
244 } | 245 } |
245 | 246 |
246 base::ThreadTaskRunnerHandle::Get()->PostTask( | 247 base::ThreadTaskRunnerHandle::Get()->PostTask( |
247 FROM_HERE, base::Bind(*iter, result, base::Passed(&attachment))); | 248 FROM_HERE, base::Bind(*iter, result, base::Passed(&attachment))); |
248 } | 249 } |
249 } | 250 } |
250 | 251 |
251 bool AttachmentDownloaderImpl::ExtractCrc32c( | 252 bool AttachmentDownloaderImpl::ExtractCrc32c( |
252 const net::HttpResponseHeaders* headers, | 253 const net::HttpResponseHeaders* headers, |
253 uint32_t* crc32c) { | 254 uint32_t* crc32c) { |
(...skipping 28 matching lines...) Expand all Loading... |
282 | 283 |
283 if (crc32c_raw.size() != sizeof(*crc32c)) | 284 if (crc32c_raw.size() != sizeof(*crc32c)) |
284 return false; | 285 return false; |
285 | 286 |
286 *crc32c = | 287 *crc32c = |
287 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); | 288 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); |
288 return true; | 289 return true; |
289 } | 290 } |
290 | 291 |
291 } // namespace syncer | 292 } // namespace syncer |
OLD | NEW |