OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/renderer_host/pepper/pepper_file_io_host.h" | 5 #include "content/browser/renderer_host/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/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 | 447 |
448 void PepperFileIOHost::SendOpenErrorReply( | 448 void PepperFileIOHost::SendOpenErrorReply( |
449 ppapi::host::ReplyMessageContext reply_context) { | 449 ppapi::host::ReplyMessageContext reply_context) { |
450 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply(0, 0)); | 450 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply(0, 0)); |
451 } | 451 } |
452 | 452 |
453 bool PepperFileIOHost::AddFileToReplyContext( | 453 bool PepperFileIOHost::AddFileToReplyContext( |
454 int32_t open_flags, | 454 int32_t open_flags, |
455 ppapi::host::ReplyMessageContext* reply_context) const { | 455 ppapi::host::ReplyMessageContext* reply_context) const { |
456 base::ProcessId plugin_process_id; | 456 base::ProcessId plugin_process_id = |
457 if (browser_ppapi_host_->in_process()) { | 457 base::GetProcId(browser_ppapi_host_->GetPluginProcessHandle()); |
| 458 if (plugin_process_id == base::kNullProcessId) |
458 plugin_process_id = resolved_render_process_id_; | 459 plugin_process_id = resolved_render_process_id_; |
459 } else { | 460 |
460 plugin_process_id = base::GetProcId( | |
461 browser_ppapi_host_->GetPluginProcessHandle()); | |
462 } | |
463 IPC::PlatformFileForTransit transit_file = BrokerGetFileHandleForProcess( | 461 IPC::PlatformFileForTransit transit_file = BrokerGetFileHandleForProcess( |
464 file_, plugin_process_id, false); | 462 file_, plugin_process_id, false); |
465 if (transit_file == IPC::InvalidPlatformFileForTransit()) | 463 if (transit_file == IPC::InvalidPlatformFileForTransit()) |
466 return false; | 464 return false; |
467 | 465 |
468 ppapi::proxy::SerializedHandle file_handle; | 466 ppapi::proxy::SerializedHandle file_handle; |
469 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. | 467 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. |
470 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; | 468 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; |
471 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); | 469 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); |
472 reply_context->params.AppendHandle(file_handle); | 470 reply_context->params.AppendHandle(file_handle); |
473 return true; | 471 return true; |
474 } | 472 } |
475 | 473 |
476 } // namespace content | 474 } // namespace content |
OLD | NEW |