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

Side by Side Diff: services/nacl/nonsfi/pnacl_link.cc

Issue 2019743002: Yet more ApplicationDelegate/ApplicationRunner conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « services/nacl/nonsfi/pnacl_compile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory>
6
7 #include "base/logging.h" 5 #include "base/logging.h"
8 #include "mojo/nacl/nonsfi/file_util.h" 6 #include "mojo/nacl/nonsfi/file_util.h"
9 #include "mojo/nacl/nonsfi/nexe_launcher_nonsfi.h" 7 #include "mojo/nacl/nonsfi/nexe_launcher_nonsfi.h"
10 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_impl_base.h"
12 #include "mojo/public/cpp/application/application_runner.h" 10 #include "mojo/public/cpp/application/run_application.h"
13 #include "mojo/public/cpp/application/service_provider_impl.h" 11 #include "mojo/public/cpp/application/service_provider_impl.h"
14 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
15 #include "services/nacl/nonsfi/kLdNexe.h" 13 #include "services/nacl/nonsfi/kLdNexe.h"
16 #include "services/nacl/nonsfi/pnacl_link.mojom.h" 14 #include "services/nacl/nonsfi/pnacl_link.mojom.h"
17 15
18 namespace mojo { 16 namespace mojo {
19 namespace nacl { 17 namespace nacl {
20 18
21 class PexeLinkerImpl : public PexeLinkerInit { 19 class PexeLinkerImpl : public PexeLinkerInit {
22 public: 20 public:
23 void PexeLinkerStart(InterfaceRequest<PexeLinker> linker_request) override { 21 void PexeLinkerStart(InterfaceRequest<PexeLinker> linker_request) override {
24 int nexe_fd = ::nacl::DataToTempFileDescriptor(::nacl::kLdNexe); 22 int nexe_fd = ::nacl::DataToTempFileDescriptor(::nacl::kLdNexe);
25 CHECK(nexe_fd >= 0) << "Could not open linker nexe"; 23 CHECK(nexe_fd >= 0) << "Could not open linker nexe";
26 ::nacl::MojoLaunchNexeNonsfi( 24 ::nacl::MojoLaunchNexeNonsfi(
27 nexe_fd, linker_request.PassMessagePipe().release().value(), 25 nexe_fd, linker_request.PassMessagePipe().release().value(),
28 true /* enable_translate_irt */); 26 true /* enable_translate_irt */);
29 } 27 }
30 }; 28 };
31 29
32 class StrongBindingPexeLinkerImpl : public PexeLinkerImpl { 30 class StrongBindingPexeLinkerImpl : public PexeLinkerImpl {
33 public: 31 public:
34 explicit StrongBindingPexeLinkerImpl(InterfaceRequest<PexeLinkerInit> request) 32 explicit StrongBindingPexeLinkerImpl(InterfaceRequest<PexeLinkerInit> request)
35 : strong_binding_(this, request.Pass()) {} 33 : strong_binding_(this, request.Pass()) {}
36 34
37 private: 35 private:
38 StrongBinding<PexeLinkerInit> strong_binding_; 36 StrongBinding<PexeLinkerInit> strong_binding_;
39 }; 37 };
40 38
41 class MultiPexeLinker : public ApplicationDelegate { 39 class MultiPexeLinker : public ApplicationImplBase {
42 public: 40 public:
43 MultiPexeLinker() {} 41 MultiPexeLinker() {}
44 42
45 // From ApplicationDelegate 43 // From ApplicationImplBase
46 bool ConfigureIncomingConnection( 44 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override {
47 ServiceProviderImpl* service_provider_impl) override {
48 service_provider_impl->AddService<PexeLinkerInit>( 45 service_provider_impl->AddService<PexeLinkerInit>(
49 [](const ConnectionContext& connection_context, 46 [](const ConnectionContext& connection_context,
50 InterfaceRequest<PexeLinkerInit> request) { 47 InterfaceRequest<PexeLinkerInit> request) {
51 new StrongBindingPexeLinkerImpl(request.Pass()); 48 new StrongBindingPexeLinkerImpl(request.Pass());
52 }); 49 });
53 return true; 50 return true;
54 } 51 }
55 }; 52 };
56 53
57 } // namespace nacl 54 } // namespace nacl
58 } // namespace mojo 55 } // namespace mojo
59 56
60 MojoResult MojoMain(MojoHandle application_request) { 57 MojoResult MojoMain(MojoHandle application_request) {
61 mojo::ApplicationRunner runner(std::unique_ptr<mojo::nacl::MultiPexeLinker>( 58 mojo::nacl::MultiPexeLinker multi_pexe_linker;
62 new mojo::nacl::MultiPexeLinker())); 59 return mojo::RunMainApplication(application_request, &multi_pexe_linker);
63 return runner.Run(application_request);
64 } 60 }
OLDNEW
« no previous file with comments | « services/nacl/nonsfi/pnacl_compile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698