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

Unified Diff: services/nacl/nonsfi/content_handler_main_pexe.cc

Issue 1932713003: More SynchronousInterfacePtr conversion + some related pexe content handler cleanup. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/nacl/nonsfi/BUILD.gn ('k') | services/nacl/nonsfi/pnacl_compile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/nacl/nonsfi/content_handler_main_pexe.cc
diff --git a/services/nacl/nonsfi/content_handler_main_pexe.cc b/services/nacl/nonsfi/content_handler_main_pexe.cc
index d590b89f0650245dc9b933247339c9126e2efe17..7fcc2a10a6caf8772c4bdba56a006cdcfd395f4a 100644
--- a/services/nacl/nonsfi/content_handler_main_pexe.cc
+++ b/services/nacl/nonsfi/content_handler_main_pexe.cc
@@ -21,57 +21,11 @@
#include "mojo/public/cpp/bindings/synchronous_interface_ptr.h"
#include "mojo/services/files/interfaces/directory.mojom-sync.h"
#include "mojo/services/files/interfaces/files.mojom.h"
-#include "services/nacl/nonsfi/pnacl_compile.mojom.h"
-#include "services/nacl/nonsfi/pnacl_link.mojom.h"
+#include "services/nacl/nonsfi/pnacl_compile.mojom-sync.h"
+#include "services/nacl/nonsfi/pnacl_link.mojom-sync.h"
namespace nacl {
namespace content_handler {
-namespace {
-
-class CompilerUI {
- public:
- explicit CompilerUI(mojo::ScopedMessagePipeHandle handle) {
- compiler_.Bind(
- mojo::InterfaceHandle<mojo::nacl::PexeCompiler>(handle.Pass(), 0u));
- }
-
- // Synchronous method to compile pexe into object file.
- mojo::Array<mojo::String> CompilePexe(mojo::String pexe_file_path) {
- mojo::Array<mojo::String> output;
- compiler_->PexeCompile(
- pexe_file_path,
- [&output](mojo::Array<mojo::String> o) { output = o.Pass(); });
- CHECK(compiler_.WaitForIncomingResponse())
- << "Waiting for pexe compiler failed";
- return output;
- }
-
- private:
- mojo::nacl::PexeCompilerPtr compiler_;
-};
-
-class LinkerUI {
- public:
- explicit LinkerUI(mojo::ScopedMessagePipeHandle handle) {
- linker_.Bind(
- mojo::InterfaceHandle<mojo::nacl::PexeLinker>(handle.Pass(), 0u));
- }
-
- // Synchronous method to link object file into nexe.
- mojo::String LinkPexe(mojo::Array<mojo::String> object_file_paths) {
- mojo::String output;
- linker_->PexeLink(std::move(object_file_paths),
- [&output](mojo::String o) { output = o; });
- CHECK(linker_.WaitForIncomingResponse())
- << "Waiting for pexe linker failed";
- return output;
- }
-
- private:
- mojo::nacl::PexeLinkerPtr linker_;
-};
-
-} // namespace anonymous
class PexeContentHandler : public mojo::ApplicationDelegate,
public mojo::ContentHandlerFactory::Delegate {
@@ -82,9 +36,9 @@ class PexeContentHandler : public mojo::ApplicationDelegate,
// Overridden from ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override {
mojo::ConnectToService(app->shell(), "mojo:pnacl_compile",
- GetProxy(&compiler_init_));
+ GetSynchronousProxy(&compiler_init_));
mojo::ConnectToService(app->shell(), "mojo:pnacl_link",
- GetProxy(&linker_init_));
+ GetSynchronousProxy(&linker_init_));
mojo::ConnectToService(app->shell(), "mojo:files", GetProxy(&files_));
mojo::files::Error error = mojo::files::Error::INTERNAL;
files_->OpenFileSystem("app_persistent_cache",
@@ -136,28 +90,20 @@ class PexeContentHandler : public mojo::ApplicationDelegate,
int DoPexeTranslation(base::FilePath& pexe_file_path) {
// Compile the pexe into an object file
- mojo::ScopedMessagePipeHandle parent_compile_pipe;
- mojo::ScopedMessagePipeHandle child_compile_pipe;
- CHECK_EQ(CreateMessagePipe(nullptr, &parent_compile_pipe,
- &child_compile_pipe), MOJO_RESULT_OK)
- << "Could not create message pipe to compiler";
- compiler_init_->PexeCompilerStart(child_compile_pipe.Pass());
+ mojo::SynchronousInterfacePtr<mojo::nacl::PexeCompiler> compiler;
+ CHECK(compiler_init_->PexeCompilerStart(GetSynchronousProxy(&compiler)));
// Communicate with the compiler using a mojom interface.
- CompilerUI compiler_ui(parent_compile_pipe.Pass());
- mojo::Array<mojo::String> object_files =
- compiler_ui.CompilePexe(pexe_file_path.value());
+ mojo::Array<mojo::String> object_files;
+ CHECK(compiler->PexeCompile(pexe_file_path.value(), &object_files));
// Link the object file into a nexe
- mojo::ScopedMessagePipeHandle parent_link_pipe;
- mojo::ScopedMessagePipeHandle child_link_pipe;
- CHECK_EQ(CreateMessagePipe(nullptr, &parent_link_pipe, &child_link_pipe),
- MOJO_RESULT_OK) << "Could not create message pipe to linker";
- linker_init_->PexeLinkerStart(child_link_pipe.Pass());
+ mojo::SynchronousInterfacePtr<mojo::nacl::PexeLinker> linker;
+ CHECK(linker_init_->PexeLinkerStart(GetSynchronousProxy(&linker)));
// Communicate with the linker using a mojom interface.
- LinkerUI linker_ui(parent_link_pipe.Pass());
- mojo::String nexe_file = linker_ui.LinkPexe(std::move(object_files));
+ mojo::String nexe_file;
+ CHECK(linker->PexeLink(std::move(object_files), &nexe_file));
// Open the nexe file and launch it (with our mojo handle)
int nexe_fd = open(nexe_file.get().c_str(), O_RDONLY);
@@ -205,8 +151,8 @@ class PexeContentHandler : public mojo::ApplicationDelegate,
mojo::SynchronousInterfacePtr<mojo::files::Directory> nexe_cache_directory_;
mojo::files::FilesPtr files_;
mojo::ContentHandlerFactory content_handler_factory_;
- mojo::nacl::PexeCompilerInitPtr compiler_init_;
- mojo::nacl::PexeLinkerInitPtr linker_init_;
+ mojo::SynchronousInterfacePtr<mojo::nacl::PexeCompilerInit> compiler_init_;
+ mojo::SynchronousInterfacePtr<mojo::nacl::PexeLinkerInit> linker_init_;
DISALLOW_COPY_AND_ASSIGN(PexeContentHandler);
};
« no previous file with comments | « services/nacl/nonsfi/BUILD.gn ('k') | services/nacl/nonsfi/pnacl_compile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698