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

Side by Side Diff: services/nacl/pnacl_link.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: Added Mojom interface to communicate with translation nexes Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698