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 <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/location.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/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" |
17 #include "base/time/time.h" | 19 #include "base/time/time.h" |
18 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
19 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
21 #include "net/http/http_util.h" | 23 #include "net/http/http_util.h" |
22 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
23 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
24 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 26 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
25 #include "sync/internal_api/public/attachments/attachment_util.h" | 27 #include "sync/internal_api/public/attachments/attachment_util.h" |
26 #include "sync/protocol/sync.pb.h" | 28 #include "sync/protocol/sync.pb.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 std::vector<DownloadCallback>::const_iterator iter; | 241 std::vector<DownloadCallback>::const_iterator iter; |
240 for (iter = download_state.user_callbacks.begin(); | 242 for (iter = download_state.user_callbacks.begin(); |
241 iter != download_state.user_callbacks.end(); | 243 iter != download_state.user_callbacks.end(); |
242 ++iter) { | 244 ++iter) { |
243 std::unique_ptr<Attachment> attachment; | 245 std::unique_ptr<Attachment> attachment; |
244 if (result == DOWNLOAD_SUCCESS) { | 246 if (result == DOWNLOAD_SUCCESS) { |
245 attachment.reset(new Attachment(Attachment::CreateFromParts( | 247 attachment.reset(new Attachment(Attachment::CreateFromParts( |
246 download_state.attachment_id, attachment_data))); | 248 download_state.attachment_id, attachment_data))); |
247 } | 249 } |
248 | 250 |
249 base::MessageLoop::current()->PostTask( | 251 base::ThreadTaskRunnerHandle::Get()->PostTask( |
250 FROM_HERE, base::Bind(*iter, result, base::Passed(&attachment))); | 252 FROM_HERE, base::Bind(*iter, result, base::Passed(&attachment))); |
251 } | 253 } |
252 } | 254 } |
253 | 255 |
254 bool AttachmentDownloaderImpl::ExtractCrc32c( | 256 bool AttachmentDownloaderImpl::ExtractCrc32c( |
255 const net::HttpResponseHeaders* headers, | 257 const net::HttpResponseHeaders* headers, |
256 uint32_t* crc32c) { | 258 uint32_t* crc32c) { |
257 DCHECK(crc32c); | 259 DCHECK(crc32c); |
258 if (!headers) { | 260 if (!headers) { |
259 return false; | 261 return false; |
(...skipping 25 matching lines...) Expand all Loading... |
285 | 287 |
286 if (crc32c_raw.size() != sizeof(*crc32c)) | 288 if (crc32c_raw.size() != sizeof(*crc32c)) |
287 return false; | 289 return false; |
288 | 290 |
289 *crc32c = | 291 *crc32c = |
290 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); | 292 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); |
291 return true; | 293 return true; |
292 } | 294 } |
293 | 295 |
294 } // namespace syncer | 296 } // namespace syncer |
OLD | NEW |