| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PPAPI_CPP_PRIVATE_FLASH_FILE_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_FLASH_FILE_H_ |
| 6 #define PPAPI_CPP_PRIVATE_FLASH_FILE_H_ | 6 #define PPAPI_CPP_PRIVATE_FLASH_FILE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ppapi/c/private/ppb_flash_file.h" | 11 #include "ppapi/c/private/ppb_flash_file.h" |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 class FileRef; | 15 class FileRef; |
| 16 class InstanceHandle; | 16 class InstanceHandle; |
| 17 | 17 |
| 18 namespace flash { | 18 namespace flash { |
| 19 | 19 |
| 20 // FileModuleLocal ------------------------------------------------------------- | 20 // FileModuleLocal ------------------------------------------------------------- |
| 21 | 21 |
| 22 class FileModuleLocal { | 22 class FileModuleLocal { |
| 23 public: | 23 public: |
| 24 // Returns true if the required interface is available. | 24 // Returns true if the required interface is available. |
| 25 static bool IsAvailable(); | 25 static bool IsAvailable(); |
| 26 | 26 |
| 27 static bool CreateThreadAdapterForInstance(const InstanceHandle& instance); | |
| 28 static void ClearThreadAdapterForInstance(const InstanceHandle& instance); | |
| 29 | |
| 30 // Returns |PP_kInvalidFileHandle| on error. | 27 // Returns |PP_kInvalidFileHandle| on error. |
| 31 static PP_FileHandle OpenFile(const InstanceHandle& instance, | 28 static PP_FileHandle OpenFile(const InstanceHandle& instance, |
| 32 const std::string& path, | 29 const std::string& path, |
| 33 int32_t mode); | 30 int32_t mode); |
| 34 static bool RenameFile(const InstanceHandle& instance, | 31 static bool RenameFile(const InstanceHandle& instance, |
| 35 const std::string& path_from, | 32 const std::string& path_from, |
| 36 const std::string& path_to); | 33 const std::string& path_to); |
| 37 static bool DeleteFileOrDir(const InstanceHandle& instance, | 34 static bool DeleteFileOrDir(const InstanceHandle& instance, |
| 38 const std::string& path, | 35 const std::string& path, |
| 39 bool recursive); | 36 bool recursive); |
| 40 static bool CreateDir(const InstanceHandle& instance, | 37 static bool CreateDir(const InstanceHandle& instance, |
| 41 const std::string& path); | 38 const std::string& path); |
| 42 static bool QueryFile(const InstanceHandle& instance, | 39 static bool QueryFile(const InstanceHandle& instance, |
| 43 const std::string& path, | 40 const std::string& path, |
| 44 PP_FileInfo* info); | 41 PP_FileInfo* info); |
| 45 // Note that, unlike the C interface, no |FreeDirContents()| is needed. | 42 // Note that, unlike the C interface, no |FreeDirContents()| is needed. |
| 46 struct DirEntry { | 43 struct DirEntry { |
| 47 std::string name; | 44 std::string name; |
| 48 bool is_dir; | 45 bool is_dir; |
| 49 }; | 46 }; |
| 50 static bool GetDirContents(const InstanceHandle& instance, | 47 static bool GetDirContents(const InstanceHandle& instance, |
| 51 const std::string& path, | 48 const std::string& path, |
| 52 std::vector<DirEntry>* dir_contents); | 49 std::vector<DirEntry>* dir_contents); |
| 53 | 50 |
| 54 // Returns true if |CreateTemporaryFile()| is supported. | |
| 55 // TODO(viettrungluu): Remove this sometime after M21 ships to Stable? | |
| 56 static bool IsCreateTemporaryFileAvailable(); | |
| 57 // Returns |PP_kInvalidFileHandle| on error. | 51 // Returns |PP_kInvalidFileHandle| on error. |
| 58 static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance); | 52 static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance); |
| 59 }; | 53 }; |
| 60 | 54 |
| 61 // FileFileRef ----------------------------------------------------------------- | 55 // FileFileRef ----------------------------------------------------------------- |
| 62 | 56 |
| 63 class FileFileRef { | 57 class FileFileRef { |
| 64 public: | 58 public: |
| 65 // Returns true if the required interface is available. | 59 // Returns true if the required interface is available. |
| 66 static bool IsAvailable(); | 60 static bool IsAvailable(); |
| 67 | 61 |
| 68 // Returns |PP_kInvalidFileHandle| on error. | 62 // Returns |PP_kInvalidFileHandle| on error. |
| 69 static PP_FileHandle OpenFile(const pp::FileRef& resource, | 63 static PP_FileHandle OpenFile(const pp::FileRef& resource, |
| 70 int32_t mode); | 64 int32_t mode); |
| 71 static bool QueryFile(const pp::FileRef& resource, | 65 static bool QueryFile(const pp::FileRef& resource, |
| 72 PP_FileInfo* info); | 66 PP_FileInfo* info); |
| 73 }; | 67 }; |
| 74 | 68 |
| 75 } // namespace flash | 69 } // namespace flash |
| 76 } // namespace pp | 70 } // namespace pp |
| 77 | 71 |
| 78 #endif // PPAPI_CPP_PRIVATE_FLASH_FILE_H_ | 72 #endif // PPAPI_CPP_PRIVATE_FLASH_FILE_H_ |
| OLD | NEW |