OLD | NEW |
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 CONTENT_RENDERER_PEPPER_QUOTA_FILE_IO_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_ | 6 #define CONTENT_RENDERER_PEPPER_QUOTA_FILE_IO_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 13 #include "content/common/content_export.h" |
13 #include "ppapi/c/pp_file_info.h" | 14 #include "ppapi/c/pp_file_info.h" |
14 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 #include "webkit/common/quota/quota_types.h" | 17 #include "webkit/common/quota/quota_types.h" |
17 #include "webkit/plugins/webkit_plugins_export.h" | |
18 | 18 |
19 namespace webkit { | 19 namespace webkit { |
20 namespace ppapi { | 20 namespace ppapi { |
21 | 21 |
22 class PluginDelegate; | 22 class PluginDelegate; |
23 | 23 |
24 // This class is created per PPB_FileIO_Impl instance and provides | 24 // This class is created per PPB_FileIO_Impl instance and provides |
25 // write operations for quota-managed files (i.e. files of | 25 // write operations for quota-managed files (i.e. files of |
26 // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}). | 26 // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}). |
27 class QuotaFileIO { | 27 class QuotaFileIO { |
28 public: | 28 public: |
29 typedef base::FileUtilProxy::WriteCallback WriteCallback; | 29 typedef base::FileUtilProxy::WriteCallback WriteCallback; |
30 typedef base::FileUtilProxy::StatusCallback StatusCallback; | 30 typedef base::FileUtilProxy::StatusCallback StatusCallback; |
31 | 31 |
32 WEBKIT_PLUGINS_EXPORT QuotaFileIO(PP_Instance instance, | 32 CONTENT_EXPORT QuotaFileIO(PP_Instance instance, |
33 base::PlatformFile file, | 33 base::PlatformFile file, |
34 const GURL& path_url, | 34 const GURL& path_url, |
35 PP_FileSystemType type); | 35 PP_FileSystemType type); |
36 WEBKIT_PLUGINS_EXPORT ~QuotaFileIO(); | 36 CONTENT_EXPORT ~QuotaFileIO(); |
37 | 37 |
38 // Performs write or setlength operation with quota checks. | 38 // Performs write or setlength operation with quota checks. |
39 // Returns true when the operation is successfully dispatched. | 39 // Returns true when the operation is successfully dispatched. |
40 // |bytes_to_write| must be geater than zero. | 40 // |bytes_to_write| must be geater than zero. |
41 // |callback| will be dispatched when the operation completes. | 41 // |callback| will be dispatched when the operation completes. |
42 // Otherwise it returns false and |callback| will not be dispatched. | 42 // Otherwise it returns false and |callback| will not be dispatched. |
43 // |callback| will not be dispatched either when this instance is | 43 // |callback| will not be dispatched either when this instance is |
44 // destroyed before the operation completes. | 44 // destroyed before the operation completes. |
45 // SetLength/WillSetLength cannot be called while there're any in-flight | 45 // SetLength/WillSetLength cannot be called while there're any in-flight |
46 // operations. For Write/WillWrite it is guaranteed that |callback| are | 46 // operations. For Write/WillWrite it is guaranteed that |callback| are |
47 // always dispatched in the same order as Write being called. | 47 // always dispatched in the same order as Write being called. |
48 WEBKIT_PLUGINS_EXPORT bool Write(int64_t offset, | 48 CONTENT_EXPORT bool Write(int64_t offset, |
49 const char* buffer, | 49 const char* buffer, |
50 int32_t bytes_to_write, | 50 int32_t bytes_to_write, |
51 const WriteCallback& callback); | 51 const WriteCallback& callback); |
52 WEBKIT_PLUGINS_EXPORT bool WillWrite(int64_t offset, | 52 CONTENT_EXPORT bool WillWrite(int64_t offset, |
53 int32_t bytes_to_write, | 53 int32_t bytes_to_write, |
54 const WriteCallback& callback); | 54 const WriteCallback& callback); |
55 | 55 |
56 WEBKIT_PLUGINS_EXPORT bool SetLength(int64_t length, | 56 CONTENT_EXPORT bool SetLength(int64_t length, |
57 const StatusCallback& callback); | 57 const StatusCallback& callback); |
58 WEBKIT_PLUGINS_EXPORT bool WillSetLength(int64_t length, | 58 CONTENT_EXPORT bool WillSetLength(int64_t length, |
59 const StatusCallback& callback); | 59 const StatusCallback& callback); |
60 | 60 |
61 // Returns the plugin delegate or NULL if the resource has outlived the | 61 // Returns the plugin delegate or NULL if the resource has outlived the |
62 // instance. | 62 // instance. |
63 PluginDelegate* GetPluginDelegate() const; | 63 PluginDelegate* GetPluginDelegate() const; |
64 | 64 |
65 private: | 65 private: |
66 class PendingOperationBase; | 66 class PendingOperationBase; |
67 class WriteOperation; | 67 class WriteOperation; |
68 class SetLengthOperation; | 68 class SetLengthOperation; |
69 | 69 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 int inflight_operations_; | 107 int inflight_operations_; |
108 | 108 |
109 base::WeakPtrFactory<QuotaFileIO> weak_factory_; | 109 base::WeakPtrFactory<QuotaFileIO> weak_factory_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO); | 111 DISALLOW_COPY_AND_ASSIGN(QuotaFileIO); |
112 }; | 112 }; |
113 | 113 |
114 } // namespace ppapi | 114 } // namespace ppapi |
115 } // namespace webkit | 115 } // namespace webkit |
116 | 116 |
117 #endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_ | 117 #endif // CONTENT_RENDERER_PEPPER_QUOTA_FILE_IO_H_ |
OLD | NEW |