| 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/message_loop_proxy.h" | |
| 12 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/task_runner.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
| 15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "webkit/fileapi/file_system_path.h" | 17 #include "webkit/fileapi/file_system_path.h" |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace fileapi { |
| 20 | 20 |
| 21 class FileSystemOperation; | 21 class FileSystemOperation; |
| 22 class FileSystemOperationContext; | 22 class FileSystemOperationContext; |
| 23 class FileSystemQuotaUtil; | 23 class FileSystemQuotaUtil; |
| 24 | 24 |
| 25 class FileWriterDelegate : public net::URLRequest::Delegate { | 25 class FileWriterDelegate : public net::URLRequest::Delegate { |
| 26 public: | 26 public: |
| 27 FileWriterDelegate( | 27 FileWriterDelegate( |
| 28 FileSystemOperation* write_operation, | 28 FileSystemOperation* write_operation, |
| 29 const FileSystemPath& path, | 29 const FileSystemPath& path, |
| 30 int64 offset, | 30 int64 offset, |
| 31 scoped_refptr<base::MessageLoopProxy> proxy); | 31 base::TaskRunner* task_runner); |
| 32 virtual ~FileWriterDelegate(); | 32 virtual ~FileWriterDelegate(); |
| 33 | 33 |
| 34 void Start(base::PlatformFile file, | 34 void Start(base::PlatformFile file, |
| 35 net::URLRequest* request); | 35 net::URLRequest* request); |
| 36 base::PlatformFile file() { | 36 base::PlatformFile file() { |
| 37 return file_; | 37 return file_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void OnReceivedRedirect(net::URLRequest* request, | 40 virtual void OnReceivedRedirect(net::URLRequest* request, |
| 41 const GURL& new_url, | 41 const GURL& new_url, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 64 void OnProgress(int bytes_read, bool done); | 64 void OnProgress(int bytes_read, bool done); |
| 65 | 65 |
| 66 FileSystemOperationContext* file_system_operation_context() const; | 66 FileSystemOperationContext* file_system_operation_context() const; |
| 67 FileSystemQuotaUtil* quota_util() const; | 67 FileSystemQuotaUtil* quota_util() const; |
| 68 | 68 |
| 69 FileSystemOperation* file_system_operation_; | 69 FileSystemOperation* file_system_operation_; |
| 70 base::PlatformFile file_; | 70 base::PlatformFile file_; |
| 71 FileSystemPath path_; | 71 FileSystemPath path_; |
| 72 int64 size_; | 72 int64 size_; |
| 73 int64 offset_; | 73 int64 offset_; |
| 74 scoped_refptr<base::MessageLoopProxy> proxy_; | 74 scoped_refptr<base::TaskRunner> task_runner_; |
| 75 base::Time last_progress_event_time_; | 75 base::Time last_progress_event_time_; |
| 76 int bytes_written_backlog_; | 76 int bytes_written_backlog_; |
| 77 int bytes_written_; | 77 int bytes_written_; |
| 78 int bytes_read_; | 78 int bytes_read_; |
| 79 int64 total_bytes_written_; | 79 int64 total_bytes_written_; |
| 80 int64 allowed_bytes_to_write_; | 80 int64 allowed_bytes_to_write_; |
| 81 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 81 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
| 82 scoped_refptr<net::DrainableIOBuffer> cursor_; | 82 scoped_refptr<net::DrainableIOBuffer> cursor_; |
| 83 scoped_ptr<net::FileStream> file_stream_; | 83 scoped_ptr<net::FileStream> file_stream_; |
| 84 net::URLRequest* request_; | 84 net::URLRequest* request_; |
| 85 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; | 85 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace fileapi | 88 } // namespace fileapi |
| 89 | 89 |
| 90 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ | 90 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| OLD | NEW |