Chromium Code Reviews| 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/fileapi/file_system_file_stream_reader.h" | 5 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 6 | 6 |
| 7 #include "base/file_util_proxy.h" | 7 #include "base/file_util_proxy.h" |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 void Int64CallbackAdapter(const net::Int64CompletionCallback& callback, | 43 void Int64CallbackAdapter(const net::Int64CompletionCallback& callback, |
| 44 int value) { | 44 int value) { |
| 45 callback.Run(value); | 45 callback.Run(value); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 FileSystemFileStreamReader::FileSystemFileStreamReader( | 50 FileSystemFileStreamReader::FileSystemFileStreamReader( |
| 51 FileSystemContext* file_system_context, | 51 FileSystemContext* file_system_context, |
| 52 const FileSystemURL& url, | 52 const FileSystemURL& url, |
| 53 int64 initial_offset) | 53 int64 initial_offset, |
| 54 const base::Time& expected_modification_time) | |
| 54 : file_system_context_(file_system_context), | 55 : file_system_context_(file_system_context), |
| 55 url_(url), | 56 url_(url), |
| 56 initial_offset_(initial_offset), | 57 initial_offset_(initial_offset), |
| 58 expected_modification_time_(expected_modification_time), | |
| 57 has_pending_create_snapshot_(false), | 59 has_pending_create_snapshot_(false), |
| 58 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 60 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 59 } | 61 } |
| 60 | 62 |
| 61 FileSystemFileStreamReader::~FileSystemFileStreamReader() { | 63 FileSystemFileStreamReader::~FileSystemFileStreamReader() { |
| 62 } | 64 } |
| 63 | 65 |
| 64 int FileSystemFileStreamReader::Read( | 66 int FileSystemFileStreamReader::Read( |
| 65 net::IOBuffer* buf, int buf_len, | 67 net::IOBuffer* buf, int buf_len, |
| 66 const net::CompletionCallback& callback) { | 68 const net::CompletionCallback& callback) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 const base::Closure& callback, | 106 const base::Closure& callback, |
| 105 const net::CompletionCallback& error_callback, | 107 const net::CompletionCallback& error_callback, |
| 106 base::PlatformFileError file_error, | 108 base::PlatformFileError file_error, |
| 107 const base::PlatformFileInfo& file_info, | 109 const base::PlatformFileInfo& file_info, |
| 108 const FilePath& platform_path, | 110 const FilePath& platform_path, |
| 109 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 111 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
| 110 DCHECK(has_pending_create_snapshot_); | 112 DCHECK(has_pending_create_snapshot_); |
| 111 DCHECK(!local_file_reader_.get()); | 113 DCHECK(!local_file_reader_.get()); |
| 112 has_pending_create_snapshot_ = false; | 114 has_pending_create_snapshot_ = false; |
| 113 | 115 |
| 114 if (file_error != base::PLATFORM_FILE_OK) { | 116 int net_error = net::PlatformFileErrorToNetError(file_error); |
| 115 error_callback.Run(net::PlatformFileErrorToNetError(file_error)); | 117 |
| 118 if (!expected_modification_time_.is_null() && | |
| 119 expected_modification_time_.ToTimeT() != | |
| 120 file_info.last_modified.ToTimeT()) | |
| 121 net_error = net::ERR_UPLOAD_FILE_CHANGED; | |
| 122 | |
| 123 if (net_error != net::OK) { | |
| 124 error_callback.Run(net_error); | |
| 116 return; | 125 return; |
| 117 } | 126 } |
| 118 | 127 |
| 119 // Keep the reference (if it's non-null) so that the file won't go away. | 128 // Keep the reference (if it's non-null) so that the file won't go away. |
| 120 snapshot_ref_ = file_ref; | 129 snapshot_ref_ = file_ref; |
| 121 | 130 |
| 122 local_file_reader_.reset( | 131 local_file_reader_.reset( |
| 123 new LocalFileStreamReader( | 132 new LocalFileStreamReader( |
| 124 file_system_context_->task_runners()->file_task_runner(), | 133 file_system_context_->task_runners()->file_task_runner(), |
| 125 platform_path, initial_offset_, base::Time())); | 134 platform_path, initial_offset_, base::Time())); |
|
kinuko
2012/10/15 07:24:07
I guess it might just work if you pass the expecte
hashimoto
2012/10/15 08:05:04
Sounds great, thanks!
Done.
| |
| 126 | 135 |
| 127 callback.Run(); | 136 callback.Run(); |
| 128 } | 137 } |
| 129 | 138 |
| 130 } // namespace fileapi | 139 } // namespace fileapi |
| OLD | NEW |