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 "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 10 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 void CallInt64CompletionCallbackWithPlatformFileError( | 37 void CallInt64CompletionCallbackWithPlatformFileError( |
38 const net::Int64CompletionCallback& callback, | 38 const net::Int64CompletionCallback& callback, |
39 base::File::Error file_error) { | 39 base::File::Error file_error) { |
40 callback.Run(net::FileErrorToNetError(file_error)); | 40 callback.Run(net::FileErrorToNetError(file_error)); |
41 } | 41 } |
42 | 42 |
43 void ReadBytes( | 43 void ReadBytes( |
44 const storage::FileSystemURL& url, | 44 const storage::FileSystemURL& url, |
45 net::IOBuffer* buf, | 45 const scoped_refptr<net::IOBuffer>& buf, |
46 int64 offset, | 46 int64 offset, |
47 int buf_len, | 47 int buf_len, |
48 const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback, | 48 const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback, |
49 const net::CompletionCallback& error_callback) { | 49 const net::CompletionCallback& error_callback) { |
50 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); | 50 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); |
51 if (!delegate) { | 51 if (!delegate) { |
52 error_callback.Run(net::ERR_FAILED); | 52 error_callback.Run(net::ERR_FAILED); |
53 return; | 53 return; |
54 } | 54 } |
55 | 55 |
56 delegate->ReadBytes( | 56 delegate->ReadBytes( |
57 url.path(), | 57 url.path(), |
58 make_scoped_refptr(buf), | 58 buf, |
59 offset, | 59 offset, |
60 buf_len, | 60 buf_len, |
61 success_callback, | 61 success_callback, |
62 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback)); | 62 base::Bind(&CallCompletionCallbackWithPlatformFileError, error_callback)); |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 MTPFileStreamReader::MTPFileStreamReader( | 67 MTPFileStreamReader::MTPFileStreamReader( |
68 storage::FileSystemContext* file_system_context, | 68 storage::FileSystemContext* file_system_context, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const base::File::Info& file_info) { | 194 const base::File::Info& file_info) { |
195 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 195 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
196 | 196 |
197 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { | 197 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { |
198 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 198 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
199 return; | 199 return; |
200 } | 200 } |
201 | 201 |
202 callback.Run(file_info.size); | 202 callback.Run(file_info.size); |
203 } | 203 } |
OLD | NEW |