gecko-dev/ipc
Nicholas Nethercote 5f16fc9dc3 Bug 1447246 - Refactor ContentProcess::Init(). r=jimm
The current code is a bit of a mess. This patch does the following.

- Changes the processing from backwards to forwards. This avoids the need for
  all the `found` booleans, because if a flag is present multiple times, the
  last one will naturally override.

- Tightens up the checking. It now doesn't use assertions, but instead returns
  false if any of the options are missing arguments, or have malformed
  arguments, or any of the mandatory flags are missing. (It assumes that
  -appdir and -profile are optional.)

- Renames the loop variable `idx` as `i`.

- Changes `!strcmp(...)` to `strcmp(...) == 0`, because I find that clearer.

- Avoids a redundant nsCString when handling -appdir.

The patch also tweaks GeckoChildProcessHost::mGroupId, which was buggy. It
holds the appModelUserId argument, which XRE_InitChildProcess() always expects
is present in the command. But it's only set to a non-empty value in
InitWindowsGroupID(), which is only called for plugin processes. So in lots of
cases the appModelUserId argument was missing, and a different argument would
be interpreted as the appModelUserId argument (seemingly without noticeable ill
effect).

The patch changes things to mGroupId defaults to "-", which means it's always
present in the command.

Note: all this explains why the old code for ContentProcess::Init() started
processing from argument aArgc, instead of aArgc-1 as you might expect -- it
had to read one extra arg in order to see the argument following -appdir,
because XRE_InitChildProcess() was decrementing aArgc for the appModelUserId
argument even when that argument wasn't present. The new code for
ContentProcess::Init() doesn't have to read past aArgc-1 because the mGroupId
fix ensures the appModelUserId argument is always present.

MozReview-Commit-ID: 8a8k6ABYMgo

--HG--
extra : rebase_source : 70695125ee26e67af3337119f4dfc293a0dab74c
2018-03-16 12:23:10 +11:00
..
app Backed out 3 changesets (bug 1430857) for breaking tests on Windows Code Coverage builds a=backout 2018-02-07 15:02:58 +02:00
chromium Bug 1440199 - Part 3: Remove IPC shared memory IDs. r=froydnj 2018-02-20 15:09:12 -07:00
contentproc Bug 1330529 - Part 3: Protect DLL loads in wmain instead of waiting until PluginProcessChild::Init. r=jimm 2018-02-02 22:53:34 -08:00
glue Bug 1447246 - Refactor ContentProcess::Init(). r=jimm 2018-03-16 12:23:10 +11:00
ipdl Bug 1441324 - Move the input event messages from PAPZCTreeManager to PAPZInputBridge. r=froydnj,rhunt 2018-03-16 16:28:19 -04:00
mscom Bug 1445302 - Replace TArray.RemoveElementAt(TArray.Length() - 1) pattern with TArray.RemoveLastElement() or TArray.PopLastElement() r=froydnj 2018-03-13 14:51:33 +01:00
testshell Bug 1432992, part 1 - Remove definitions of Ci, Cr, Cc, and Cu. r=florian 2018-02-06 09:36:57 -08:00
moz.build Bug 1412258 - Get rid of ipc/dbus, r=smaug 2017-10-27 18:41:40 +02:00
pull-chromium.py