Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: webkit/fileapi/file_writer_delegate.h

Issue 10387054: Implement SandboxFileWriter and rewrite FileWriterDelegate to use it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/file_writer.h ('k') | webkit/fileapi/file_writer_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_system_operation_interface.h"
16 #include "webkit/fileapi/file_system_path.h" 17 #include "webkit/fileapi/file_system_path.h"
17 18
18 namespace fileapi { 19 namespace fileapi {
19 20
20 class FileSystemOperation;
21 class FileSystemOperationContext; 21 class FileSystemOperationContext;
22 class FileSystemQuotaUtil; 22 class FileSystemQuotaUtil;
23 class FileWriter;
23 24
24 class FileWriterDelegate : public net::URLRequest::Delegate { 25 class FileWriterDelegate : public net::URLRequest::Delegate {
25 public: 26 public:
26 FileWriterDelegate( 27 FileWriterDelegate(
27 FileSystemOperation* write_operation, 28 const FileSystemOperationInterface::WriteCallback& write_callback,
28 const FileSystemPath& path, 29 scoped_ptr<FileWriter> file_writer);
29 int64 offset);
30 virtual ~FileWriterDelegate(); 30 virtual ~FileWriterDelegate();
31 31
32 void Start(base::PlatformFile file, 32 void Start(scoped_ptr<net::URLRequest> request);
33 scoped_ptr<net::URLRequest> request);
34 33
35 // Cancels the current write operation. Returns true if it is ok to 34 // Cancels the current write operation. Returns true if it is ok to
36 // delete this instance immediately. Otherwise this will call 35 // delete this instance immediately. Otherwise this will call
37 // |write_operation|->DidWrite() with complete=true to let the operation 36 // |write_operation|->DidWrite() with complete=true to let the operation
38 // perform the final cleanup. 37 // perform the final cleanup.
39 bool Cancel(); 38 bool Cancel();
40 39
41 base::PlatformFile file() const { return file_; }
42
43 virtual void OnReceivedRedirect(net::URLRequest* request, 40 virtual void OnReceivedRedirect(net::URLRequest* request,
44 const GURL& new_url, 41 const GURL& new_url,
45 bool* defer_redirect) OVERRIDE; 42 bool* defer_redirect) OVERRIDE;
46 virtual void OnAuthRequired(net::URLRequest* request, 43 virtual void OnAuthRequired(net::URLRequest* request,
47 net::AuthChallengeInfo* auth_info) OVERRIDE; 44 net::AuthChallengeInfo* auth_info) OVERRIDE;
48 virtual void OnCertificateRequested( 45 virtual void OnCertificateRequested(
49 net::URLRequest* request, 46 net::URLRequest* request,
50 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; 47 net::SSLCertRequestInfo* cert_request_info) OVERRIDE;
51 virtual void OnSSLCertificateError(net::URLRequest* request, 48 virtual void OnSSLCertificateError(net::URLRequest* request,
52 const net::SSLInfo& ssl_info, 49 const net::SSLInfo& ssl_info,
53 bool fatal) OVERRIDE; 50 bool fatal) OVERRIDE;
54 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; 51 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
55 virtual void OnReadCompleted(net::URLRequest* request, 52 virtual void OnReadCompleted(net::URLRequest* request,
56 int bytes_read) OVERRIDE; 53 int bytes_read) OVERRIDE;
57 54
58 private: 55 private:
59 void OnGetFileInfoAndStartRequest( 56 void OnGetFileInfoAndStartRequest(
60 scoped_ptr<net::URLRequest> request, 57 scoped_ptr<net::URLRequest> request,
61 base::PlatformFileError error, 58 base::PlatformFileError error,
62 const base::PlatformFileInfo& file_info); 59 const base::PlatformFileInfo& file_info);
63 void Read(); 60 void Read();
64 void OnDataReceived(int bytes_read); 61 void OnDataReceived(int bytes_read);
65 void Write(); 62 void Write();
66 void OnDataWritten(int write_response); 63 void OnDataWritten(int write_response);
67 void OnError(base::PlatformFileError error); 64 void OnError(base::PlatformFileError error);
68 void OnProgress(int bytes_read, bool done); 65 void OnProgress(int bytes_read, bool done);
66 void OnWriteCancelled(int status);
69 67
70 FileSystemOperationContext* file_system_operation_context() const;
71 FileSystemQuotaUtil* quota_util() const; 68 FileSystemQuotaUtil* quota_util() const;
72 69
73 FileSystemOperation* file_system_operation_; 70 FileSystemOperationInterface::WriteCallback write_callback_;
74 base::PlatformFile file_; 71 scoped_ptr<FileWriter> file_writer_;
75 FileSystemPath path_;
76 int64 size_;
77 int64 offset_;
78 bool has_pending_write_;
79 base::Time last_progress_event_time_; 72 base::Time last_progress_event_time_;
80 int bytes_written_backlog_; 73 int bytes_written_backlog_;
81 int bytes_written_; 74 int bytes_written_;
82 int bytes_read_; 75 int bytes_read_;
83 int64 total_bytes_written_;
84 int64 allowed_bytes_to_write_;
85 scoped_refptr<net::IOBufferWithSize> io_buffer_; 76 scoped_refptr<net::IOBufferWithSize> io_buffer_;
86 scoped_refptr<net::DrainableIOBuffer> cursor_; 77 scoped_refptr<net::DrainableIOBuffer> cursor_;
87 scoped_ptr<net::FileStream> file_stream_;
88 scoped_ptr<net::URLRequest> request_; 78 scoped_ptr<net::URLRequest> request_;
89 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; 79 base::WeakPtrFactory<FileWriterDelegate> weak_factory_;
90 }; 80 };
91 81
92 } // namespace fileapi 82 } // namespace fileapi
93 83
94 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_ 84 #endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_writer.h ('k') | webkit/fileapi/file_writer_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698