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

Unified Diff: components/nacl/loader/nacl_trusted_listener.cc

Issue 2590173002: Convert NaCl renderer-loader messages to mojo. (Closed)
Patch Set: GetProxy() -> MakeRequest() Created 4 years 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
« no previous file with comments | « components/nacl/loader/nacl_trusted_listener.h ('k') | components/nacl/loader/nonsfi/nonsfi_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nacl_trusted_listener.cc
diff --git a/components/nacl/loader/nacl_trusted_listener.cc b/components/nacl/loader/nacl_trusted_listener.cc
index df8fc200c14b78b5b5d7ef904414b338d541add3..20448fa05398cc70a8e9d44e718250c7be4f43d4 100644
--- a/components/nacl/loader/nacl_trusted_listener.cc
+++ b/components/nacl/loader/nacl_trusted_listener.cc
@@ -6,52 +6,45 @@
#include "base/single_thread_task_runner.h"
#include "build/build_config.h"
-#include "ipc/message_filter.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "native_client/src/public/chrome_main.h"
namespace {
-// The OnChannelError() event must be processed in a MessageFilter so it can
-// be handled on the IO thread. The main thread used by NaClListener is busy
-// in NaClChromeMainAppStart(), so it can't be used for servicing messages.
-class EOFMessageFilter : public IPC::MessageFilter {
+class NaClExitControlImpl : public nacl::mojom::NaClExitControl {
public:
- void OnChannelError() override {
- // The renderer process dropped its connection to this process (the NaCl
- // loader process), either because the <embed> element was removed
- // (perhaps implicitly if the tab was closed) or because the renderer
- // crashed. The NaCl loader process should therefore exit.
+ ~NaClExitControlImpl() override {
+ // If the binding disconnects, the renderer process dropped its connection
+ // to this process (the NaCl loader process), either because the <embed>
+ // element was removed (perhaps implicitly if the tab was closed) or because
+ // the renderer crashed. The NaCl loader process should therefore exit.
//
// For SFI NaCl, trusted code does this exit voluntarily, but untrusted
// code cannot disable it. However, for Non-SFI NaCl, the following exit
// call could be disabled by untrusted code.
NaClExit(0);
brucedawson 2016/12/21 01:12:28 VC++ hates having a call to exit() in a destructor
}
- private:
- ~EOFMessageFilter() override {}
};
+void CreateExitControl(nacl::mojom::NaClExitControlRequest request) {
+ mojo::MakeStrongBinding(base::MakeUnique<NaClExitControlImpl>(),
+ std::move(request));
}
-NaClTrustedListener::NaClTrustedListener(
- const IPC::ChannelHandle& handle,
- base::SingleThreadTaskRunner* ipc_task_runner,
- base::WaitableEvent* shutdown_event)
- : channel_handle_(handle) {
- channel_ =
- IPC::SyncChannel::Create(handle, IPC::Channel::MODE_SERVER, this,
- ipc_task_runner, true, /* create_channel_now */
- shutdown_event);
- channel_->AddFilter(new EOFMessageFilter());
-}
-
-NaClTrustedListener::~NaClTrustedListener() {
-}
+} // namespace
-bool NaClTrustedListener::OnMessageReceived(const IPC::Message& msg) {
- return false;
+NaClTrustedListener::NaClTrustedListener(
+ nacl::mojom::NaClRendererHostPtr renderer_host,
+ base::SingleThreadTaskRunner* io_task_runner)
+ : renderer_host_(std::move(renderer_host)) {
+ nacl::mojom::NaClExitControlPtr exit_control;
+ // The exit control binding must run on the IO thread. The main thread used
+ // by NaClListener is busy in NaClChromeMainAppStart(), so it can't be used
+ // for servicing messages.
+ io_task_runner->PostTask(
+ FROM_HERE, base::Bind(&CreateExitControl,
+ base::Passed(mojo::MakeRequest(&exit_control))));
+ renderer_host_->ProvideExitControl(std::move(exit_control));
}
-bool NaClTrustedListener::Send(IPC::Message* msg) {
- return channel_->Send(msg);
-}
+NaClTrustedListener::~NaClTrustedListener() = default;
« no previous file with comments | « components/nacl/loader/nacl_trusted_listener.h ('k') | components/nacl/loader/nonsfi/nonsfi_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698