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

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: fix 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 bool Write(int64_t offset,
yzshen1 2011/07/27 18:26:08 1) Please comment that if returns false the callba
kinuko 2011/07/28 14:11:00 Done.
37 const char* buffer,
38 int32_t bytes_to_write,
39 WriteCallback* callback);
40 bool SetLength(int64_t length, StatusCallback* callback);
41 bool WillWrite(int64_t offset,
42 int32_t bytes_to_write,
43 WriteCallback* callback);
44 bool WillSetLength(int64_t length, StatusCallback* callback);
45
46 private:
47 class PendingOperationBase;
48 class WriteOperation;
49 class SetLengthOperation;
50
51 bool CheckIfExceedsQuota(int64_t new_file_size) const;
52 void WillUpdate();
53 void DidWrite(WriteOperation* op, int64_t written_offset_end);
54 void DidSetLength(base::PlatformFileError error, int64_t new_file_size);
55
56 bool RegisterOperationForQuotaChecks(PendingOperationBase* op);
57 void DidQueryInfoForQuota(base::PlatformFileError error_code,
58 const base::PlatformFileInfo& file_info);
59 void DidQueryAvailableSpace(int64_t avail_space);
60 void DidQueryForQuotaCheck();
61
62 // The plugin instance that owns this (via PPB_FileIO_Impl).
63 PluginInstance* instance_;
64
65 // The file information associated to this instance.
66 base::PlatformFile file_;
67 GURL file_url_;
68 quota::StorageType storage_type_;
69
70 // Operations waiting for a quota check to finish.
71 std::deque<PendingOperationBase*> pending_operations_;
yzshen1 2011/07/27 18:26:08 All you use are *queue* operations. Why to change
kinuko 2011/07/28 14:11:00 I wanted to use methods like size(), begin() and e
yzshen1 2011/07/28 17:40:52 Okay. :) On 2011/07/28 14:11:00, kinuko wrote:
72
73 // Operations queued to dispatch the callbacks.
74 std::deque<PendingOperationBase*> pending_callbacks_;
yzshen1 2011/07/27 18:26:08 It seems to me that you don't need two queues: you
kinuko 2011/07/28 14:11:00 That looks true. Removed.
75
76 // Valid only while there're pending quota checks.
77 int64_t cached_file_size_;
78 int64_t cached_available_space_;
79
80 // Quota-related queries and errors occured during inflight quota checks.
81 int outstanding_quota_queries_;
82 int outstanding_errors_;
83
84 // For parallel writes bookkeeping.
85 int64_t max_written_offset_;
86 int inflight_operations_;
87
88 base::ScopedCallbackFactory<QuotaFileIO> callback_factory_;
89 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO);
90 };
91
92 } // namespace ppapi
93 } // namespace webkit
94
95 #endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698