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