| 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 #ifndef WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ | 6 #define WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "net/base/file_stream.h" | 13 #include "net/base/file_stream.h" |
| 14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 16 #include "webkit/fileapi/fileapi_export.h" | 16 #include "webkit/fileapi/fileapi_export.h" |
| 17 #include "webkit/fileapi/file_system_operation_interface.h" | 17 #include "webkit/fileapi/file_system_operation.h" |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace fileapi { |
| 20 | 20 |
| 21 class FileStreamWriter; | 21 class FileStreamWriter; |
| 22 class FileSystemOperationContext; | 22 class FileSystemOperationContext; |
| 23 class FileSystemQuotaUtil; | 23 class FileSystemQuotaUtil; |
| 24 | 24 |
| 25 class FILEAPI_EXPORT_PRIVATE FileWriterDelegate | 25 class FILEAPI_EXPORT_PRIVATE FileWriterDelegate |
| 26 : public net::URLRequest::Delegate { | 26 : public net::URLRequest::Delegate { |
| 27 public: | 27 public: |
| 28 FileWriterDelegate( | 28 FileWriterDelegate( |
| 29 const FileSystemOperationInterface::WriteCallback& write_callback, | 29 const FileSystemOperation::WriteCallback& write_callback, |
| 30 scoped_ptr<FileStreamWriter> file_writer); | 30 scoped_ptr<FileStreamWriter> file_writer); |
| 31 virtual ~FileWriterDelegate(); | 31 virtual ~FileWriterDelegate(); |
| 32 | 32 |
| 33 void Start(scoped_ptr<net::URLRequest> request); | 33 void Start(scoped_ptr<net::URLRequest> request); |
| 34 | 34 |
| 35 // Cancels the current write operation. Returns true if it is ok to | 35 // Cancels the current write operation. Returns true if it is ok to |
| 36 // delete this instance immediately. Otherwise this will call | 36 // delete this instance immediately. Otherwise this will call |
| 37 // |write_operation|->DidWrite() with complete=true to let the operation | 37 // |write_operation|->DidWrite() with complete=true to let the operation |
| 38 // perform the final cleanup. | 38 // perform the final cleanup. |
| 39 bool Cancel(); | 39 bool Cancel(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 61 void Read(); | 61 void Read(); |
| 62 void OnDataReceived(int bytes_read); | 62 void OnDataReceived(int bytes_read); |
| 63 void Write(); | 63 void Write(); |
| 64 void OnDataWritten(int write_response); | 64 void OnDataWritten(int write_response); |
| 65 void OnError(base::PlatformFileError error); | 65 void OnError(base::PlatformFileError error); |
| 66 void OnProgress(int bytes_read, bool done); | 66 void OnProgress(int bytes_read, bool done); |
| 67 void OnWriteCancelled(int status); | 67 void OnWriteCancelled(int status); |
| 68 | 68 |
| 69 FileSystemQuotaUtil* quota_util() const; | 69 FileSystemQuotaUtil* quota_util() const; |
| 70 | 70 |
| 71 FileSystemOperationInterface::WriteCallback write_callback_; | 71 FileSystemOperation::WriteCallback write_callback_; |
| 72 scoped_ptr<FileStreamWriter> file_stream_writer_; | 72 scoped_ptr<FileStreamWriter> file_stream_writer_; |
| 73 base::Time last_progress_event_time_; | 73 base::Time last_progress_event_time_; |
| 74 int bytes_written_backlog_; | 74 int bytes_written_backlog_; |
| 75 int bytes_written_; | 75 int bytes_written_; |
| 76 int bytes_read_; | 76 int bytes_read_; |
| 77 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 77 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
| 78 scoped_refptr<net::DrainableIOBuffer> cursor_; | 78 scoped_refptr<net::DrainableIOBuffer> cursor_; |
| 79 scoped_ptr<net::URLRequest> request_; | 79 scoped_ptr<net::URLRequest> request_; |
| 80 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; | 80 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace fileapi | 83 } // namespace fileapi |
| 84 | 84 |
| 85 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ | 85 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| OLD | NEW |