| 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 "content/renderer/pepper/ppb_file_ref_impl.h" | 5 #include "content/renderer/pepper/ppb_file_ref_impl.h" | 
| 6 | 6 | 
| 7 #include "base/files/file_util_proxy.h" | 7 #include "base/files/file_util_proxy.h" | 
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" | 
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" | 
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" | 
| 11 #include "content/child/fileapi/file_system_dispatcher.h" | 11 #include "content/child/fileapi/file_system_dispatcher.h" | 
| 12 #include "content/renderer/pepper/common.h" | 12 #include "content/renderer/pepper/common.h" | 
| 13 #include "content/renderer/pepper/pepper_file_system_host.h" | 13 #include "content/renderer/pepper/pepper_file_system_host.h" | 
| 14 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 14 #include "content/renderer/pepper/pepper_helper_impl.h" | 
| 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 
| 16 #include "content/renderer/pepper/plugin_module.h" | 16 #include "content/renderer/pepper/plugin_module.h" | 
| 17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 
| 18 #include "content/renderer/pepper/resource_helper.h" | 18 #include "content/renderer/pepper/resource_helper.h" | 
| 19 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" | 
| 20 #include "net/base/escape.h" | 20 #include "net/base/escape.h" | 
| 21 #include "ppapi/c/pp_errors.h" | 21 #include "ppapi/c/pp_errors.h" | 
| 22 #include "ppapi/host/ppapi_host.h" | 22 #include "ppapi/host/ppapi_host.h" | 
| 23 #include "ppapi/shared_impl/file_type_conversion.h" | 23 #include "ppapi/shared_impl/file_type_conversion.h" | 
| 24 #include "ppapi/shared_impl/time_conversion.h" | 24 #include "ppapi/shared_impl/time_conversion.h" | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 231 | 231 | 
| 232 PPB_FileRef_Impl::~PPB_FileRef_Impl() { | 232 PPB_FileRef_Impl::~PPB_FileRef_Impl() { | 
| 233 } | 233 } | 
| 234 | 234 | 
| 235 // static | 235 // static | 
| 236 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, | 236 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, | 
| 237                                                    PP_Resource pp_file_system, | 237                                                    PP_Resource pp_file_system, | 
| 238                                                    const std::string& path) { | 238                                                    const std::string& path) { | 
| 239   PepperPluginInstanceImpl* plugin_instance = | 239   PepperPluginInstanceImpl* plugin_instance = | 
| 240       ResourceHelper::PPInstanceToPluginInstance(instance); | 240       ResourceHelper::PPInstanceToPluginInstance(instance); | 
| 241   if (!plugin_instance || !plugin_instance->delegate()) | 241   if (!plugin_instance || !plugin_instance->helper()) | 
| 242     return 0; | 242     return 0; | 
| 243 | 243 | 
| 244   ppapi::host::ResourceHost* host = GetResourceHostInternal( | 244   ppapi::host::ResourceHost* host = GetResourceHostInternal( | 
| 245       instance, pp_file_system); | 245       instance, pp_file_system); | 
| 246   if (!host) | 246   if (!host) | 
| 247     return 0; | 247     return 0; | 
| 248 | 248 | 
| 249   PepperFileSystemHost* fs_host = host->AsPepperFileSystemHost(); | 249   PepperFileSystemHost* fs_host = host->AsPepperFileSystemHost(); | 
| 250   if (!fs_host) | 250   if (!fs_host) | 
| 251     return 0; | 251     return 0; | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 459   if (!plugin_instance.get()) | 459   if (!plugin_instance.get()) | 
| 460     return PP_ERROR_FAILED; | 460     return PP_ERROR_FAILED; | 
| 461 | 461 | 
| 462   if (!file_system_) { | 462   if (!file_system_) { | 
| 463     // External file system | 463     // External file system | 
| 464     // We have to do something totally different for external file systems. | 464     // We have to do something totally different for external file systems. | 
| 465 | 465 | 
| 466     // TODO(teravest): Use the SequencedWorkerPool instead. | 466     // TODO(teravest): Use the SequencedWorkerPool instead. | 
| 467     scoped_refptr<base::TaskRunner> task_runner = | 467     scoped_refptr<base::TaskRunner> task_runner = | 
| 468         RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); | 468         RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); | 
| 469     if (!plugin_instance->delegate()->AsyncOpenFile( | 469     if (!plugin_instance->helper()->AsyncOpenFile( | 
| 470             GetSystemPath(), | 470             GetSystemPath(), | 
| 471             base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 471             base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 
| 472             base::Bind(&QueryCallback, task_runner, info, callback))) | 472             base::Bind(&QueryCallback, task_runner, info, callback))) | 
| 473       return PP_ERROR_FAILED; | 473       return PP_ERROR_FAILED; | 
| 474   } else { | 474   } else { | 
| 475     // Non-external file system | 475     // Non-external file system | 
| 476     if (!HasValidFileSystem()) | 476     if (!HasValidFileSystem()) | 
| 477       return PP_ERROR_NOACCESS; | 477       return PP_ERROR_NOACCESS; | 
| 478 | 478 | 
| 479     PP_FileSystemType file_system_type = GetResourceHost()-> | 479     PP_FileSystemType file_system_type = GetResourceHost()-> | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 521 ppapi::host::ResourceHost* PPB_FileRef_Impl::GetResourceHostInternal( | 521 ppapi::host::ResourceHost* PPB_FileRef_Impl::GetResourceHostInternal( | 
| 522     PP_Instance instance, PP_Resource resource) { | 522     PP_Instance instance, PP_Resource resource) { | 
| 523   const ppapi::host::PpapiHost* ppapi_host = | 523   const ppapi::host::PpapiHost* ppapi_host = | 
| 524       RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); | 524       RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); | 
| 525   if (!resource || !ppapi_host) | 525   if (!resource || !ppapi_host) | 
| 526     return NULL; | 526     return NULL; | 
| 527   return ppapi_host->GetResourceHost(resource); | 527   return ppapi_host->GetResourceHost(resource); | 
| 528 } | 528 } | 
| 529 | 529 | 
| 530 }  // namespace content | 530 }  // namespace content | 
| OLD | NEW | 
|---|