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

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

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nulls auditeed 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_widget_impl.cc ('k') | webkit/plugins/ppapi/quota_file_io.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) 2011 The Chromium Authors. All rights reserved. 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 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_PLUGINS_PPAPI_QUOTA_FILE_IO_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
6 #define WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_ 6 #define WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/file_util_proxy.h" 10 #include "base/file_util_proxy.h"
11 #include "base/memory/scoped_callback_factory.h" 11 #include "base/memory/scoped_callback_factory.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "ppapi/c/pp_file_info.h" 14 #include "ppapi/c/pp_file_info.h"
15 #include "ppapi/c/pp_instance.h"
15 #include "webkit/quota/quota_types.h" 16 #include "webkit/quota/quota_types.h"
16 17
17 namespace webkit { 18 namespace webkit {
18 namespace ppapi { 19 namespace ppapi {
19 20
20 class PluginInstance; 21 class PluginDelegate;
21 22
22 // This class is created per PPB_FileIO_Impl instance and provides 23 // This class is created per PPB_FileIO_Impl instance and provides
23 // write operations for quota-managed files (i.e. files of 24 // write operations for quota-managed files (i.e. files of
24 // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}). 25 // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}).
25 class QuotaFileIO { 26 class QuotaFileIO {
26 public: 27 public:
27 typedef base::FileUtilProxy::WriteCallback WriteCallback; 28 typedef base::FileUtilProxy::WriteCallback WriteCallback;
28 typedef base::FileUtilProxy::StatusCallback StatusCallback; 29 typedef base::FileUtilProxy::StatusCallback StatusCallback;
29 30
30 QuotaFileIO(PluginInstance* instance, 31 QuotaFileIO(PP_Instance instance,
31 base::PlatformFile file, 32 base::PlatformFile file,
32 const GURL& path_url, 33 const GURL& path_url,
33 PP_FileSystemType type); 34 PP_FileSystemType type);
34 ~QuotaFileIO(); 35 ~QuotaFileIO();
35 36
36 // Performs write or setlength operation with quota checks. 37 // Performs write or setlength operation with quota checks.
37 // Returns true when the operation is successfully dispatched. 38 // Returns true when the operation is successfully dispatched.
38 // |bytes_to_write| must be geater than zero. 39 // |bytes_to_write| must be geater than zero.
39 // |callback| will be dispatched when the operation completes. 40 // |callback| will be dispatched when the operation completes.
40 // Otherwise it returns false and |callback| will not be dispatched. 41 // Otherwise it returns false and |callback| will not be dispatched.
41 // |callback| will not be dispatched either when this instance is 42 // |callback| will not be dispatched either when this instance is
42 // destroyed before the operation completes. 43 // destroyed before the operation completes.
43 // SetLength/WillSetLength cannot be called while there're any inflight 44 // SetLength/WillSetLength cannot be called while there're any inflight
44 // operations. For Write/WillWrite it is guaranteed that |callback| are 45 // operations. For Write/WillWrite it is guaranteed that |callback| are
45 // always dispatched in the same order as Write being called. 46 // always dispatched in the same order as Write being called.
46 bool Write(int64_t offset, 47 bool Write(int64_t offset,
47 const char* buffer, 48 const char* buffer,
48 int32_t bytes_to_write, 49 int32_t bytes_to_write,
49 WriteCallback* callback); 50 WriteCallback* callback);
50 bool WillWrite(int64_t offset, 51 bool WillWrite(int64_t offset,
51 int32_t bytes_to_write, 52 int32_t bytes_to_write,
52 WriteCallback* callback); 53 WriteCallback* callback);
53 54
54 bool SetLength(int64_t length, StatusCallback* callback); 55 bool SetLength(int64_t length, StatusCallback* callback);
55 bool WillSetLength(int64_t length, StatusCallback* callback); 56 bool WillSetLength(int64_t length, StatusCallback* callback);
56 57
58 // Returns the plugin delegate or NULL if the resource has outlived the
59 // instance.
60 PluginDelegate* GetPluginDelegate() const;
61
57 private: 62 private:
58 class PendingOperationBase; 63 class PendingOperationBase;
59 class WriteOperation; 64 class WriteOperation;
60 class SetLengthOperation; 65 class SetLengthOperation;
61 66
62 bool CheckIfExceedsQuota(int64_t new_file_size) const; 67 bool CheckIfExceedsQuota(int64_t new_file_size) const;
63 void WillUpdate(); 68 void WillUpdate();
64 void DidWrite(WriteOperation* op, int64_t written_offset_end); 69 void DidWrite(WriteOperation* op, int64_t written_offset_end);
65 void DidSetLength(base::PlatformFileError error, int64_t new_file_size); 70 void DidSetLength(base::PlatformFileError error, int64_t new_file_size);
66 71
67 bool RegisterOperationForQuotaChecks(PendingOperationBase* op); 72 bool RegisterOperationForQuotaChecks(PendingOperationBase* op);
68 void DidQueryInfoForQuota(base::PlatformFileError error_code, 73 void DidQueryInfoForQuota(base::PlatformFileError error_code,
69 const base::PlatformFileInfo& file_info); 74 const base::PlatformFileInfo& file_info);
70 void DidQueryAvailableSpace(int64_t avail_space); 75 void DidQueryAvailableSpace(int64_t avail_space);
71 void DidQueryForQuotaCheck(); 76 void DidQueryForQuotaCheck();
72 77
73 // The plugin instance that owns this (via PPB_FileIO_Impl). 78 // The plugin instance that owns this (via PPB_FileIO_Impl).
74 PluginInstance* instance_; 79 PP_Instance pp_instance_;
75 80
76 // The file information associated to this instance. 81 // The file information associated to this instance.
77 base::PlatformFile file_; 82 base::PlatformFile file_;
78 GURL file_url_; 83 GURL file_url_;
79 quota::StorageType storage_type_; 84 quota::StorageType storage_type_;
80 85
81 // Pending operations that are waiting quota checks and pending 86 // Pending operations that are waiting quota checks and pending
82 // callbacks that are to be fired after the operation; 87 // callbacks that are to be fired after the operation;
83 // we use two separate queues for them so that we can safely dequeue the 88 // we use two separate queues for them so that we can safely dequeue the
84 // pending callbacks while enqueueing new operations. (This could 89 // pending callbacks while enqueueing new operations. (This could
(...skipping 14 matching lines...) Expand all
99 int inflight_operations_; 104 int inflight_operations_;
100 105
101 base::ScopedCallbackFactory<QuotaFileIO> callback_factory_; 106 base::ScopedCallbackFactory<QuotaFileIO> callback_factory_;
102 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO); 107 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO);
103 }; 108 };
104 109
105 } // namespace ppapi 110 } // namespace ppapi
106 } // namespace webkit 111 } // namespace webkit
107 112
108 #endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_ 113 #endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_widget_impl.cc ('k') | webkit/plugins/ppapi/quota_file_io.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698