| 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/pepper_file_io_host.h" | 5 #include "content/renderer/pepper/pepper_file_io_host.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/callback.h" | 8 #include "base/callback.h" | 
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" | 
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" | 
| 11 #include "base/files/file_util_proxy.h" | 11 #include "base/files/file_util_proxy.h" | 
| 12 #include "content/child/child_thread.h" | 12 #include "content/child/child_thread.h" | 
| 13 #include "content/child/fileapi/file_system_dispatcher.h" | 13 #include "content/child/fileapi/file_system_dispatcher.h" | 
| 14 #include "content/child/quota_dispatcher.h" | 14 #include "content/child/quota_dispatcher.h" | 
| 15 #include "content/common/fileapi/file_system_messages.h" | 15 #include "content/common/fileapi/file_system_messages.h" | 
| 16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" | 
| 17 #include "content/public/renderer/content_renderer_client.h" | 17 #include "content/public/renderer/content_renderer_client.h" | 
| 18 #include "content/renderer/pepper/host_globals.h" | 18 #include "content/renderer/pepper/host_globals.h" | 
| 19 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 19 #include "content/renderer/pepper/pepper_helper_impl.h" | 
| 20 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 20 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 
| 21 #include "content/renderer/pepper/ppb_file_ref_impl.h" | 21 #include "content/renderer/pepper/ppb_file_ref_impl.h" | 
| 22 #include "content/renderer/pepper/quota_file_io.h" | 22 #include "content/renderer/pepper/quota_file_io.h" | 
| 23 #include "content/renderer/pepper/resource_helper.h" | 23 #include "content/renderer/pepper/resource_helper.h" | 
| 24 #include "content/renderer/render_thread_impl.h" | 24 #include "content/renderer/render_thread_impl.h" | 
| 25 #include "ppapi/c/pp_errors.h" | 25 #include "ppapi/c/pp_errors.h" | 
| 26 #include "ppapi/host/dispatch_host_message.h" | 26 #include "ppapi/host/dispatch_host_message.h" | 
| 27 #include "ppapi/host/ppapi_host.h" | 27 #include "ppapi/host/ppapi_host.h" | 
| 28 #include "ppapi/proxy/ppapi_messages.h" | 28 #include "ppapi/proxy/ppapi_messages.h" | 
| 29 #include "ppapi/shared_impl/file_type_conversion.h" | 29 #include "ppapi/shared_impl/file_type_conversion.h" | 
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 222         ChildThread::current()->file_system_dispatcher(); | 222         ChildThread::current()->file_system_dispatcher(); | 
| 223     AsyncOpenFileSystemURLCallback callback = base::Bind( | 223     AsyncOpenFileSystemURLCallback callback = base::Bind( | 
| 224         &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, | 224         &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, | 
| 225         weak_factory_.GetWeakPtr(), | 225         weak_factory_.GetWeakPtr(), | 
| 226         context->MakeReplyMessageContext()); | 226         context->MakeReplyMessageContext()); | 
| 227     file_system_dispatcher->OpenFile( | 227     file_system_dispatcher->OpenFile( | 
| 228       file_system_url_, flags, | 228       file_system_url_, flags, | 
| 229       base::Bind(&DidOpenFileSystemURL, callback), | 229       base::Bind(&DidOpenFileSystemURL, callback), | 
| 230       base::Bind(&DidFailOpenFileSystemURL, callback)); | 230       base::Bind(&DidFailOpenFileSystemURL, callback)); | 
| 231   } else { | 231   } else { | 
| 232     PepperPluginDelegateImpl* plugin_delegate = | 232     PepperHelperImpl* helper = static_cast<PepperPluginInstanceImpl*>( | 
| 233         static_cast<PepperPluginInstanceImpl*>( | 233         PepperPluginInstance::Get(pp_instance()))->helper(); | 
| 234             PepperPluginInstance::Get(pp_instance()))->delegate(); | 234     if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL || !helper) | 
| 235     if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL || !plugin_delegate) |  | 
| 236       return PP_ERROR_FAILED; | 235       return PP_ERROR_FAILED; | 
| 237     if (!plugin_delegate->AsyncOpenFile( | 236     if (!helper->AsyncOpenFile( | 
| 238             file_ref->GetSystemPath(), flags, | 237             file_ref->GetSystemPath(), flags, | 
| 239             base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, | 238             base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, | 
| 240                        weak_factory_.GetWeakPtr(), | 239                        weak_factory_.GetWeakPtr(), | 
| 241                        context->MakeReplyMessageContext()))) | 240                        context->MakeReplyMessageContext()))) | 
| 242       return PP_ERROR_FAILED; | 241       return PP_ERROR_FAILED; | 
| 243   } | 242   } | 
| 244 | 243 | 
| 245   state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); | 244   state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); | 
| 246   return PP_OK_COMPLETIONPENDING; | 245   return PP_OK_COMPLETIONPENDING; | 
| 247 } | 246 } | 
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 609   // On the plugin side, the callback expects a parameter with different meaning | 608   // On the plugin side, the callback expects a parameter with different meaning | 
| 610   // depends on whether is negative or not. It is the result here. We translate | 609   // depends on whether is negative or not. It is the result here. We translate | 
| 611   // for the callback. | 610   // for the callback. | 
| 612   int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); | 611   int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); | 
| 613   reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 612   reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 
| 614   host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 613   host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 
| 615   state_manager_.SetOperationFinished(); | 614   state_manager_.SetOperationFinished(); | 
| 616 } | 615 } | 
| 617 | 616 | 
| 618 }  // namespace content | 617 }  // namespace content | 
| OLD | NEW | 
|---|