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 "storage/browser/fileapi/local_file_stream_reader.h" | 5 #include "storage/browser/fileapi/local_file_stream_reader.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 LocalFileStreamReader::~LocalFileStreamReader() { | 37 LocalFileStreamReader::~LocalFileStreamReader() { |
38 } | 38 } |
39 | 39 |
40 int LocalFileStreamReader::Read(net::IOBuffer* buf, int buf_len, | 40 int LocalFileStreamReader::Read(net::IOBuffer* buf, int buf_len, |
41 const net::CompletionCallback& callback) { | 41 const net::CompletionCallback& callback) { |
42 DCHECK(!has_pending_open_); | 42 DCHECK(!has_pending_open_); |
43 if (stream_impl_) | 43 if (stream_impl_) |
44 return stream_impl_->Read(buf, buf_len, callback); | 44 return stream_impl_->Read(buf, buf_len, callback); |
45 return Open(base::Bind(&LocalFileStreamReader::DidOpenForRead, | 45 return Open(base::Bind(&LocalFileStreamReader::DidOpenForRead, |
46 weak_factory_.GetWeakPtr(), | 46 weak_factory_.GetWeakPtr(), base::RetainedRef(buf), |
47 make_scoped_refptr(buf), buf_len, callback)); | 47 buf_len, callback)); |
48 } | 48 } |
49 | 49 |
50 int64_t LocalFileStreamReader::GetLength( | 50 int64_t LocalFileStreamReader::GetLength( |
51 const net::Int64CompletionCallback& callback) { | 51 const net::Int64CompletionCallback& callback) { |
52 const bool posted = base::FileUtilProxy::GetFileInfo( | 52 const bool posted = base::FileUtilProxy::GetFileInfo( |
53 task_runner_.get(), | 53 task_runner_.get(), |
54 file_path_, | 54 file_path_, |
55 base::Bind(&LocalFileStreamReader::DidGetFileInfoForGetLength, | 55 base::Bind(&LocalFileStreamReader::DidGetFileInfoForGetLength, |
56 weak_factory_.GetWeakPtr(), | 56 weak_factory_.GetWeakPtr(), |
57 callback)); | 57 callback)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return; | 160 return; |
161 } | 161 } |
162 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { | 162 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { |
163 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 163 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
164 return; | 164 return; |
165 } | 165 } |
166 callback.Run(file_info.size); | 166 callback.Run(file_info.size); |
167 } | 167 } |
168 | 168 |
169 } // namespace storage | 169 } // namespace storage |
OLD | NEW |