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 |
27 // Returns |PP_kInvalidFileHandle| on error. | 30 // Returns |PP_kInvalidFileHandle| on error. |
28 static PP_FileHandle OpenFile(const InstanceHandle& instance, | 31 static PP_FileHandle OpenFile(const InstanceHandle& instance, |
29 const std::string& path, | 32 const std::string& path, |
30 int32_t mode); | 33 int32_t mode); |
31 static bool RenameFile(const InstanceHandle& instance, | 34 static bool RenameFile(const InstanceHandle& instance, |
32 const std::string& path_from, | 35 const std::string& path_from, |
33 const std::string& path_to); | 36 const std::string& path_to); |
34 static bool DeleteFileOrDir(const InstanceHandle& instance, | 37 static bool DeleteFileOrDir(const InstanceHandle& instance, |
35 const std::string& path, | 38 const std::string& path, |
36 bool recursive); | 39 bool recursive); |
37 static bool CreateDir(const InstanceHandle& instance, | 40 static bool CreateDir(const InstanceHandle& instance, |
38 const std::string& path); | 41 const std::string& path); |
39 static bool QueryFile(const InstanceHandle& instance, | 42 static bool QueryFile(const InstanceHandle& instance, |
40 const std::string& path, | 43 const std::string& path, |
41 PP_FileInfo* info); | 44 PP_FileInfo* info); |
42 // Note that, unlike the C interface, no |FreeDirContents()| is needed. | 45 // Note that, unlike the C interface, no |FreeDirContents()| is needed. |
43 struct DirEntry { | 46 struct DirEntry { |
44 std::string name; | 47 std::string name; |
45 bool is_dir; | 48 bool is_dir; |
46 }; | 49 }; |
47 static bool GetDirContents(const InstanceHandle& instance, | 50 static bool GetDirContents(const InstanceHandle& instance, |
48 const std::string& path, | 51 const std::string& path, |
49 std::vector<DirEntry>* dir_contents); | 52 std::vector<DirEntry>* dir_contents); |
50 | 53 |
| 54 // Returns true if |CreateTemporaryFile()| is supported. |
| 55 // TODO(viettrungluu): Remove this sometime after M21 ships to Stable? |
| 56 static bool IsCreateTemporaryFileAvailable(); |
51 // Returns |PP_kInvalidFileHandle| on error. | 57 // Returns |PP_kInvalidFileHandle| on error. |
52 static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance); | 58 static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance); |
53 }; | 59 }; |
54 | 60 |
55 // FileFileRef ----------------------------------------------------------------- | 61 // FileFileRef ----------------------------------------------------------------- |
56 | 62 |
57 class FileFileRef { | 63 class FileFileRef { |
58 public: | 64 public: |
59 // Returns true if the required interface is available. | 65 // Returns true if the required interface is available. |
60 static bool IsAvailable(); | 66 static bool IsAvailable(); |
61 | 67 |
62 // Returns |PP_kInvalidFileHandle| on error. | 68 // Returns |PP_kInvalidFileHandle| on error. |
63 static PP_FileHandle OpenFile(const pp::FileRef& resource, | 69 static PP_FileHandle OpenFile(const pp::FileRef& resource, |
64 int32_t mode); | 70 int32_t mode); |
65 static bool QueryFile(const pp::FileRef& resource, | 71 static bool QueryFile(const pp::FileRef& resource, |
66 PP_FileInfo* info); | 72 PP_FileInfo* info); |
67 }; | 73 }; |
68 | 74 |
69 } // namespace flash | 75 } // namespace flash |
70 } // namespace pp | 76 } // namespace pp |
71 | 77 |
72 #endif // PPAPI_CPP_PRIVATE_FLASH_FILE_H_ | 78 #endif // PPAPI_CPP_PRIVATE_FLASH_FILE_H_ |
OLD | NEW |