Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
|
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.
| |
| 5 #include <fcntl.h> | |
| 6 | |
| 7 #include "base/files/file_util.h" | |
| 8 #include "mojo/nacl/nonsfi/nexe_launcher_nonsfi.h" | |
| 9 #include "mojo/public/c/system/main.h" | |
| 10 #include "mojo/public/cpp/application/application_connection.h" | |
| 11 #include "mojo/public/cpp/application/application_delegate.h" | |
| 12 #include "mojo/public/cpp/application/application_runner.h" | |
| 13 #include "mojo/public/cpp/application/interface_factory.h" | |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 15 #include "services/nacl/pexe_translator.mojom.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 namespace nacl { | |
| 19 | |
| 20 class PexeTranslatorImpl : public PexeTranslator { | |
| 21 public: | |
| 22 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.
| |
| 23 // int nexe_fd = open("native_client/toolchain/linux_x86/pnacl_translator" | |
| 24 // "/translator/x86-32-nonsfi/bin/pnacl-llc.nexe", | |
| 25 int nexe_fd = open("sean_out/pnacl-llc.nexe", O_RDONLY); | |
| 26 if (nexe_fd < 0) | |
| 27 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.
| |
| 28 ::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.
| |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 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
| |
| 33 public: | |
| 34 explicit StrongBindingPexeTranslatorImpl(InterfaceRequest<PexeTranslator> | |
| 35 request) | |
| 36 : strong_binding_(this, request.Pass()) {} | |
| 37 | |
| 38 private: | |
| 39 StrongBinding<PexeTranslator> strong_binding_; | |
| 40 }; | |
| 41 | |
| 42 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
| |
| 43 public mojo::InterfaceFactory<PexeTranslator> { | |
| 44 public: | |
| 45 MultiPexeTranslator() {} | |
| 46 | |
| 47 // From ApplicationDelegate | |
| 48 bool ConfigureIncomingConnection( | |
| 49 mojo::ApplicationConnection* connection) override { | |
| 50 connection->AddService<PexeTranslator>(this); | |
| 51 return true; | |
| 52 } | |
| 53 | |
| 54 // From InterfaceFactory | |
| 55 void Create(mojo::ApplicationConnection* connection, | |
| 56 mojo::InterfaceRequest<PexeTranslator> request) override { | |
| 57 new StrongBindingPexeTranslatorImpl(request.Pass()); | |
| 58 } | |
| 59 }; | |
| 60 | |
| 61 } // namespace nacl | |
| 62 } // namespace mojo | |
| 63 | |
| 64 MojoResult MojoMain(MojoHandle application_request) { | |
| 65 mojo::ApplicationRunner runner(new mojo::nacl::MultiPexeTranslator()); | |
| 66 return runner.Run(application_request); | |
| 67 } | |
| OLD | NEW |