| 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/sandbox_file_stream_writer.h" | 5 #include "webkit/fileapi/sandbox_file_stream_writer.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/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 quota_util()->proxy()->EndUpdateOrigin(url_.origin(), url_.type()); | 60 quota_util()->proxy()->EndUpdateOrigin(url_.origin(), url_.type()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 int SandboxFileStreamWriter::Write( | 63 int SandboxFileStreamWriter::Write( |
| 64 net::IOBuffer* buf, int buf_len, | 64 net::IOBuffer* buf, int buf_len, |
| 65 const net::CompletionCallback& callback) { | 65 const net::CompletionCallback& callback) { |
| 66 has_pending_operation_ = true; | 66 has_pending_operation_ = true; |
| 67 if (local_file_writer_.get()) | 67 if (local_file_writer_.get()) |
| 68 return WriteInternal(buf, buf_len, callback); | 68 return WriteInternal(buf, buf_len, callback); |
| 69 | 69 |
| 70 base::PlatformFileError error_code; |
| 70 FileSystemOperation* operation = | 71 FileSystemOperation* operation = |
| 71 file_system_context_->CreateFileSystemOperation(url_); | 72 file_system_context_->CreateFileSystemOperation(url_, &error_code); |
| 73 if (error_code != base::PLATFORM_FILE_OK) |
| 74 return net::PlatformFileErrorToNetError(error_code); |
| 75 |
| 72 DCHECK(operation); | 76 DCHECK(operation); |
| 73 net::CompletionCallback write_task = | 77 net::CompletionCallback write_task = |
| 74 base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, | 78 base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, |
| 75 weak_factory_.GetWeakPtr(), | 79 weak_factory_.GetWeakPtr(), |
| 76 make_scoped_refptr(buf), buf_len, callback); | 80 make_scoped_refptr(buf), buf_len, callback); |
| 77 operation->GetMetadata( | 81 operation->GetMetadata( |
| 78 url_, base::Bind(&SandboxFileStreamWriter::DidGetFileInfo, | 82 url_, base::Bind(&SandboxFileStreamWriter::DidGetFileInfo, |
| 79 weak_factory_.GetWeakPtr(), write_task)); | 83 weak_factory_.GetWeakPtr(), write_task)); |
| 80 return net::ERR_IO_PENDING; | 84 return net::ERR_IO_PENDING; |
| 81 } | 85 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 pending_cancel.Run(net::OK); | 237 pending_cancel.Run(net::OK); |
| 234 return true; | 238 return true; |
| 235 } | 239 } |
| 236 | 240 |
| 237 FileSystemQuotaUtil* SandboxFileStreamWriter::quota_util() const { | 241 FileSystemQuotaUtil* SandboxFileStreamWriter::quota_util() const { |
| 238 DCHECK(file_system_context_.get()); | 242 DCHECK(file_system_context_.get()); |
| 239 return file_system_context_->GetQuotaUtil(url_.type()); | 243 return file_system_context_->GetQuotaUtil(url_.type()); |
| 240 } | 244 } |
| 241 | 245 |
| 242 } // namespace fileapi | 246 } // namespace fileapi |
| OLD | NEW |