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/fileapi/sandbox_file_stream_writer.h" | 5 #include "webkit/browser/fileapi/sandbox_file_stream_writer.h" |
6 | 6 |
7 #include "base/files/file_util_proxy.h" | 7 #include "base/files/file_util_proxy.h" |
8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 buf, buf_len, | 105 buf, buf_len, |
106 base::Bind(&SandboxFileStreamWriter::DidWrite, weak_factory_.GetWeakPtr(), | 106 base::Bind(&SandboxFileStreamWriter::DidWrite, weak_factory_.GetWeakPtr(), |
107 callback)); | 107 callback)); |
108 if (result != net::ERR_IO_PENDING) | 108 if (result != net::ERR_IO_PENDING) |
109 has_pending_operation_ = false; | 109 has_pending_operation_ = false; |
110 return result; | 110 return result; |
111 } | 111 } |
112 | 112 |
113 void SandboxFileStreamWriter::DidCreateSnapshotFile( | 113 void SandboxFileStreamWriter::DidCreateSnapshotFile( |
114 const net::CompletionCallback& callback, | 114 const net::CompletionCallback& callback, |
115 base::PlatformFileError file_error, | 115 base::File::Error file_error, |
116 const base::PlatformFileInfo& file_info, | 116 const base::File::Info& file_info, |
117 const base::FilePath& platform_path, | 117 const base::FilePath& platform_path, |
118 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 118 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
119 DCHECK(!file_ref.get()); | 119 DCHECK(!file_ref.get()); |
120 | 120 |
121 if (CancelIfRequested()) | 121 if (CancelIfRequested()) |
122 return; | 122 return; |
123 if (file_error != base::PLATFORM_FILE_OK) { | 123 if (file_error != base::File::FILE_OK) { |
124 callback.Run(net::PlatformFileErrorToNetError(file_error)); | 124 callback.Run(net::FileErrorToNetError(file_error)); |
125 return; | 125 return; |
126 } | 126 } |
127 if (file_info.is_directory) { | 127 if (file_info.is_directory) { |
128 // We should not be writing to a directory. | 128 // We should not be writing to a directory. |
129 callback.Run(net::ERR_ACCESS_DENIED); | 129 callback.Run(net::ERR_ACCESS_DENIED); |
130 return; | 130 return; |
131 } | 131 } |
132 file_size_ = file_info.size; | 132 file_size_ = file_info.size; |
133 if (initial_offset_ > file_size_) { | 133 if (initial_offset_ > file_size_) { |
134 LOG(ERROR) << initial_offset_ << ", " << file_size_; | 134 LOG(ERROR) << initial_offset_ << ", " << file_size_; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 DCHECK(cancel_callback_.is_null()); | 236 DCHECK(cancel_callback_.is_null()); |
237 | 237 |
238 // Write() is not called yet, so there's nothing to flush. | 238 // Write() is not called yet, so there's nothing to flush. |
239 if (!local_file_writer_) | 239 if (!local_file_writer_) |
240 return net::OK; | 240 return net::OK; |
241 | 241 |
242 return local_file_writer_->Flush(callback); | 242 return local_file_writer_->Flush(callback); |
243 } | 243 } |
244 | 244 |
245 } // namespace fileapi | 245 } // namespace fileapi |
OLD | NEW |