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_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 } | 105 } |
106 | 106 |
107 } // namespace | 107 } // namespace |
108 | 108 |
109 PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host, | 109 PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host, |
110 PP_Instance instance, | 110 PP_Instance instance, |
111 PP_Resource resource) | 111 PP_Resource resource) |
112 : ResourceHost(host->GetPpapiHost(), instance, resource), | 112 : ResourceHost(host->GetPpapiHost(), instance, resource), |
113 file_(base::kInvalidPlatformFileValue), | 113 file_(base::kInvalidPlatformFileValue), |
114 file_system_type_(PP_FILESYSTEMTYPE_INVALID), | 114 file_system_type_(PP_FILESYSTEMTYPE_INVALID), |
115 quota_limit_type_(quota::kQuotaLimitTypeUnknown), | |
115 is_running_in_process_(host->IsRunningInProcess()), | 116 is_running_in_process_(host->IsRunningInProcess()), |
116 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 117 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
117 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed. | 118 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed. |
118 webkit::ppapi::PluginInstance* plugin_instance = | 119 webkit::ppapi::PluginInstance* plugin_instance = |
119 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); | 120 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); |
120 plugin_delegate_ = plugin_instance ? plugin_instance->delegate() : NULL; | 121 plugin_delegate_ = plugin_instance ? plugin_instance->delegate() : NULL; |
121 } | 122 } |
122 | 123 |
123 PepperFileIOHost::~PepperFileIOHost() { | 124 PepperFileIOHost::~PepperFileIOHost() { |
124 OnHostMsgClose(NULL); | 125 OnHostMsgClose(NULL); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 context->MakeReplyMessageContext()))) | 448 context->MakeReplyMessageContext()))) |
448 return PP_ERROR_FAILED; | 449 return PP_ERROR_FAILED; |
449 | 450 |
450 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); | 451 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); |
451 return PP_OK_COMPLETIONPENDING; | 452 return PP_OK_COMPLETIONPENDING; |
452 } | 453 } |
453 | 454 |
454 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( | 455 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( |
455 ppapi::host::HostMessageContext* context) { | 456 ppapi::host::HostMessageContext* context) { |
456 if (!is_running_in_process_ && | 457 if (!is_running_in_process_ && |
458 quota_limit_type_ != quota::kQuotaLimitTypeUnlimited && | |
459 // TODO(hamaji): Remove the whitelist once it turned out the | |
460 // quota check is sufficient. http://crbug.com/226386 | |
457 !GetContentClient()->renderer()->IsRequestOSFileHandleAllowedForURL( | 461 !GetContentClient()->renderer()->IsRequestOSFileHandleAllowedForURL( |
458 file_system_url_)) | 462 file_system_url_)) |
459 return PP_ERROR_FAILED; | 463 return PP_ERROR_FAILED; |
460 | 464 |
461 // TODO(hamaji): Should fail if quota is not unlimited. | |
462 // http://crbug.com/224123 | |
463 | |
464 RendererPpapiHost* renderer_ppapi_host = | 465 RendererPpapiHost* renderer_ppapi_host = |
465 RendererPpapiHost::GetForPPInstance(pp_instance()); | 466 RendererPpapiHost::GetForPPInstance(pp_instance()); |
466 | 467 |
467 IPC::PlatformFileForTransit file = | 468 IPC::PlatformFileForTransit file = |
468 renderer_ppapi_host->ShareHandleWithRemote(file_, false); | 469 renderer_ppapi_host->ShareHandleWithRemote(file_, false); |
469 if (file == IPC::InvalidPlatformFileForTransit()) | 470 if (file == IPC::InvalidPlatformFileForTransit()) |
470 return PP_ERROR_FAILED; | 471 return PP_ERROR_FAILED; |
471 ppapi::host::ReplyMessageContext reply_context = | 472 ppapi::host::ReplyMessageContext reply_context = |
472 context->MakeReplyMessageContext(); | 473 context->MakeReplyMessageContext(); |
473 reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle( | 474 reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 527 |
527 reply_context.params.set_result(pp_error); | 528 reply_context.params.set_result(pp_error); |
528 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply()); | 529 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply()); |
529 state_manager_.SetOperationFinished(); | 530 state_manager_.SetOperationFinished(); |
530 } | 531 } |
531 | 532 |
532 void PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback( | 533 void PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback( |
533 ppapi::host::ReplyMessageContext reply_context, | 534 ppapi::host::ReplyMessageContext reply_context, |
534 base::PlatformFileError error_code, | 535 base::PlatformFileError error_code, |
535 base::PassPlatformFile file, | 536 base::PassPlatformFile file, |
537 quota::QuotaLimitType quota_limit_type, | |
536 const PluginDelegate::NotifyCloseFileCallback& callback) { | 538 const PluginDelegate::NotifyCloseFileCallback& callback) { |
537 if (error_code == base::PLATFORM_FILE_OK) | 539 if (error_code == base::PLATFORM_FILE_OK) |
538 notify_close_file_callback_ = callback; | 540 notify_close_file_callback_ = callback; |
541 //quota_limit_type_ = quota_limit_type; | |
kinuko
2013/04/04 11:01:42
need to comment this in?
hamaji
2013/04/04 11:50:12
Wow :) Done.
| |
539 ExecutePlatformOpenFileCallback(reply_context, error_code, file); | 542 ExecutePlatformOpenFileCallback(reply_context, error_code, file); |
540 } | 543 } |
541 | 544 |
542 void PepperFileIOHost::ExecutePlatformQueryCallback( | 545 void PepperFileIOHost::ExecutePlatformQueryCallback( |
543 ppapi::host::ReplyMessageContext reply_context, | 546 ppapi::host::ReplyMessageContext reply_context, |
544 base::PlatformFileError error_code, | 547 base::PlatformFileError error_code, |
545 const base::PlatformFileInfo& file_info) { | 548 const base::PlatformFileInfo& file_info) { |
546 PP_FileInfo pp_info; | 549 PP_FileInfo pp_info; |
547 pp_info.size = file_info.size; | 550 pp_info.size = file_info.size; |
548 pp_info.creation_time = TimeToPPTime(file_info.creation_time); | 551 pp_info.creation_time = TimeToPPTime(file_info.creation_time); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 // On the plugin side, the callback expects a parameter with different meaning | 596 // On the plugin side, the callback expects a parameter with different meaning |
594 // depends on whether is negative or not. It is the result here. We translate | 597 // depends on whether is negative or not. It is the result here. We translate |
595 // for the callback. | 598 // for the callback. |
596 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); | 599 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); |
597 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 600 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); |
598 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 601 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); |
599 state_manager_.SetOperationFinished(); | 602 state_manager_.SetOperationFinished(); |
600 } | 603 } |
601 | 604 |
602 } // namespace content | 605 } // namespace content |
OLD | NEW |