| 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/safe_numerics.h" | 10 #include "base/safe_numerics.h" |
| 11 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" | 11 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" |
| 12 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 14 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 16 |
| 16 using content::BrowserThread; | 17 using content::BrowserThread; |
| 17 | 18 |
| 18 namespace chrome { | 19 namespace chrome { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 void MTPReadFileWorker::ReadDataChunkFromDeviceFile( | 59 void MTPReadFileWorker::ReadDataChunkFromDeviceFile( |
| 59 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { | 60 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { |
| 60 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 61 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 61 DCHECK(snapshot_file_details.get()); | 62 DCHECK(snapshot_file_details.get()); |
| 62 | 63 |
| 63 // To avoid calling |snapshot_file_details| methods and passing ownership of | 64 // To avoid calling |snapshot_file_details| methods and passing ownership of |
| 64 // |snapshot_file_details| in the same_line. | 65 // |snapshot_file_details| in the same_line. |
| 65 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); | 66 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); |
| 66 | 67 |
| 67 device::MediaTransferProtocolManager* mtp_device_mgr = | 68 device::MediaTransferProtocolManager* mtp_device_manager = |
| 68 device::MediaTransferProtocolManager::GetInstance(); | 69 StorageMonitor::GetInstance()->media_transfer_protocol_manager(); |
| 69 mtp_device_mgr->ReadFileChunkByPath( | 70 mtp_device_manager->ReadFileChunkByPath( |
| 70 device_handle_, | 71 device_handle_, |
| 71 snapshot_file_details_ptr->device_file_path(), | 72 snapshot_file_details_ptr->device_file_path(), |
| 72 snapshot_file_details_ptr->bytes_written(), | 73 snapshot_file_details_ptr->bytes_written(), |
| 73 snapshot_file_details_ptr->BytesToRead(), | 74 snapshot_file_details_ptr->BytesToRead(), |
| 74 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile, | 75 base::Bind(&MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile, |
| 75 weak_ptr_factory_.GetWeakPtr(), | 76 weak_ptr_factory_.GetWeakPtr(), |
| 76 base::Passed(&snapshot_file_details))); | 77 base::Passed(&snapshot_file_details))); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( | 80 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 135 } |
| 135 content::BrowserThread::PostTask( | 136 content::BrowserThread::PostTask( |
| 136 content::BrowserThread::IO, | 137 content::BrowserThread::IO, |
| 137 FROM_HERE, | 138 FROM_HERE, |
| 138 base::Bind(snapshot_file_details->success_callback(), | 139 base::Bind(snapshot_file_details->success_callback(), |
| 139 snapshot_file_details->file_info(), | 140 snapshot_file_details->file_info(), |
| 140 snapshot_file_details->snapshot_file_path())); | 141 snapshot_file_details->snapshot_file_path())); |
| 141 } | 142 } |
| 142 | 143 |
| 143 } // namespace chrome | 144 } // namespace chrome |
| OLD | NEW |