| 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_helper_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" | |
| 24 #include "content/renderer/render_thread_impl.h" | 23 #include "content/renderer/render_thread_impl.h" |
| 25 #include "ppapi/c/pp_errors.h" | 24 #include "ppapi/c/pp_errors.h" |
| 26 #include "ppapi/c/ppb_file_io.h" | 25 #include "ppapi/c/ppb_file_io.h" |
| 27 #include "ppapi/host/dispatch_host_message.h" | 26 #include "ppapi/host/dispatch_host_message.h" |
| 28 #include "ppapi/host/ppapi_host.h" | 27 #include "ppapi/host/ppapi_host.h" |
| 29 #include "ppapi/proxy/ppapi_messages.h" | 28 #include "ppapi/proxy/ppapi_messages.h" |
| 30 #include "ppapi/shared_impl/file_type_conversion.h" | 29 #include "ppapi/shared_impl/file_type_conversion.h" |
| 31 #include "ppapi/shared_impl/time_conversion.h" | 30 #include "ppapi/shared_impl/time_conversion.h" |
| 32 #include "ppapi/thunk/enter.h" | 31 #include "ppapi/thunk/enter.h" |
| 33 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 32 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (file_ref->HasValidFileSystem()) { | 215 if (file_ref->HasValidFileSystem()) { |
| 217 file_system_url_ = file_ref->GetFileSystemURL(); | 216 file_system_url_ = file_ref->GetFileSystemURL(); |
| 218 | 217 |
| 219 FileSystemDispatcher* file_system_dispatcher = | 218 FileSystemDispatcher* file_system_dispatcher = |
| 220 ChildThread::current()->file_system_dispatcher(); | 219 ChildThread::current()->file_system_dispatcher(); |
| 221 AsyncOpenFileSystemURLCallback callback = base::Bind( | 220 AsyncOpenFileSystemURLCallback callback = base::Bind( |
| 222 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, | 221 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, |
| 223 weak_factory_.GetWeakPtr(), | 222 weak_factory_.GetWeakPtr(), |
| 224 context->MakeReplyMessageContext()); | 223 context->MakeReplyMessageContext()); |
| 225 file_system_dispatcher->OpenFile( | 224 file_system_dispatcher->OpenFile( |
| 226 file_system_url_, flags, | 225 file_system_url_, flags, |
| 227 base::Bind(&DidOpenFileSystemURL, callback), | 226 base::Bind(&DidOpenFileSystemURL, callback), |
| 228 base::Bind(&DidFailOpenFileSystemURL, callback)); | 227 base::Bind(&DidFailOpenFileSystemURL, callback)); |
| 229 } else { | 228 } else { |
| 230 PepperHelperImpl* helper = static_cast<PepperPluginInstanceImpl*>( | 229 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) |
| 231 PepperPluginInstance::Get(pp_instance()))->helper(); | |
| 232 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL || !helper) | |
| 233 return PP_ERROR_FAILED; | 230 return PP_ERROR_FAILED; |
| 234 if (!helper->AsyncOpenFile( | 231 RenderThreadImpl::current()->AsyncOpenFile( |
| 235 file_ref->GetSystemPath(), flags, | 232 file_ref->GetSystemPath(), flags, |
| 236 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, | 233 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, |
| 237 weak_factory_.GetWeakPtr(), | 234 weak_factory_.GetWeakPtr(), |
| 238 context->MakeReplyMessageContext()))) | 235 context->MakeReplyMessageContext())); |
| 239 return PP_ERROR_FAILED; | |
| 240 } | 236 } |
| 241 | 237 |
| 242 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); | 238 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); |
| 243 return PP_OK_COMPLETIONPENDING; | 239 return PP_OK_COMPLETIONPENDING; |
| 244 } | 240 } |
| 245 | 241 |
| 246 int32_t PepperFileIOHost::OnHostMsgTouch( | 242 int32_t PepperFileIOHost::OnHostMsgTouch( |
| 247 ppapi::host::HostMessageContext* context, | 243 ppapi::host::HostMessageContext* context, |
| 248 PP_Time last_access_time, | 244 PP_Time last_access_time, |
| 249 PP_Time last_modified_time) { | 245 PP_Time last_modified_time) { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 // On the plugin side, the callback expects a parameter with different meaning | 532 // On the plugin side, the callback expects a parameter with different meaning |
| 537 // depends on whether is negative or not. It is the result here. We translate | 533 // depends on whether is negative or not. It is the result here. We translate |
| 538 // for the callback. | 534 // for the callback. |
| 539 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); | 535 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); |
| 540 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 536 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); |
| 541 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 537 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); |
| 542 state_manager_.SetOperationFinished(); | 538 state_manager_.SetOperationFinished(); |
| 543 } | 539 } |
| 544 | 540 |
| 545 } // namespace content | 541 } // namespace content |
| OLD | NEW |