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 | |
| 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/pnacl_link.mojom.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 namespace nacl { | |
| 19 | |
| 20 class PexeLinkerImpl : public PexeLinkerInit { | |
| 21 public: | |
| 22 void PexeLinkerStart(ScopedMessagePipeHandle handle) override { | |
| 23 char path[] = "native_client/toolchain/linux_x86/pnacl_translator" | |
| 24 "/translator/x86-32-nonsfi/bin/ld.nexe"; | |
|
Petr Hosek
2015/10/27 15:07:52
ditto
Sean Klein
2015/10/28 17:02:41
Done.
| |
| 25 int nexe_fd = open(path, O_RDONLY); | |
| 26 if (nexe_fd < 0) | |
| 27 LOG(FATAL) << "Could not open linker nexe: " << path; | |
| 28 ::nacl::MojoLaunchNexeNonsfi(nexe_fd, | |
| 29 handle.release().value(), | |
| 30 true /* enable_translate_irt */); | |
| 31 } | |
| 32 }; | |
| 33 | |
| 34 class StrongBindingPexeLinkerImpl : public PexeLinkerImpl { | |
| 35 public: | |
| 36 explicit StrongBindingPexeLinkerImpl(InterfaceRequest<PexeLinkerInit> request) | |
| 37 : strong_binding_(this, request.Pass()) {} | |
| 38 | |
| 39 private: | |
| 40 StrongBinding<PexeLinkerInit> strong_binding_; | |
| 41 }; | |
| 42 | |
| 43 class MultiPexeLinker : public mojo::ApplicationDelegate, | |
| 44 public mojo::InterfaceFactory<PexeLinkerInit> { | |
| 45 public: | |
| 46 MultiPexeLinker() {} | |
| 47 | |
| 48 // From ApplicationDelegate | |
| 49 bool ConfigureIncomingConnection( | |
| 50 mojo::ApplicationConnection* connection) override { | |
| 51 connection->AddService<PexeLinkerInit>(this); | |
| 52 return true; | |
| 53 } | |
| 54 | |
| 55 // From InterfaceFactory | |
| 56 void Create(mojo::ApplicationConnection* connection, | |
| 57 mojo::InterfaceRequest<PexeLinkerInit> request) override { | |
| 58 new StrongBindingPexeLinkerImpl(request.Pass()); | |
| 59 } | |
| 60 }; | |
| 61 | |
| 62 } // namespace nacl | |
| 63 } // namespace mojo | |
| 64 | |
| 65 MojoResult MojoMain(MojoHandle application_request) { | |
| 66 mojo::ApplicationRunner runner(new mojo::nacl::MultiPexeLinker()); | |
| 67 return runner.Run(application_request); | |
| 68 } | |
| OLD | NEW |