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

Side by Side Diff: webkit/plugins/ppapi/quota_file_io.h

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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) 2011 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_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
6 #define WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
7
8 #include <deque>
9
10 #include "base/file_util_proxy.h"
11 #include "base/memory/scoped_callback_factory.h"
12 #include "base/platform_file.h"
13 #include "googleurl/src/gurl.h"
14 #include "ppapi/c/pp_file_info.h"
15 #include "webkit/quota/quota_types.h"
16
17 namespace webkit {
18 namespace ppapi {
19
20 class PluginInstance;
21
22 // This class is created per PPB_FileIO_Impl instance and provides
23 // write operations for quota-managed files (i.e. files of
24 // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}).
25 class QuotaFileIO {
26 public:
27 typedef base::FileUtilProxy::WriteCallback WriteCallback;
28 typedef base::FileUtilProxy::StatusCallback StatusCallback;
29
30 QuotaFileIO(PluginInstance* instance,
31 base::PlatformFile file,
32 const GURL& path_url,
33 PP_FileSystemType type);
34 ~QuotaFileIO();
35
36 // Performs write or setlength operation with quota checks.
37 // Returns true and when the operation is successfully dispatched.
yzshen1 2011/07/28 17:40:52 nit: remove 'and'?
kinuko 2011/07/29 08:39:51 Done.
38 // |callback| will be dispatched when the operation completes.
39 // Otherwise it returns false and |callback| will not be dispatched.
40 // |callback| will not be dispatched either when this instance is
41 // destroyed before the operation completes.
42 // |callback| are always dispatched in order.
yzshen1 2011/07/28 17:40:52 nit: Please be more clear about "in order" in the
kinuko 2011/07/29 08:39:51 Done.
43 bool Write(int64_t offset,
44 const char* buffer,
45 int32_t bytes_to_write,
46 WriteCallback* callback);
47 bool SetLength(int64_t length, StatusCallback* callback);
48 bool WillWrite(int64_t offset,
49 int32_t bytes_to_write,
50 WriteCallback* callback);
51 bool WillSetLength(int64_t length, StatusCallback* callback);
52
53 private:
54 class PendingOperationBase;
55 class WriteOperation;
56 class SetLengthOperation;
57
58 bool CheckIfExceedsQuota(int64_t new_file_size) const;
59 void WillUpdate();
60 void DidWrite(WriteOperation* op, int64_t written_offset_end);
61 void DidSetLength(base::PlatformFileError error, int64_t new_file_size);
62
63 bool RegisterOperationForQuotaChecks(PendingOperationBase* op);
64 void DidQueryInfoForQuota(base::PlatformFileError error_code,
65 const base::PlatformFileInfo& file_info);
66 void DidQueryAvailableSpace(int64_t avail_space);
67 void DidQueryForQuotaCheck();
68
69 // The plugin instance that owns this (via PPB_FileIO_Impl).
70 PluginInstance* instance_;
71
72 // The file information associated to this instance.
73 base::PlatformFile file_;
74 GURL file_url_;
75 quota::StorageType storage_type_;
76
77 // Operations waiting for a quota check to finish.
78 std::deque<PendingOperationBase*> pending_operations_;
79
80 // Valid only while there're pending quota checks.
81 int64_t cached_file_size_;
82 int64_t cached_available_space_;
83
84 // Quota-related queries and errors occured during inflight quota checks.
85 int outstanding_quota_queries_;
86 int outstanding_errors_;
87
88 // For parallel writes bookkeeping.
89 int64_t max_written_offset_;
90 int inflight_operations_;
91
92 base::ScopedCallbackFactory<QuotaFileIO> callback_factory_;
93 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO);
94 };
95
96 } // namespace ppapi
97 } // namespace webkit
98
99 #endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698