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

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

Issue 131413009: Prototype: Use Chromium IPC for plugin LOAD_MODULE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, some FIXMEs cleaned up Created 6 years, 10 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/trusted_plugin_channel.cc
diff --git a/components/nacl/renderer/trusted_plugin_channel.cc b/components/nacl/renderer/trusted_plugin_channel.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8414e6467ea0d57c5c24d7d1d1b34b2d101c4e74
--- /dev/null
+++ b/components/nacl/renderer/trusted_plugin_channel.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/nacl/renderer/trusted_plugin_channel.h"
+
+#include "base/debug/stack_trace.h"
+#include "content/public/renderer/render_thread.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+
+namespace nacl {
+
+TrustedPluginChannel::TrustedPluginChannel(
+ const IPC::ChannelHandle& handle,
+ PP_CompletionCallback connected_callback)
+ : connected_callback_(connected_callback),
+ shutdown_event_(true, false) {
+ fprintf(stderr, "TrustedPluginChannel::TrustedPluginChannel");
+ fprintf(stderr, "fd: %d\n", handle.socket.fd);
+ fprintf(stderr, "message_loop: %p\n", base::MessageLoop::current());
+ channel_.reset(new IPC::SyncChannel(
+ handle, IPC::Channel::MODE_CLIENT, this,
+ content::RenderThread::Get()->GetIOMessageLoopProxy(), true,
+ &shutdown_event_));
+}
+
+bool TrustedPluginChannel::Send(IPC::Message* message) {
+ fprintf(stderr, "TrustedPluginChannel::Send(), message=%p\n", message);
+ return channel_->Send(message);
+}
+
+bool TrustedPluginChannel::OnMessageReceived(const IPC::Message& message) {
+ return false;
+}
+
+void TrustedPluginChannel::OnChannelConnected(int32 peer_pid) {
+ fprintf(stderr, "TrustedPluginChannel::OnChannelConnected, peer_pid=%d\n",
+ peer_pid);
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(connected_callback_.func,
+ connected_callback_.user_data,
+ static_cast<int32_t>(PP_OK)));
+ connected_callback_ = PP_BlockUntilComplete();
+}
+
+void TrustedPluginChannel::OnChannelError() {
+ fprintf(stderr, "TrustedPluginChannel::OnChannelError\n");
+ if (connected_callback_.func) {
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(connected_callback_.func,
+ connected_callback_.user_data,
+ static_cast<int32_t>(PP_ERROR_FAILED)));
+ connected_callback_ = PP_BlockUntilComplete();
+ }
+}
+
+} // namespace nacl

Powered by Google App Engine
This is Rietveld 408576698