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

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

Issue 249183004: Implement open_resource in non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 f0f4adb8f940a261a4116c1f6fe9b1f292e0e4e2..26d7ae455e93dc767937a8335f0f46dfedc1678f 100644
--- a/components/nacl/renderer/manifest_service_channel.cc
+++ b/components/nacl/renderer/manifest_service_channel.cc
@@ -4,6 +4,7 @@
#include "components/nacl/renderer/manifest_service_channel.h"
+#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "content/public/renderer/render_thread.h"
@@ -24,7 +25,8 @@ ManifestServiceChannel::ManifestServiceChannel(
channel_(new IPC::SyncChannel(
handle, IPC::Channel::MODE_CLIENT, this,
content::RenderThread::Get()->GetIOMessageLoopProxy(),
- true, waitable_event)) {
+ true, waitable_event)),
+ weak_ptr_factory_(this) {
}
ManifestServiceChannel::~ManifestServiceChannel() {
@@ -32,12 +34,17 @@ ManifestServiceChannel::~ManifestServiceChannel() {
base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED);
}
+void ManifestServiceChannel::Send(IPC::Message* message) {
+ channel_->Send(message);
+}
+
bool ManifestServiceChannel::OnMessageReceived(const IPC::Message& message) {
- // TODO(hidehiko): Implement OpenResource.
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ManifestServiceChannel, message)
IPC_MESSAGE_HANDLER(PpapiHostMsg_StartupInitializationComplete,
OnStartupInitializationComplete)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(PpapiHostMsg_OpenResource,
+ OnOpenResource)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -57,4 +64,28 @@ void ManifestServiceChannel::OnStartupInitializationComplete() {
delegate_->StartupInitializationComplete();
}
+void ManifestServiceChannel::OnOpenResource(
+ const std::string& key, IPC::Message* reply) {
+ delegate_->OpenResource(key,
Mark Seaborn 2014/04/30 21:20:58 On Windows, it would be better for this to be a no
hidehiko 2014/05/01 05:20:31 Done.
+ base::Bind(&ManifestServiceChannel::DidOpenResource,
+ weak_ptr_factory_.GetWeakPtr(), reply));
+}
+
+void ManifestServiceChannel::DidOpenResource(
+ IPC::Message* reply, const base::PlatformFile& platform_file) {
+#if defined(OS_WIN)
+ // Currently this is used only for non-SFI mode, which is not supported on
+ // windows.
+ NOTREACHED();
Mark Seaborn 2014/04/30 21:20:58 This would allow the NaCl process to crash the ren
hidehiko 2014/05/01 05:20:31 IMHO, crashing on Debug build is fine. Actually, t
Mark Seaborn 2014/05/01 06:32:35 For what meaning of "should"? :-) Untrusted code
hidehiko 2014/05/01 13:05:40 I'm a bit confused. I thought nacl_helper is a par
Mark Seaborn 2014/05/01 23:28:33 Ah, sorry, I hadn't realised that the new IPC chan
hidehiko 2014/05/02 01:32:27 Thanks. So let's keep the current error handling.
+#else
+ // Here, PlatformFileForTransit is alias of base::FileDescriptor.
+ PpapiHostMsg_OpenResource::WriteReplyParams(
+ reply,
+ ppapi::proxy::SerializedHandle(
+ ppapi::proxy::SerializedHandle::FILE,
+ base::FileDescriptor(platform_file, true)));
Mark Seaborn 2014/04/30 21:20:58 On error, platform_file will be PP_kInvalidFileHan
hidehiko 2014/05/01 05:20:31 I think it's fine. Anyway, let's add a test case i
Mark Seaborn 2014/05/01 06:32:35 Hmm, as I read it, that means you're not sure whet
hidehiko 2014/05/01 13:05:40 I've already confirmed manually, and invoking open
+#endif
+ Send(reply);
Mark Seaborn 2014/04/30 21:20:58 What are the implications of calling Send(Reply) w
hidehiko 2014/05/01 05:20:31 acknowledged.
+}
+
} // namespace nacl

Powered by Google App Engine
This is Rietveld 408576698