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

Unified Diff: shell/out_of_process_native_runner.cc

Issue 1341873002: Enabling 64-bit mojo shell to launch 32-bit child to handle nonsfi content. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Anonymous namespaces and modified target names Created 5 years, 3 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 | « shell/child_process_host_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/out_of_process_native_runner.cc
diff --git a/shell/out_of_process_native_runner.cc b/shell/out_of_process_native_runner.cc
index 39cf1f7003abfef747ed59f21afdebf9d08b04ab..9ac1dbd04f1e0382ec0e8a2c6a861550cc989f5e 100644
--- a/shell/out_of_process_native_runner.cc
+++ b/shell/out_of_process_native_runner.cc
@@ -4,14 +4,45 @@
#include "shell/out_of_process_native_runner.h"
+#include <elf.h>
+#include <string>
+
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/files/file_util.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "shell/child_controller.mojom.h"
#include "shell/child_process_host.h"
#include "shell/in_process_native_runner.h"
+namespace {
+
+// Determines if content handler must be run as 32 bit application
+// based on elf header. Returns false on error.
+bool Require32Bit(const base::FilePath& app_path) {
+ if (sizeof(void*) == 4) {
+ // CPU arch is already 32 bits
+ return true;
+ } else {
+ char data[EI_NIDENT];
+ // Read e_ident from the elf file
+ if (sizeof(data) != ReadFile(app_path, data, sizeof(data))) {
+ DCHECK(false);
+ return false;
+ }
+ // Check the magic elf number
+ if (memcmp(data, ELFMAG, SELFMAG)) {
+ DCHECK(false);
+ return false;
+ }
+ // Identify the architecture required
+ return data[EI_CLASS] == ELFCLASS32;
+ }
+}
+
+} // namespace
+
namespace shell {
OutOfProcessNativeRunner::OutOfProcessNativeRunner(Context* context)
@@ -37,7 +68,7 @@ void OutOfProcessNativeRunner::Start(
app_completed_callback_ = app_completed_callback;
child_process_host_.reset(new ChildProcessHost(context_));
- child_process_host_->Start();
+ child_process_host_->Start(Require32Bit(app_path));
// TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe.
child_process_host_->StartApp(
« no previous file with comments | « shell/child_process_host_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698