Index: content/zygote/zygote_linux.cc |
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc |
index 8e66788091a4d46e053586956381a7839fa24e81..0d1fa73fa71cb182640f9d2fdba78b1e65646faa 100644 |
--- a/content/zygote/zygote_linux.cc |
+++ b/content/zygote/zygote_linux.cc |
@@ -185,24 +185,24 @@ |
PickleIterator iter(pickle); |
int kind; |
- if (iter.ReadInt(&kind)) { |
+ if (pickle.ReadInt(&iter, &kind)) { |
switch (kind) { |
case kZygoteCommandFork: |
// This function call can return multiple times, once per fork(). |
- return HandleForkRequest(fd, iter, fds.Pass()); |
+ return HandleForkRequest(fd, pickle, iter, fds.Pass()); |
case kZygoteCommandReap: |
if (!fds.empty()) |
break; |
- HandleReapRequest(fd, iter); |
+ HandleReapRequest(fd, pickle, iter); |
return false; |
case kZygoteCommandGetTerminationStatus: |
if (!fds.empty()) |
break; |
- HandleGetTerminationStatus(fd, iter); |
+ HandleGetTerminationStatus(fd, pickle, iter); |
return false; |
case kZygoteCommandGetSandboxStatus: |
- HandleGetSandboxStatus(fd, iter); |
+ HandleGetSandboxStatus(fd, pickle, iter); |
return false; |
case kZygoteCommandForkRealPID: |
// This shouldn't happen in practice, but some failure paths in |
@@ -223,10 +223,11 @@ |
// TODO(jln): remove callers to this broken API. See crbug.com/274855. |
void Zygote::HandleReapRequest(int fd, |
+ const Pickle& pickle, |
PickleIterator iter) { |
base::ProcessId child; |
- if (!iter.ReadInt(&child)) { |
+ if (!pickle.ReadInt(&iter, &child)) { |
LOG(WARNING) << "Error parsing reap request from browser"; |
return; |
} |
@@ -306,11 +307,13 @@ |
} |
void Zygote::HandleGetTerminationStatus(int fd, |
+ const Pickle& pickle, |
PickleIterator iter) { |
bool known_dead; |
base::ProcessHandle child_requested; |
- if (!iter.ReadBool(&known_dead) || !iter.ReadInt(&child_requested)) { |
+ if (!pickle.ReadBool(&iter, &known_dead) || |
+ !pickle.ReadInt(&iter, &child_requested)) { |
LOG(WARNING) << "Error parsing GetTerminationStatus request " |
<< "from browser"; |
return; |
@@ -425,9 +428,9 @@ |
PickleIterator iter(pickle); |
int kind; |
- CHECK(iter.ReadInt(&kind)); |
+ CHECK(pickle.ReadInt(&iter, &kind)); |
CHECK(kind == kZygoteCommandForkRealPID); |
- CHECK(iter.ReadInt(&real_pid)); |
+ CHECK(pickle.ReadInt(&iter, &real_pid)); |
} |
// Fork failed. |
@@ -463,7 +466,8 @@ |
return real_pid; |
} |
-base::ProcessId Zygote::ReadArgsAndFork(PickleIterator iter, |
+base::ProcessId Zygote::ReadArgsAndFork(const Pickle& pickle, |
+ PickleIterator iter, |
ScopedVector<base::ScopedFD> fds, |
std::string* uma_name, |
int* uma_sample, |
@@ -477,21 +481,21 @@ |
const std::string channel_id_prefix = std::string("--") |
+ switches::kProcessChannelID + std::string("="); |
- if (!iter.ReadString(&process_type)) |
- return -1; |
- if (!iter.ReadInt(&argc)) |
+ if (!pickle.ReadString(&iter, &process_type)) |
+ return -1; |
+ if (!pickle.ReadInt(&iter, &argc)) |
return -1; |
for (int i = 0; i < argc; ++i) { |
std::string arg; |
- if (!iter.ReadString(&arg)) |
+ if (!pickle.ReadString(&iter, &arg)) |
return -1; |
args.push_back(arg); |
if (arg.compare(0, channel_id_prefix.length(), channel_id_prefix) == 0) |
channel_id = arg.substr(channel_id_prefix.length()); |
} |
- if (!iter.ReadInt(&numfds)) |
+ if (!pickle.ReadInt(&iter, &numfds)) |
return -1; |
if (numfds != static_cast<int>(fds.size())) |
return -1; |
@@ -504,7 +508,7 @@ |
// Remaining FDs are for the global descriptor mapping. |
for (int i = 1; i < numfds; ++i) { |
base::GlobalDescriptors::Key key; |
- if (!iter.ReadUInt32(&key)) |
+ if (!pickle.ReadUInt32(&iter, &key)) |
return -1; |
mapping.push_back(std::make_pair(key, fds[i]->get())); |
} |
@@ -549,13 +553,14 @@ |
} |
bool Zygote::HandleForkRequest(int fd, |
+ const Pickle& pickle, |
PickleIterator iter, |
ScopedVector<base::ScopedFD> fds) { |
std::string uma_name; |
int uma_sample; |
int uma_boundary_value; |
base::ProcessId child_pid = ReadArgsAndFork( |
- iter, fds.Pass(), &uma_name, &uma_sample, &uma_boundary_value); |
+ pickle, iter, fds.Pass(), &uma_name, &uma_sample, &uma_boundary_value); |
if (child_pid == 0) |
return true; |
// If there's no UMA report for this particular fork, then check if any |
@@ -579,6 +584,7 @@ |
} |
bool Zygote::HandleGetSandboxStatus(int fd, |
+ const Pickle& pickle, |
PickleIterator iter) { |
if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
sizeof(sandbox_flags_)) { |