| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" | 5 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { | 59 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { |
| 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 61 DCHECK(snapshot_file_details.get()); | 61 DCHECK(snapshot_file_details.get()); |
| 62 | 62 |
| 63 // To avoid calling |snapshot_file_details| methods and passing ownership of | 63 // To avoid calling |snapshot_file_details| methods and passing ownership of |
| 64 // |snapshot_file_details| in the same_line. | 64 // |snapshot_file_details| in the same_line. |
| 65 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); | 65 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); |
| 66 | 66 |
| 67 device::MediaTransferProtocolManager* mtp_device_manager = | 67 device::MediaTransferProtocolManager* mtp_device_manager = |
| 68 StorageMonitor::GetInstance()->media_transfer_protocol_manager(); | 68 StorageMonitor::GetInstance()->media_transfer_protocol_manager(); |
| 69 mtp_device_manager->ReadFileChunkById( | 69 mtp_device_manager->ReadFileChunk( |
| 70 device_handle_, | 70 device_handle_, |
| 71 snapshot_file_details_ptr->file_id(), | 71 snapshot_file_details_ptr->file_id(), |
| 72 snapshot_file_details_ptr->bytes_written(), | 72 snapshot_file_details_ptr->bytes_written(), |
| 73 snapshot_file_details_ptr->BytesToRead(), | 73 snapshot_file_details_ptr->BytesToRead(), |
| 74 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile, | 74 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile, |
| 75 weak_ptr_factory_.GetWeakPtr(), | 75 weak_ptr_factory_.GetWeakPtr(), |
| 76 base::Passed(&snapshot_file_details))); | 76 base::Passed(&snapshot_file_details))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( | 79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 base::File::FILE_ERROR_FAILED)); | 132 base::File::FILE_ERROR_FAILED)); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 content::BrowserThread::PostTask( | 135 content::BrowserThread::PostTask( |
| 136 content::BrowserThread::IO, | 136 content::BrowserThread::IO, |
| 137 FROM_HERE, | 137 FROM_HERE, |
| 138 base::Bind(snapshot_file_details->success_callback(), | 138 base::Bind(snapshot_file_details->success_callback(), |
| 139 snapshot_file_details->file_info(), | 139 snapshot_file_details->file_info(), |
| 140 snapshot_file_details->snapshot_file_path())); | 140 snapshot_file_details->snapshot_file_path())); |
| 141 } | 141 } |
| OLD | NEW |