Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: components/nacl/renderer/manifest_service_channel.cc

Issue 418423002: Pepper: Stop using SRPC for irt_open_resource(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for dmichael Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/nacl/renderer/manifest_service_channel.cc
diff --git a/components/nacl/renderer/manifest_service_channel.cc b/components/nacl/renderer/manifest_service_channel.cc
index cb397038f82760ea310db0e093078bca4035ea41..c241b02114a80d84a070a14970f8381e1edbb53c 100644
--- a/components/nacl/renderer/manifest_service_channel.cc
+++ b/components/nacl/renderer/manifest_service_channel.cc
@@ -7,10 +7,12 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
+#include "content/public/common/sandbox_init.h"
#include "content/public/renderer/render_thread.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_sync_channel.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_file_io.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace nacl {
@@ -29,6 +31,7 @@ ManifestServiceChannel::ManifestServiceChannel(
content::RenderThread::Get()->GetIOMessageLoopProxy(),
true,
waitable_event)),
+ peer_pid_(base::kNullProcessId),
weak_ptr_factory_(this) {
}
@@ -54,6 +57,7 @@ bool ManifestServiceChannel::OnMessageReceived(const IPC::Message& message) {
}
void ManifestServiceChannel::OnChannelConnected(int32 peer_pid) {
+ peer_pid_ = peer_pid;
if (!connected_callback_.is_null())
base::ResetAndReturn(&connected_callback_).Run(PP_OK);
}
@@ -69,31 +73,33 @@ void ManifestServiceChannel::OnStartupInitializationComplete() {
void ManifestServiceChannel::OnOpenResource(
const std::string& key, IPC::Message* reply) {
- // Currently this is used only for non-SFI mode, which is not supported on
- // windows.
-#if !defined(OS_WIN)
delegate_->OpenResource(
key,
base::Bind(&ManifestServiceChannel::DidOpenResource,
weak_ptr_factory_.GetWeakPtr(), reply));
-#else
- PpapiHostMsg_OpenResource::WriteReplyParams(
- reply, ppapi::proxy::SerializedHandle());
- Send(reply);
-#endif
}
-#if !defined(OS_WIN)
void ManifestServiceChannel::DidOpenResource(
IPC::Message* reply, base::File file) {
- // Here, PlatformFileForTransit is alias of base::FileDescriptor.
- PpapiHostMsg_OpenResource::WriteReplyParams(
- reply,
- ppapi::proxy::SerializedHandle(
- ppapi::proxy::SerializedHandle::FILE,
- base::FileDescriptor(file.Pass())));
+ ppapi::proxy::SerializedHandle h;
Mark Seaborn 2014/08/07 04:46:22 Nit: 'h' -> 'handle' (to avoid 1-char var names)
teravest 2014/08/07 18:47:02 Done.
+ if (file.IsValid()) {
+ IPC::PlatformFileForTransit file_for_transit;
+#if defined(OS_WIN)
+ bool ok = content::BrokerDuplicateHandle(
+ file.TakePlatformFile(),
+ peer_pid_,
+ &file_for_transit,
+ 0, // desired_access is 0 since we're using DUPLICATE_SAME_ACCESS.
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+ if (ok)
+ h.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0);
+#else
+ file_for_transit = base::FileDescriptor(file.Pass());
+ h.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0);
+#endif
+ }
+ PpapiHostMsg_OpenResource::WriteReplyParams(reply, h);
Send(reply);
}
-#endif
} // namespace nacl

Powered by Google App Engine
This is Rietveld 408576698