OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/snapshot_file_details.h" | 5 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 | 10 |
11 //////////////////////////////////////////////////////////////////////////////// | 11 //////////////////////////////////////////////////////////////////////////////// |
12 // SnapshotRequestInfo // | 12 // SnapshotRequestInfo // |
13 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
14 | 14 |
15 SnapshotRequestInfo::SnapshotRequestInfo( | 15 SnapshotRequestInfo::SnapshotRequestInfo( |
16 uint32_t file_id, | 16 uint32_t file_id, |
17 const base::FilePath& snapshot_file_path, | 17 const base::FilePath& snapshot_file_path, |
18 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback& | 18 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback& |
19 success_callback, | 19 success_callback, |
20 const MTPDeviceAsyncDelegate::ErrorCallback& error_callback) | 20 const MTPDeviceAsyncDelegate::ErrorCallback& error_callback) |
21 : file_id(file_id), | 21 : file_id(file_id), |
22 snapshot_file_path(snapshot_file_path), | 22 snapshot_file_path(snapshot_file_path), |
23 success_callback(success_callback), | 23 success_callback(success_callback), |
24 error_callback(error_callback) {} | 24 error_callback(error_callback) {} |
25 | 25 |
| 26 SnapshotRequestInfo::SnapshotRequestInfo(const SnapshotRequestInfo& other) = |
| 27 default; |
| 28 |
26 SnapshotRequestInfo::~SnapshotRequestInfo() { | 29 SnapshotRequestInfo::~SnapshotRequestInfo() { |
27 } | 30 } |
28 | 31 |
29 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
30 // SnapshotFileDetails // | 33 // SnapshotFileDetails // |
31 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
32 | 35 |
33 SnapshotFileDetails::SnapshotFileDetails( | 36 SnapshotFileDetails::SnapshotFileDetails( |
34 const SnapshotRequestInfo& request_info, | 37 const SnapshotRequestInfo& request_info, |
35 const base::File::Info& file_info) | 38 const base::File::Info& file_info) |
(...skipping 24 matching lines...) Expand all Loading... |
60 return !error_occurred_ && (bytes_written_ == file_info_.size); | 63 return !error_occurred_ && (bytes_written_ == file_info_.size); |
61 } | 64 } |
62 | 65 |
63 uint32_t SnapshotFileDetails::BytesToRead() const { | 66 uint32_t SnapshotFileDetails::BytesToRead() const { |
64 // Read data in 1MB chunks. | 67 // Read data in 1MB chunks. |
65 static const uint32_t kReadChunkSize = 1024 * 1024; | 68 static const uint32_t kReadChunkSize = 1024 * 1024; |
66 return std::min( | 69 return std::min( |
67 kReadChunkSize, | 70 kReadChunkSize, |
68 base::checked_cast<uint32_t>(file_info_.size) - bytes_written_); | 71 base::checked_cast<uint32_t>(file_info_.size) - bytes_written_); |
69 } | 72 } |
OLD | NEW |