Add a ProcessIdentifier, vended from the UI process, to each child process
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Dec 2017 05:56:29 +0000 (05:56 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Dec 2017 05:56:29 +0000 (05:56 +0000)
commitf27f607663845a1407d0327870328468edef424e
treeb1169c16213831cd6a45979b1411cf8f4784c8d5
parent1af765957245c7b2351c05f7a155b5ae5687c277
Add a ProcessIdentifier, vended from the UI process, to each child process
https://bugs.webkit.org/show_bug.cgi?id=181155

Reviewed by Brent Fulgham.

Source/WebCore:

No new tests (Not yet testable)

More than once we've needed to create an identifier for an object that is unique across
all processes no matter which process it came from.

Sometimes we have an object or proxy object to the UI, Storage, or Network process
that allows us to augment a process-unique identifier to be globally unique. Due to multiple
sessions even this isn't good enough. Other times we have to create more hair-brained solutions.

In upcoming MessagePort work (Next step is https://bugs.webkit.org/show_bug.cgi?id=181172)
there was no truly workable solution for this.

By introducing a new ProcessIdentifier to each WK2 child processes that is guaranteed to be
unique over the run of a given UI process, we can easily create an object in any process and
identify it uniquely across all processes.

Obviously "process identifier" brings to mind a processes PID but that isn't good enough.
The number of PIDs on the system is fairly low and they are global across all
processes on the system. It is easy to see how a given UI process that runs for long enough
(such as a web browser that the user rarely quits) will start to run in to recycled PIDs,
therefore breaking the uniqueness guarantee that is required.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/Process.cpp: Added.
(WebCore::Process::setIdentifier): Sets the process-wise identifier (to be used during WK2
  child process initialization)
(WebCore::Process::identifier): Get the process-wide identifier.
* platform/Process.h: Added.

Source/WebKit:

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::initialize): Set the process-wide identifier if the initialization
  parameters have it. Cocoa ASSERTS it exists; non-Cocoa platforms will have to figure this
  out soon.
* Shared/ChildProcess.h:

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::getProcessIdentifier):

* UIProcess/ChildProcessProxy.cpp:
(WebKit::ChildProcessProxy::getLaunchOptions):
* UIProcess/ChildProcessProxy.h:
(WebKit::ChildProcessProxy::coreProcessIdentifier const):

* UIProcess/Launcher/ProcessLauncher.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/Process.cpp [new file with mode: 0644]
Source/WebCore/platform/Process.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/Shared/ChildProcess.cpp
Source/WebKit/Shared/ChildProcess.h
Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h
Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm
Source/WebKit/UIProcess/ChildProcessProxy.cpp
Source/WebKit/UIProcess/ChildProcessProxy.h
Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm