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

Side by Side Diff: services/nacl/content_handler_main_nonsfi.cc

Issue 1371413003: Refactored launching of nexes to separate file. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
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 <fcntl.h> 5 #include <fcntl.h>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "mojo/application/application_runner_chromium.h" 8 #include "mojo/application/application_runner_chromium.h"
9 #include "mojo/application/content_handler_factory.h" 9 #include "mojo/application/content_handler_factory.h"
10 #include "mojo/data_pipe_utils/data_pipe_utils.h" 10 #include "mojo/data_pipe_utils/data_pipe_utils.h"
11 #include "mojo/message_pump/message_pump_mojo.h" 11 #include "mojo/message_pump/message_pump_mojo.h"
12 #include "mojo/nacl/irt_mojo_nonsfi.h" 12 #include "mojo/nacl/nexe_launcher_nonsfi.h"
13 #include "mojo/public/c/system/main.h" 13 #include "mojo/public/c/system/main.h"
14 #include "mojo/public/cpp/application/application_impl.h" 14 #include "mojo/public/cpp/application/application_impl.h"
15 #include "native_client/src/public/irt_core.h"
16 #include "native_client/src/public/nonsfi/elf_loader.h"
17 15
18 namespace nacl { 16 namespace nacl {
19 namespace content_handler { 17 namespace content_handler {
20 18
21 class NaClContentHandler : public mojo::ApplicationDelegate, 19 class NaClContentHandler : public mojo::ApplicationDelegate,
22 public mojo::ContentHandlerFactory::Delegate { 20 public mojo::ContentHandlerFactory::Delegate {
23 public: 21 public:
24 NaClContentHandler() : content_handler_factory_(this) {} 22 NaClContentHandler() : content_handler_factory_(this) {}
25 23
26 private: 24 private:
(...skipping 25 matching lines...) Expand all
52 LOG(FATAL) << "Could not open the stream pointer's file descriptor"; 50 LOG(FATAL) << "Could not open the stream pointer's file descriptor";
53 } 51 }
54 fd = dup(fd); 52 fd = dup(fd);
55 if (fd == -1) { 53 if (fd == -1) {
56 LOG(FATAL) << "Could not dup the file descriptor"; 54 LOG(FATAL) << "Could not dup the file descriptor";
57 } 55 }
58 if (fclose(nexe_file_stream)) { 56 if (fclose(nexe_file_stream)) {
59 LOG(FATAL) << "Failed to close temp file"; 57 LOG(FATAL) << "Failed to close temp file";
60 } 58 }
61 59
62 // Run -- also, closes the fd, removing the temp file. 60 MojoHandle h = application_request.PassMessagePipe().release().value();
63 uintptr_t entry = NaClLoadElfFile(fd); 61 // launch_nexe_nonsfi takes ownership of the fd.
64 62 launch_nexe_nonsfi(fd, h);
65 MojoSetInitialHandle(
66 application_request.PassMessagePipe().release().value());
67 int argc = 1;
68 char* argvp = const_cast<char*>("NaClMain");
69 char* envp = nullptr;
70 nacl_irt_nonsfi_entry(argc, &argvp, &envp,
71 reinterpret_cast<nacl_entry_func_t>(entry),
72 MojoIrtNonsfiQuery);
73 abort();
74 NOTREACHED();
75 } 63 }
76 64
77 mojo::ContentHandlerFactory content_handler_factory_; 65 mojo::ContentHandlerFactory content_handler_factory_;
78 66
79 DISALLOW_COPY_AND_ASSIGN(NaClContentHandler); 67 DISALLOW_COPY_AND_ASSIGN(NaClContentHandler);
80 }; 68 };
81 69
82 } // namespace content_handler 70 } // namespace content_handler
83 } // namespace nacl 71 } // namespace nacl
84 72
85 MojoResult MojoMain(MojoHandle application_request) { 73 MojoResult MojoMain(MojoHandle application_request) {
86 mojo::ApplicationRunnerChromium runner( 74 mojo::ApplicationRunnerChromium runner(
87 new nacl::content_handler::NaClContentHandler()); 75 new nacl::content_handler::NaClContentHandler());
88 return runner.Run(application_request); 76 return runner.Run(application_request);
89 } 77 }
OLDNEW
« mojo/nacl/nexe_launcher_nonsfi.h ('K') | « mojo/nacl/nexe_launcher_nonsfi.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698