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 #include "ppapi/cpp/private/flash_file.h" | 5 #include "ppapi/cpp/private/flash_file.h" |
6 | 6 |
7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/cpp/file_ref.h" | 9 #include "ppapi/cpp/file_ref.h" |
10 #include "ppapi/cpp/instance_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 return rv; | 33 return rv; |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 bool FileModuleLocal::IsAvailable() { | 37 bool FileModuleLocal::IsAvailable() { |
38 return has_interface<PPB_Flash_File_ModuleLocal_3_0>() || | 38 return has_interface<PPB_Flash_File_ModuleLocal_3_0>() || |
39 has_interface<PPB_Flash_File_ModuleLocal_2_0>(); | 39 has_interface<PPB_Flash_File_ModuleLocal_2_0>(); |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
| 43 bool FileModuleLocal::CreateThreadAdapterForInstance( |
| 44 const InstanceHandle& instance) { |
| 45 bool rv = false; |
| 46 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
| 47 rv = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
| 48 CreateThreadAdapterForInstance(instance.pp_instance()); |
| 49 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { |
| 50 rv = get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
| 51 CreateThreadAdapterForInstance( instance.pp_instance()); |
| 52 } |
| 53 return rv; |
| 54 } |
| 55 |
| 56 // static |
| 57 void FileModuleLocal::ClearThreadAdapterForInstance( |
| 58 const InstanceHandle& instance) { |
| 59 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
| 60 get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
| 61 ClearThreadAdapterForInstance(instance.pp_instance()); |
| 62 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { |
| 63 get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
| 64 ClearThreadAdapterForInstance(instance.pp_instance()); |
| 65 } |
| 66 } |
| 67 |
| 68 // static |
43 PP_FileHandle FileModuleLocal::OpenFile(const InstanceHandle& instance, | 69 PP_FileHandle FileModuleLocal::OpenFile(const InstanceHandle& instance, |
44 const std::string& path, | 70 const std::string& path, |
45 int32_t mode) { | 71 int32_t mode) { |
46 PP_FileHandle file_handle = PP_kInvalidFileHandle; | 72 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
47 int32_t result = PP_ERROR_FAILED; | 73 int32_t result = PP_ERROR_FAILED; |
48 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { | 74 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
49 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> | 75 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
50 OpenFile(instance.pp_instance(), path.c_str(), mode, &file_handle); | 76 OpenFile(instance.pp_instance(), path.c_str(), mode, &file_handle); |
51 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { | 77 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { |
52 result = get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> | 78 result = get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 172 } |
147 if (contents) { | 173 if (contents) { |
148 get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> | 174 get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
149 FreeDirContents(instance.pp_instance(), contents); | 175 FreeDirContents(instance.pp_instance(), contents); |
150 } | 176 } |
151 } | 177 } |
152 return result == PP_OK; | 178 return result == PP_OK; |
153 } | 179 } |
154 | 180 |
155 // static | 181 // static |
| 182 bool FileModuleLocal::IsCreateTemporaryFileAvailable() { |
| 183 return has_interface<PPB_Flash_File_ModuleLocal_3_0>(); |
| 184 } |
| 185 |
| 186 // static |
156 PP_FileHandle FileModuleLocal::CreateTemporaryFile( | 187 PP_FileHandle FileModuleLocal::CreateTemporaryFile( |
157 const InstanceHandle& instance) { | 188 const InstanceHandle& instance) { |
158 PP_FileHandle file_handle = PP_kInvalidFileHandle; | 189 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
159 int32_t result = PP_ERROR_FAILED; | 190 int32_t result = PP_ERROR_FAILED; |
160 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { | 191 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
161 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> | 192 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
162 CreateTemporaryFile(instance.pp_instance(), &file_handle); | 193 CreateTemporaryFile(instance.pp_instance(), &file_handle); |
163 } | 194 } |
164 return (result == PP_OK) ? file_handle : PP_kInvalidFileHandle; | 195 return (result == PP_OK) ? file_handle : PP_kInvalidFileHandle; |
165 } | 196 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (has_interface<PPB_Flash_File_FileRef>()) { | 233 if (has_interface<PPB_Flash_File_FileRef>()) { |
203 result = get_interface<PPB_Flash_File_FileRef>()-> | 234 result = get_interface<PPB_Flash_File_FileRef>()-> |
204 QueryFile(resource.pp_resource(), info); | 235 QueryFile(resource.pp_resource(), info); |
205 } | 236 } |
206 return result == PP_OK; | 237 return result == PP_OK; |
207 } | 238 } |
208 | 239 |
209 } // namespace flash | 240 } // namespace flash |
210 | 241 |
211 } // namespace pp | 242 } // namespace pp |
OLD | NEW |