| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // Appends |data| to the snapshot file specified by the |snapshot_file_path| on | 22 // Appends |data| to the snapshot file specified by the |snapshot_file_path| on |
| 23 // the file thread. | 23 // the file thread. |
| 24 // Returns the number of bytes written to the snapshot file. In case of failure, | 24 // Returns the number of bytes written to the snapshot file. In case of failure, |
| 25 // returns zero. | 25 // returns zero. |
| 26 uint32 WriteDataChunkIntoSnapshotFileOnFileThread( | 26 uint32 WriteDataChunkIntoSnapshotFileOnFileThread( |
| 27 const base::FilePath& snapshot_file_path, | 27 const base::FilePath& snapshot_file_path, |
| 28 const std::string& data) { | 28 const std::string& data) { |
| 29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 30 int bytes_written = | 30 int bytes_written = |
| 31 file_util::AppendToFile(snapshot_file_path, data.data(), | 31 base::AppendToFile(snapshot_file_path, data.data(), |
| 32 base::checked_cast<int>(data.size())); | 32 base::checked_cast<int>(data.size())); |
| 33 return (static_cast<int>(data.size()) == bytes_written) ? | 33 return (static_cast<int>(data.size()) == bytes_written) ? |
| 34 base::checked_cast<uint32>(bytes_written) : 0; | 34 base::checked_cast<uint32>(bytes_written) : 0; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 MTPReadFileWorker::MTPReadFileWorker(const std::string& device_handle) | 39 MTPReadFileWorker::MTPReadFileWorker(const std::string& device_handle) |
| 40 : device_handle_(device_handle), | 40 : device_handle_(device_handle), |
| 41 weak_ptr_factory_(this) { | 41 weak_ptr_factory_(this) { |
| 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| (...skipping 89 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 |