| 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 | |
| 69 PP_FileHandle FileModuleLocal::OpenFile(const InstanceHandle& instance, | 43 PP_FileHandle FileModuleLocal::OpenFile(const InstanceHandle& instance, |
| 70 const std::string& path, | 44 const std::string& path, |
| 71 int32_t mode) { | 45 int32_t mode) { |
| 72 PP_FileHandle file_handle = PP_kInvalidFileHandle; | 46 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
| 73 int32_t result = PP_ERROR_FAILED; | 47 int32_t result = PP_ERROR_FAILED; |
| 74 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { | 48 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
| 75 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> | 49 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
| 76 OpenFile(instance.pp_instance(), path.c_str(), mode, &file_handle); | 50 OpenFile(instance.pp_instance(), path.c_str(), mode, &file_handle); |
| 77 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { | 51 } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) { |
| 78 result = get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> | 52 result = get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 146 } |
| 173 if (contents) { | 147 if (contents) { |
| 174 get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> | 148 get_interface<PPB_Flash_File_ModuleLocal_2_0>()-> |
| 175 FreeDirContents(instance.pp_instance(), contents); | 149 FreeDirContents(instance.pp_instance(), contents); |
| 176 } | 150 } |
| 177 } | 151 } |
| 178 return result == PP_OK; | 152 return result == PP_OK; |
| 179 } | 153 } |
| 180 | 154 |
| 181 // static | 155 // static |
| 182 bool FileModuleLocal::IsCreateTemporaryFileAvailable() { | |
| 183 return has_interface<PPB_Flash_File_ModuleLocal_3_0>(); | |
| 184 } | |
| 185 | |
| 186 // static | |
| 187 PP_FileHandle FileModuleLocal::CreateTemporaryFile( | 156 PP_FileHandle FileModuleLocal::CreateTemporaryFile( |
| 188 const InstanceHandle& instance) { | 157 const InstanceHandle& instance) { |
| 189 PP_FileHandle file_handle = PP_kInvalidFileHandle; | 158 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
| 190 int32_t result = PP_ERROR_FAILED; | 159 int32_t result = PP_ERROR_FAILED; |
| 191 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { | 160 if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) { |
| 192 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> | 161 result = get_interface<PPB_Flash_File_ModuleLocal_3_0>()-> |
| 193 CreateTemporaryFile(instance.pp_instance(), &file_handle); | 162 CreateTemporaryFile(instance.pp_instance(), &file_handle); |
| 194 } | 163 } |
| 195 return (result == PP_OK) ? file_handle : PP_kInvalidFileHandle; | 164 return (result == PP_OK) ? file_handle : PP_kInvalidFileHandle; |
| 196 } | 165 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (has_interface<PPB_Flash_File_FileRef>()) { | 202 if (has_interface<PPB_Flash_File_FileRef>()) { |
| 234 result = get_interface<PPB_Flash_File_FileRef>()-> | 203 result = get_interface<PPB_Flash_File_FileRef>()-> |
| 235 QueryFile(resource.pp_resource(), info); | 204 QueryFile(resource.pp_resource(), info); |
| 236 } | 205 } |
| 237 return result == PP_OK; | 206 return result == PP_OK; |
| 238 } | 207 } |
| 239 | 208 |
| 240 } // namespace flash | 209 } // namespace flash |
| 241 | 210 |
| 242 } // namespace pp | 211 } // namespace pp |
| OLD | NEW |