summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_writer_delegate.h
diff options
context:
space:
mode:
authorericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 19:55:00 +0000
committerericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 19:55:00 +0000
commit368ddad78d3f2eac1ea7a92cfb9716ecd0166279 (patch)
tree12991a1cf9204760a254dfacd954158035e4d52b /webkit/fileapi/file_writer_delegate.h
parentc1973bdf0c94687f96155af8249358a4b585e381 (diff)
downloadchromium_src-368ddad78d3f2eac1ea7a92cfb9716ecd0166279.zip
chromium_src-368ddad78d3f2eac1ea7a92cfb9716ecd0166279.tar.gz
chromium_src-368ddad78d3f2eac1ea7a92cfb9716ecd0166279.tar.bz2
Add the actual writing-files part of FileWriter.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3476002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_writer_delegate.h')
-rw-r--r--webkit/fileapi/file_writer_delegate.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/webkit/fileapi/file_writer_delegate.h b/webkit/fileapi/file_writer_delegate.h
new file mode 100644
index 0000000..ed35ce6
--- /dev/null
+++ b/webkit/fileapi/file_writer_delegate.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
+#define WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
+
+#include "base/file_path.h"
+#include "base/platform_file.h"
+#include "base/ref_counted.h"
+#include "base/scoped_callback_factory.h"
+#include "base/scoped_ptr.h"
+#include "base/task.h"
+#include "base/time.h"
+#include "net/base/file_stream.h"
+#include "net/base/io_buffer.h"
+#include "net/url_request/url_request.h"
+
+namespace fileapi {
+
+class FileSystemOperation;
+
+class FileWriterDelegate : public URLRequest::Delegate {
+ public:
+ FileWriterDelegate(
+ FileSystemOperation* write_operation,
+ int64 offset);
+ virtual ~FileWriterDelegate();
+
+ void Start(base::PlatformFile file, URLRequest* request);
+ base::PlatformFile file() {
+ return file_;
+ }
+
+ virtual void OnReceivedRedirect(
+ URLRequest* request, const GURL& new_url, bool* defer_redirect);
+ virtual void OnAuthRequired(
+ URLRequest* request, net::AuthChallengeInfo* auth_info);
+ virtual void OnCertificateRequested(
+ URLRequest* request, net::SSLCertRequestInfo* cert_request_info);
+ virtual void OnSSLCertificateError(
+ URLRequest* request, int cert_error, net::X509Certificate* cert);
+ virtual void OnResponseStarted(URLRequest* request);
+ virtual void OnReadCompleted(URLRequest* request, int bytes_read);
+
+ private:
+ void Read();
+ void OnDataReceived(int bytes_read);
+ void Write();
+ void OnDataWritten(int write_response);
+ void OnError(base::PlatformFileError error);
+ void OnProgress(int bytes_read, bool done);
+
+ FileSystemOperation* file_system_operation_;
+ base::PlatformFile file_;
+ int64 offset_;
+ base::Time last_progress_event_time_;
+ int bytes_read_backlog_;
+ int bytes_written_;
+ int bytes_read_;
+ scoped_refptr<net::IOBufferWithSize> io_buffer_;
+ scoped_ptr<net::FileStream> file_stream_;
+ URLRequest* request_;
+ base::ScopedCallbackFactory<FileWriterDelegate> callback_factory_;
+ ScopedRunnableMethodFactory<FileWriterDelegate> method_factory_;
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
+