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

Unified Diff: services/nacl/pexe_linker_app.cc

Issue 1382713002: Creating a pexe content handler to translate and run pexes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Tests Added Created 5 years, 2 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: services/nacl/pexe_linker_app.cc
diff --git a/services/nacl/pexe_linker_app.cc b/services/nacl/pexe_linker_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..350fadc221425dbac4bf9ef1585049f2f5ad26c7
--- /dev/null
+++ b/services/nacl/pexe_linker_app.cc
@@ -0,0 +1,66 @@
+// Copyright 2015 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 <fcntl.h>
+
+#include "base/files/file_util.h"
+#include "mojo/nacl/nonsfi/nexe_launcher_nonsfi.h"
+#include "mojo/public/c/system/main.h"
+#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_runner.h"
+#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "services/nacl/pexe_linker.mojom.h"
+
+namespace mojo {
+namespace nacl {
+
+class PexeLinkerImpl : public PexeLinker {
+ public:
+ void PexeLink(ScopedMessagePipeHandle handle) override {
+// int nexe_fd = open("native_client/toolchain/linux_x86/pnacl_translator"
+// "/translator/x86-32-nonsfi/bin/ld.nexe", O_RDONLY);
+ int nexe_fd = open("sean_out/ld.nexe", O_RDONLY);
Mark Seaborn 2015/10/20 21:32:40 Needs fixing. :-)
Sean Klein 2015/10/22 21:50:00 No worries, the bots wouldn't let me get past this
+ if (nexe_fd < 0)
+ LOG(FATAL) << "Could not open linker nexe";
+ ::nacl::MojoLaunchNexeNonsfi(nexe_fd, handle.Pass().get().value());
+ }
+};
+
+class StrongBindingPexeLinkerImpl : public PexeLinkerImpl {
+ public:
+ explicit StrongBindingPexeLinkerImpl(InterfaceRequest<PexeLinker> request)
+ : strong_binding_(this, request.Pass()) {}
+
+ private:
+ StrongBinding<PexeLinker> strong_binding_;
+};
+
+class MultiPexeLinker : public mojo::ApplicationDelegate,
+ public mojo::InterfaceFactory<PexeLinker> {
+ public:
+ MultiPexeLinker() {}
+
+ // From ApplicationDelegate
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ connection->AddService<PexeLinker>(this);
+ return true;
+ }
+
+ // From InterfaceFactory
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<PexeLinker> request) override {
+ new StrongBindingPexeLinkerImpl(request.Pass());
+ }
+};
+
+} // namespace nacl
+} // namespace mojo
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunner runner(new mojo::nacl::MultiPexeLinker());
+ return runner.Run(application_request);
+}

Powered by Google App Engine
This is Rietveld 408576698