| 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/blob/local_file_stream_reader.h" | 5 #include "webkit/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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 LocalFileStreamReader::LocalFileStreamReader( | 35 LocalFileStreamReader::LocalFileStreamReader( |
| 36 base::TaskRunner* task_runner, | 36 base::TaskRunner* task_runner, |
| 37 const base::FilePath& file_path, | 37 const base::FilePath& file_path, |
| 38 int64 initial_offset, | 38 int64 initial_offset, |
| 39 const base::Time& expected_modification_time) | 39 const base::Time& expected_modification_time) |
| 40 : task_runner_(task_runner), | 40 : task_runner_(task_runner), |
| 41 file_path_(file_path), | 41 file_path_(file_path), |
| 42 initial_offset_(initial_offset), | 42 initial_offset_(initial_offset), |
| 43 expected_modification_time_(expected_modification_time), | 43 expected_modification_time_(expected_modification_time), |
| 44 has_pending_open_(false), | 44 has_pending_open_(false), |
| 45 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} | 45 weak_factory_(this) {} |
| 46 | 46 |
| 47 LocalFileStreamReader::~LocalFileStreamReader() { | 47 LocalFileStreamReader::~LocalFileStreamReader() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 int LocalFileStreamReader::Read(net::IOBuffer* buf, int buf_len, | 50 int LocalFileStreamReader::Read(net::IOBuffer* buf, int buf_len, |
| 51 const net::CompletionCallback& callback) { | 51 const net::CompletionCallback& callback) { |
| 52 DCHECK(!has_pending_open_); | 52 DCHECK(!has_pending_open_); |
| 53 if (stream_impl_.get()) | 53 if (stream_impl_.get()) |
| 54 return stream_impl_->Read(buf, buf_len, callback); | 54 return stream_impl_->Read(buf, buf_len, callback); |
| 55 return Open(base::Bind(&LocalFileStreamReader::DidOpenForRead, | 55 return Open(base::Bind(&LocalFileStreamReader::DidOpenForRead, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { | 160 if (!VerifySnapshotTime(expected_modification_time_, file_info)) { |
| 161 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); | 161 callback.Run(net::ERR_UPLOAD_FILE_CHANGED); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 callback.Run(file_info.size); | 164 callback.Run(file_info.size); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace webkit_blob | 167 } // namespace webkit_blob |
| OLD | NEW |