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 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ppapi/c/pp_file_info.h" | 11 #include "ppapi/c/pp_file_info.h" |
12 #include "ppapi/c/ppb_file_io.h" | 12 #include "ppapi/c/ppb_file_io.h" |
13 #include "ppapi/c/private/ppb_flash_file.h" | 13 #include "ppapi/c/private/ppb_flash_file.h" |
14 #include "ppapi/shared_impl/time_conversion.h" | 14 #include "ppapi/shared_impl/time_conversion.h" |
15 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
16 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
17 #include "webkit/plugins/ppapi/file_path.h" | 17 #include "webkit/plugins/ppapi/file_path.h" |
18 #include "webkit/plugins/ppapi/file_type_conversions.h" | 18 #include "webkit/plugins/ppapi/file_type_conversions.h" |
19 #include "webkit/plugins/ppapi/plugin_delegate.h" | 19 #include "webkit/plugins/ppapi/plugin_delegate.h" |
20 #include "webkit/plugins/ppapi/plugin_module.h" | 20 #include "webkit/plugins/ppapi/plugin_module.h" |
21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
22 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 22 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 23 #include "webkit/plugins/ppapi/resource_helper.h" |
23 #include "webkit/plugins/ppapi/resource_tracker.h" | 24 #include "webkit/plugins/ppapi/resource_tracker.h" |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
26 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
27 #endif | 28 #endif |
28 | 29 |
29 using ppapi::thunk::EnterResource; | 30 using ppapi::thunk::EnterResource; |
30 using ppapi::thunk::PPB_FileRef_API; | 31 using ppapi::thunk::PPB_FileRef_API; |
31 using ppapi::TimeToPPTime; | 32 using ppapi::TimeToPPTime; |
32 | 33 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 PP_FileHandle* file) { | 219 PP_FileHandle* file) { |
219 int flags = 0; | 220 int flags = 0; |
220 if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) | 221 if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) |
221 return PP_ERROR_BADARGUMENT; | 222 return PP_ERROR_BADARGUMENT; |
222 | 223 |
223 EnterResource<PPB_FileRef_API> enter(file_ref_id, true); | 224 EnterResource<PPB_FileRef_API> enter(file_ref_id, true); |
224 if (enter.failed()) | 225 if (enter.failed()) |
225 return PP_ERROR_BADRESOURCE; | 226 return PP_ERROR_BADRESOURCE; |
226 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); | 227 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); |
227 | 228 |
228 PluginInstance* instance = file_ref->instance(); | 229 PluginInstance* instance = ResourceHelper::GetPluginInstance(file_ref); |
229 if (!instance) | 230 if (!instance) |
230 return PP_ERROR_FAILED; | 231 return PP_ERROR_FAILED; |
231 | 232 |
232 base::PlatformFile base_file; | 233 base::PlatformFile base_file; |
233 base::PlatformFileError result = instance->delegate()->OpenFile( | 234 base::PlatformFileError result = instance->delegate()->OpenFile( |
234 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), | 235 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), |
235 flags, | 236 flags, |
236 &base_file); | 237 &base_file); |
237 *file = base_file; | 238 *file = base_file; |
238 return PlatformFileErrorToPepperError(result); | 239 return PlatformFileErrorToPepperError(result); |
239 } | 240 } |
240 | 241 |
241 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 242 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
242 PP_FileInfo* info) { | 243 PP_FileInfo* info) { |
243 EnterResource<PPB_FileRef_API> enter(file_ref_id, true); | 244 EnterResource<PPB_FileRef_API> enter(file_ref_id, true); |
244 if (enter.failed()) | 245 if (enter.failed()) |
245 return PP_ERROR_BADRESOURCE; | 246 return PP_ERROR_BADRESOURCE; |
246 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); | 247 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); |
247 | 248 |
248 PluginInstance* instance = file_ref->instance(); | 249 PluginInstance* instance = ResourceHelper::GetPluginInstance(file_ref); |
249 if (!instance) | 250 if (!instance) |
250 return PP_ERROR_FAILED; | 251 return PP_ERROR_FAILED; |
251 | 252 |
252 base::PlatformFileInfo file_info; | 253 base::PlatformFileInfo file_info; |
253 base::PlatformFileError result = instance->delegate()->QueryFile( | 254 base::PlatformFileError result = instance->delegate()->QueryFile( |
254 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), | 255 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), |
255 &file_info); | 256 &file_info); |
256 if (result == base::PLATFORM_FILE_OK) { | 257 if (result == base::PLATFORM_FILE_OK) { |
257 info->size = file_info.size; | 258 info->size = file_info.size; |
258 info->creation_time = TimeToPPTime(file_info.creation_time); | 259 info->creation_time = TimeToPPTime(file_info.creation_time); |
(...skipping 15 matching lines...) Expand all Loading... |
274 | 275 |
275 } // namespace | 276 } // namespace |
276 | 277 |
277 // static | 278 // static |
278 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() { | 279 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() { |
279 return &ppb_flash_file_fileref; | 280 return &ppb_flash_file_fileref; |
280 } | 281 } |
281 | 282 |
282 } // namespace ppapi | 283 } // namespace ppapi |
283 } // namespace webkit | 284 } // namespace webkit |
OLD | NEW |