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

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

Issue 15442002: Move FileAPI sandboxed filesystem related code from webkit/fileapi to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_SANDBOX_FILE_STREAM_WRITER_H_
6 #define WEBKIT_FILEAPI_SANDBOX_FILE_STREAM_WRITER_H_
7
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/platform_file.h"
11 #include "googleurl/src/gurl.h"
12 #include "webkit/fileapi/file_stream_writer.h"
13 #include "webkit/fileapi/file_system_types.h"
14 #include "webkit/fileapi/file_system_url.h"
15 #include "webkit/fileapi/task_runner_bound_observer_list.h"
16 #include "webkit/quota/quota_types.h"
17 #include "webkit/storage/webkit_storage_export.h"
18
19 namespace fileapi {
20
21 class FileSystemContext;
22 class FileSystemQuotaUtil;
23 class LocalFileStreamWriter;
24
25 class WEBKIT_STORAGE_EXPORT_PRIVATE SandboxFileStreamWriter
26 : public FileStreamWriter {
27 public:
28 SandboxFileStreamWriter(FileSystemContext* file_system_context,
29 const FileSystemURL& url,
30 int64 initial_offset,
31 const UpdateObserverList& observers);
32 virtual ~SandboxFileStreamWriter();
33
34 // FileStreamWriter overrides.
35 virtual int Write(net::IOBuffer* buf, int buf_len,
36 const net::CompletionCallback& callback) OVERRIDE;
37 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE;
38 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE;
39
40 // Used only by tests.
41 void set_default_quota(int64 quota) {
42 default_quota_ = quota;
43 }
44
45 private:
46 // Performs quota calculation and calls local_file_writer_->Write().
47 int WriteInternal(net::IOBuffer* buf, int buf_len,
48 const net::CompletionCallback& callback);
49
50 // Callbacks that are chained for the first write. This eventually calls
51 // WriteInternal.
52 void DidGetFileInfo(const net::CompletionCallback& callback,
53 base::PlatformFileError file_error,
54 const base::PlatformFileInfo& file_info,
55 const base::FilePath& platform_path);
56 void DidGetUsageAndQuota(const net::CompletionCallback& callback,
57 quota::QuotaStatusCode status,
58 int64 usage, int64 quota);
59 void DidInitializeForWrite(net::IOBuffer* buf, int buf_len,
60 const net::CompletionCallback& callback,
61 int init_status);
62
63 void DidWrite(const net::CompletionCallback& callback, int write_response);
64
65 // Stops the in-flight operation, calls |cancel_callback_| and returns true
66 // if there's a pending cancel request.
67 bool CancelIfRequested();
68
69 scoped_refptr<FileSystemContext> file_system_context_;
70 FileSystemURL url_;
71 int64 initial_offset_;
72 scoped_ptr<LocalFileStreamWriter> local_file_writer_;
73 net::CompletionCallback cancel_callback_;
74
75 UpdateObserverList observers_;
76
77 base::FilePath file_path_;
78 int64 file_size_;
79 int64 total_bytes_written_;
80 int64 allowed_bytes_to_write_;
81 bool has_pending_operation_;
82
83 int64 default_quota_;
84
85 base::WeakPtrFactory<SandboxFileStreamWriter> weak_factory_;
86
87 DISALLOW_COPY_AND_ASSIGN(SandboxFileStreamWriter);
88 };
89
90 } // namespace fileapi
91
92 #endif // WEBKIT_FILEAPI_SANDBOX_FILE_STREAM_WRITER_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_directory_database_unittest.cc ('k') | webkit/fileapi/sandbox_file_stream_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698