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_helper_impl.h" | 14 #include "content/renderer/pepper/pepper_helper_impl.h" |
15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | |
16 #include "content/renderer/pepper/plugin_module.h" | 15 #include "content/renderer/pepper/plugin_module.h" |
17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 16 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
18 #include "content/renderer/pepper/resource_helper.h" | |
19 #include "content/renderer/render_thread_impl.h" | 17 #include "content/renderer/render_thread_impl.h" |
20 #include "net/base/escape.h" | 18 #include "net/base/escape.h" |
21 #include "ppapi/c/pp_errors.h" | 19 #include "ppapi/c/pp_errors.h" |
22 #include "ppapi/host/ppapi_host.h" | 20 #include "ppapi/host/ppapi_host.h" |
23 #include "ppapi/shared_impl/file_type_conversion.h" | 21 #include "ppapi/shared_impl/file_type_conversion.h" |
24 #include "ppapi/shared_impl/time_conversion.h" | 22 #include "ppapi/shared_impl/time_conversion.h" |
25 #include "ppapi/shared_impl/var.h" | 23 #include "ppapi/shared_impl/var.h" |
26 #include "ppapi/thunk/enter.h" | 24 #include "ppapi/thunk/enter.h" |
27 #include "ppapi/thunk/ppb_file_system_api.h" | 25 #include "ppapi/thunk/ppb_file_system_api.h" |
28 #include "url/gurl.h" | 26 #include "url/gurl.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 external_file_system_path_(external_file_path) { | 227 external_file_system_path_(external_file_path) { |
230 } | 228 } |
231 | 229 |
232 PPB_FileRef_Impl::~PPB_FileRef_Impl() { | 230 PPB_FileRef_Impl::~PPB_FileRef_Impl() { |
233 } | 231 } |
234 | 232 |
235 // static | 233 // static |
236 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, | 234 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, |
237 PP_Resource pp_file_system, | 235 PP_Resource pp_file_system, |
238 const std::string& path) { | 236 const std::string& path) { |
239 PepperPluginInstanceImpl* plugin_instance = | |
240 ResourceHelper::PPInstanceToPluginInstance(instance); | |
241 if (!plugin_instance || !plugin_instance->helper()) | |
242 return 0; | |
243 | |
244 ppapi::host::ResourceHost* host = GetResourceHostInternal( | 237 ppapi::host::ResourceHost* host = GetResourceHostInternal( |
245 instance, pp_file_system); | 238 instance, pp_file_system); |
246 if (!host) | 239 if (!host) |
247 return 0; | 240 return 0; |
248 | 241 |
249 PepperFileSystemHost* fs_host = host->AsPepperFileSystemHost(); | 242 PepperFileSystemHost* fs_host = host->AsPepperFileSystemHost(); |
250 if (!fs_host) | 243 if (!fs_host) |
251 return 0; | 244 return 0; |
252 | 245 |
253 PP_FileSystemType type = fs_host->GetType(); | 246 PP_FileSystemType type = fs_host->GetType(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 440 |
448 int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, | 441 int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, |
449 scoped_refptr<TrackedCallback> callback) { | 442 scoped_refptr<TrackedCallback> callback) { |
450 NOTREACHED(); | 443 NOTREACHED(); |
451 return PP_ERROR_FAILED; | 444 return PP_ERROR_FAILED; |
452 } | 445 } |
453 | 446 |
454 int32_t PPB_FileRef_Impl::QueryInHost( | 447 int32_t PPB_FileRef_Impl::QueryInHost( |
455 linked_ptr<PP_FileInfo> info, | 448 linked_ptr<PP_FileInfo> info, |
456 scoped_refptr<TrackedCallback> callback) { | 449 scoped_refptr<TrackedCallback> callback) { |
457 scoped_refptr<PepperPluginInstanceImpl> plugin_instance = | |
458 ResourceHelper::GetPluginInstance(this); | |
459 if (!plugin_instance.get()) | |
460 return PP_ERROR_FAILED; | |
461 | |
462 if (!file_system_) { | 450 if (!file_system_) { |
463 // External file system | 451 // External file system |
464 // We have to do something totally different for external file systems. | 452 // We have to do something totally different for external file systems. |
465 | 453 |
466 // TODO(teravest): Use the SequencedWorkerPool instead. | 454 // TODO(teravest): Use the SequencedWorkerPool instead. |
467 scoped_refptr<base::TaskRunner> task_runner = | 455 scoped_refptr<base::TaskRunner> task_runner = |
468 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); | 456 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); |
469 if (!plugin_instance->helper()->AsyncOpenFile( | 457 RenderThreadImpl::current()->AsyncOpenFile( |
470 GetSystemPath(), | 458 GetSystemPath(), |
471 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 459 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
472 base::Bind(&QueryCallback, task_runner, info, callback))) | 460 base::Bind(&QueryCallback, task_runner, info, callback)); |
473 return PP_ERROR_FAILED; | |
474 } else { | 461 } else { |
475 // Non-external file system | 462 // Non-external file system |
476 if (!HasValidFileSystem()) | 463 if (!HasValidFileSystem()) |
477 return PP_ERROR_NOACCESS; | 464 return PP_ERROR_NOACCESS; |
478 | 465 |
479 PP_FileSystemType file_system_type = GetResourceHost()-> | 466 PP_FileSystemType file_system_type = GetResourceHost()-> |
480 AsPepperFileSystemHost()->GetType(); | 467 AsPepperFileSystemHost()->GetType(); |
481 FileSystemDispatcher* file_system_dispatcher = | 468 FileSystemDispatcher* file_system_dispatcher = |
482 ChildThread::current()->file_system_dispatcher(); | 469 ChildThread::current()->file_system_dispatcher(); |
483 file_system_dispatcher->ReadMetadata( | 470 file_system_dispatcher->ReadMetadata( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 ppapi::host::ResourceHost* PPB_FileRef_Impl::GetResourceHostInternal( | 508 ppapi::host::ResourceHost* PPB_FileRef_Impl::GetResourceHostInternal( |
522 PP_Instance instance, PP_Resource resource) { | 509 PP_Instance instance, PP_Resource resource) { |
523 const ppapi::host::PpapiHost* ppapi_host = | 510 const ppapi::host::PpapiHost* ppapi_host = |
524 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); | 511 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); |
525 if (!resource || !ppapi_host) | 512 if (!resource || !ppapi_host) |
526 return NULL; | 513 return NULL; |
527 return ppapi_host->GetResourceHost(resource); | 514 return ppapi_host->GetResourceHost(resource); |
528 } | 515 } |
529 | 516 |
530 } // namespace content | 517 } // namespace content |
OLD | NEW |