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

Unified Diff: services/nacl/pexe_translator_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
« services/nacl/pexe_linker_app.cc ('K') | « services/nacl/pexe_translator.mojom ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/nacl/pexe_translator_app.cc
diff --git a/services/nacl/pexe_translator_app.cc b/services/nacl/pexe_translator_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..95a9d9f671800e76867cd7f5905806fa5cd218cc
--- /dev/null
+++ b/services/nacl/pexe_translator_app.cc
@@ -0,0 +1,67 @@
+// 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.
+
Mark Seaborn 2015/10/20 22:28:58 Nit: Can you name this using similar naming to the
Sean Klein 2015/10/22 21:50:01 Done.
+#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_translator.mojom.h"
+
+namespace mojo {
+namespace nacl {
+
+class PexeTranslatorImpl : public PexeTranslator {
+ public:
+ void PexeTranslate(ScopedMessagePipeHandle handle) override {
Mark Seaborn 2015/10/20 22:28:58 Nit: fix indentation -- this is indented by 3
Sean Klein 2015/10/22 21:50:01 Done.
+// int nexe_fd = open("native_client/toolchain/linux_x86/pnacl_translator"
+// "/translator/x86-32-nonsfi/bin/pnacl-llc.nexe",
+ int nexe_fd = open("sean_out/pnacl-llc.nexe", O_RDONLY);
+ if (nexe_fd < 0)
+ LOG(FATAL) << "Could not open compiler nexe";
Mark Seaborn 2015/10/20 22:28:58 It would be nice to report the filename in these e
Sean Klein 2015/10/22 21:50:01 Done.
+ ::nacl::MojoLaunchNexeNonsfi(nexe_fd, handle.Pass().get().value());
Mark Seaborn 2015/10/20 22:28:58 I think you can do handle.release().value() instea
Sean Klein 2015/10/22 21:50:01 Done.
+ }
+};
+
+class StrongBindingPexeTranslatorImpl : public PexeTranslatorImpl {
Mark Seaborn 2015/10/20 22:28:58 How come this is a separate class from PexeTransla
Sean Klein 2015/10/22 21:50:01 This is based on the echo server's model here: htt
+ public:
+ explicit StrongBindingPexeTranslatorImpl(InterfaceRequest<PexeTranslator>
+ request)
+ : strong_binding_(this, request.Pass()) {}
+
+ private:
+ StrongBinding<PexeTranslator> strong_binding_;
+};
+
+class MultiPexeTranslator : public mojo::ApplicationDelegate,
Mark Seaborn 2015/10/20 22:28:58 What does the "Multi" part mean? If we try to tra
Sean Klein 2015/10/22 21:50:01 As I mentioned earlier, I followed a similar struc
+ public mojo::InterfaceFactory<PexeTranslator> {
+ public:
+ MultiPexeTranslator() {}
+
+ // From ApplicationDelegate
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ connection->AddService<PexeTranslator>(this);
+ return true;
+ }
+
+ // From InterfaceFactory
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<PexeTranslator> request) override {
+ new StrongBindingPexeTranslatorImpl(request.Pass());
+ }
+};
+
+} // namespace nacl
+} // namespace mojo
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunner runner(new mojo::nacl::MultiPexeTranslator());
+ return runner.Run(application_request);
+}
« services/nacl/pexe_linker_app.cc ('K') | « services/nacl/pexe_translator.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698