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 "webkit/browser/blob/local_file_stream_reader.h" | 5 #include "webkit/browser/blob/local_file_stream_reader.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_util_proxy.h" | 8 #include "base/files/file_util_proxy.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
13 #include "net/base/file_stream.h" | 13 #include "net/base/file_stream.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 | 16 |
17 namespace webkit_blob { | 17 namespace webkit_blob { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const int kOpenFlagsForRead = base::PLATFORM_FILE_OPEN | | 21 const int kOpenFlagsForRead = base::PLATFORM_FILE_OPEN | |
22 base::PLATFORM_FILE_READ | | 22 base::PLATFORM_FILE_READ | |
23 base::PLATFORM_FILE_ASYNC; | 23 base::PLATFORM_FILE_ASYNC; |
24 | 24 |
25 // Verify if the underlying file has not been modified. | 25 // Verify if the underlying file has not been modified. |
26 bool VerifySnapshotTime(const base::Time& expected_modification_time, | 26 bool VerifySnapshotTime(const base::Time& expected_modification_time, |
27 const base::PlatformFileInfo& file_info) { | 27 const base::File::Info& file_info) { |
28 return expected_modification_time.is_null() || | 28 return expected_modification_time.is_null() || |
29 expected_modification_time.ToTimeT() == | 29 expected_modification_time.ToTimeT() == |
30 file_info.last_modified.ToTimeT(); | 30 file_info.last_modified.ToTimeT(); |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 FileStreamReader* FileStreamReader::CreateForLocalFile( | 35 FileStreamReader* FileStreamReader::CreateForLocalFile( |
36 base::TaskRunner* task_runner, | 36 base::TaskRunner* task_runner, |
37 const base::FilePath& file_path, | 37 const base::FilePath& file_path, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return; | 151 return; |
152 } | 152 } |
153 DCHECK(stream_impl_.get()); | 153 DCHECK(stream_impl_.get()); |
154 const int read_result = stream_impl_->Read(buf, buf_len, callback); | 154 const int read_result = stream_impl_->Read(buf, buf_len, callback); |
155 if (read_result != net::ERR_IO_PENDING) | 155 if (read_result != net::ERR_IO_PENDING) |
156 callback.Run(read_result); | 156 callback.Run(read_result); |
157 } | 157 } |
158 | 158 |
159 void LocalFileStreamReader::DidGetFileInfoForGetLength( | 159 void LocalFileStreamReader::DidGetFileInfoForGetLength( |
160 const net::Int64CompletionCallback& callback, | 160 const net::Int64CompletionCallback& callback, |
161 base::PlatformFileError error, | 161 base::File::Error error, |
162 const base::PlatformFileInfo& file_info) { | 162 const base::File::Info& file_info) { |
163 if (file_info.is_directory) { | 163 if (file_info.is_directory) { |
164 callback.Run(net::ERR_FILE_NOT_FOUND); | 164 callback.Run(net::ERR_FILE_NOT_FOUND); |
165 return; | 165 return; |
166 } | 166 } |
167 if (error != base::PLATFORM_FILE_OK) { | 167 if (error != base::File::FILE_OK) { |
168 callback.Run(net::PlatformFileErrorToNetError(error)); | 168 callback.Run(net::FileErrorToNetError(error)); |
169 return; | 169 return; |
170 } | 170 } |
171 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { | 171 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { |
172 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 172 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
173 return; | 173 return; |
174 } | 174 } |
175 callback.Run(file_info.size); | 175 callback.Run(file_info.size); |
176 } | 176 } |
177 | 177 |
178 } // namespace webkit_blob | 178 } // namespace webkit_blob |
OLD | NEW |