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 "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h" | 5 #include "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 success_callback, | 60 success_callback, |
61 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback)); | 61 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback)); |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 MTPFileStreamReader::MTPFileStreamReader( | 66 MTPFileStreamReader::MTPFileStreamReader( |
67 fileapi::FileSystemContext* file_system_context, | 67 fileapi::FileSystemContext* file_system_context, |
68 const fileapi::FileSystemURL& url, | 68 const fileapi::FileSystemURL& url, |
69 int64 initial_offset, | 69 int64 initial_offset, |
70 const base::Time& expected_modification_time) | 70 const base::Time& expected_modification_time, |
| 71 bool do_media_header_validation) |
71 : file_system_context_(file_system_context), | 72 : file_system_context_(file_system_context), |
72 url_(url), | 73 url_(url), |
73 current_offset_(initial_offset), | 74 current_offset_(initial_offset), |
74 expected_modification_time_(expected_modification_time), | 75 expected_modification_time_(expected_modification_time), |
75 media_header_validated_(false), | 76 media_header_validated_(!do_media_header_validation), |
76 weak_factory_(this) { | 77 weak_factory_(this) { |
77 } | 78 } |
78 | 79 |
79 MTPFileStreamReader::~MTPFileStreamReader() { | 80 MTPFileStreamReader::~MTPFileStreamReader() { |
80 } | 81 } |
81 | 82 |
82 int MTPFileStreamReader::Read(net::IOBuffer* buf, int buf_len, | 83 int MTPFileStreamReader::Read(net::IOBuffer* buf, int buf_len, |
83 const net::CompletionCallback& callback) { | 84 const net::CompletionCallback& callback) { |
84 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
85 | 86 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const base::File::Info& file_info) { | 187 const base::File::Info& file_info) { |
187 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 188 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
188 | 189 |
189 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { | 190 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { |
190 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 191 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
191 return; | 192 return; |
192 } | 193 } |
193 | 194 |
194 callback.Run(file_info.size); | 195 callback.Run(file_info.size); |
195 } | 196 } |
OLD | NEW |