| 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" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "webkit/blob/local_file_stream_reader.h" | 12 #include "webkit/blob/local_file_stream_reader.h" |
| 13 #include "webkit/fileapi/file_system_context.h" | 13 #include "webkit/fileapi/file_system_context.h" |
| 14 #include "webkit/fileapi/file_system_operation_interface.h" | 14 #include "webkit/fileapi/file_system_operation.h" |
| 15 #include "webkit/fileapi/file_system_quota_util.h" | 15 #include "webkit/fileapi/file_system_quota_util.h" |
| 16 #include "webkit/fileapi/file_system_util.h" | 16 #include "webkit/fileapi/file_system_util.h" |
| 17 #include "webkit/fileapi/local_file_stream_writer.h" | 17 #include "webkit/fileapi/local_file_stream_writer.h" |
| 18 #include "webkit/quota/quota_manager.h" | 18 #include "webkit/quota/quota_manager.h" |
| 19 | 19 |
| 20 namespace fileapi { | 20 namespace fileapi { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Adjust the |quota| value in overwriting case (i.e. |file_size| > 0 and | 24 // Adjust the |quota| value in overwriting case (i.e. |file_size| > 0 and |
| (...skipping 35 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 FileSystemOperationInterface* operation = | 70 FileSystemOperation* operation = |
| 71 file_system_context_->CreateFileSystemOperation(url_); | 71 file_system_context_->CreateFileSystemOperation(url_); |
| 72 DCHECK(operation); | 72 DCHECK(operation); |
| 73 net::CompletionCallback write_task = | 73 net::CompletionCallback write_task = |
| 74 base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, | 74 base::Bind(&SandboxFileStreamWriter::DidInitializeForWrite, |
| 75 weak_factory_.GetWeakPtr(), | 75 weak_factory_.GetWeakPtr(), |
| 76 make_scoped_refptr(buf), buf_len, callback); | 76 make_scoped_refptr(buf), buf_len, callback); |
| 77 operation->GetMetadata( | 77 operation->GetMetadata( |
| 78 url_, base::Bind(&SandboxFileStreamWriter::DidGetFileInfo, | 78 url_, base::Bind(&SandboxFileStreamWriter::DidGetFileInfo, |
| 79 weak_factory_.GetWeakPtr(), write_task)); | 79 weak_factory_.GetWeakPtr(), write_task)); |
| 80 return net::ERR_IO_PENDING; | 80 return net::ERR_IO_PENDING; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 pending_cancel.Run(net::OK); | 233 pending_cancel.Run(net::OK); |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 | 236 |
| 237 FileSystemQuotaUtil* SandboxFileStreamWriter::quota_util() const { | 237 FileSystemQuotaUtil* SandboxFileStreamWriter::quota_util() const { |
| 238 DCHECK(file_system_context_.get()); | 238 DCHECK(file_system_context_.get()); |
| 239 return file_system_context_->GetQuotaUtil(url_.type()); | 239 return file_system_context_->GetQuotaUtil(url_.type()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace fileapi | 242 } // namespace fileapi |
| OLD | NEW |