Implement the infrastructure of creating WorkerFetchContext in worker global scope.

This CL implements the infrastructure of creating WorkerFetchContext in worker
global scope of Dedicated Worker, Shared Worker and Service Worker.

1. WorkerFetchContext for Dedicated Worker
 1.1. DedicatedWorkerMessagingProxyProviderImpl::CreateWorkerMessagingProxy()
      calls RenderFrameImpl::CreateWorkerFetchContext() on the main thread.
 1.2. RenderFrameImpl::CreateWorkerFetchContext() gets the interface of
      WorkerURLLoaderFactoryProvider which is implemented in the browser process
      as WorkerURLLoaderFactoryProviderImpl, and creates a
      WorkerFetchContextImpl with the interface. WorkerFetchContextImpl keeps
      the interface as |provider_info_| until InitializeOnWorkerThread() is
      called on the worker thread.
 1.3. RenderFrameImpl::CreateWorkerFetchContext() copies the service worker
      state (ServiceWorkerProviderID and IsControlledByServiceWorker) of the
      frame to the WorkerFetchContextImpl.
 1.4. ProvideWorkerFetchContextToWorker() creates a WorkerFetchContextHolder
      which holds the WorkerFetchContextImpl and provides it to the
      WorkerClients using the Supplement mechanism.
 1.5. After the worker thread is created, the WorkerClients is reattached to
      the worker thread in the constructor of WorkerGlobalScope.
 1.6. WorkerGlobalScope::FetchContext() will be called to get the
      WorkerFetchContext in ThreadableLoader::Create() When fetch() is called in
      the worker thread. (This is not in this CL yet.)
 1.7. When WorkerGlobalScope::FetchContext() is called for the first time,
      WorkerFetchContext::Create() is called to get the WorkerFetchContextHolder
      from the WorkerClients and take the WorkerFetchContextImpl from it and
      create the WorkerFetchContext.
 1.8. The constructor of WorkerFetchContext calls WorkerFetchContextImpl::
      InitializeOnWorkerThread() which creates a ResourceDispatcher and calls
      WorkerURLLoaderFactoryProviderImpl::GetURLLoaderFactoryAndRegisterClient()
      in the browser process via mojo IPC with a request of URLLoaderFactory and
      the pointer (ServiceWorkerWorkerClient) of itself.
 1.9. WorkerURLLoaderFactoryProviderImpl::GetURLLoaderFactoryAndRegisterClient()
      binds the request of URLLoaderFactory to ResourceMessageFilter and calls
      ServiceWorkerContextWrapper::BindWorkerFetchContext() to bind the
      ServiceWorkerWorkerClient (the pointer to WorkerFetchContextImpl in the
      worker thread) with the parent frame's ServiceWorkerProviderHost. When the
      controller service worker of the ServiceWorkerProviderHost changed,
      WorkerFetchContextImpl::SetControllerServiceWorker() will be called via
      mojo. So WorkerFetchContextImpl::IsControlledByServiceWorker() can return
      the correct status.
 1.10. WorkerFetchContext::CreateURLLoader() calls WorkerFetchContextImpl::
       CreateURLLoader() which returns a new WebURLLoaderImpl with the pointer
       of URLLoaderFactory.

2. WorkerFetchContext for Shared Worker is created almost same as the Dedicated
   Worker. The only difference is that CreateWorkerFetchContext() is called in
   WebSharedWorkerImpl::OnScriptLoaderFinished().

3. WorkerFetchContext for Service Worker
 3.1. WebEmbeddedWorkerImpl::StartWorkerThread() calls
      ServiceWorkerContextClient::CreateServiceWorkerFetchContext() on the main
      thread.
 3.2. ServiceWorkerContextClient::CreateServiceWorkerFetchContext() gets the
      interface of WorkerURLLoaderFactoryProvider which is implemented in the
      browser process as WorkerURLLoaderFactoryProviderImpl, and creates a
      ServiceWorkerFetchContextImpl with the interface.
      ServiceWorkerFetchContextImpl keeps the interface as |provider_info_|
      until InitializeOnWorkerThread() is called on the worker thread.
 3.3. In WebEmbeddedWorkerImpl::StartWorkerThread(), the fetch context related
      information (ex: DataSaverEnabled) is set to the
      ServiceWorkerFetchContextImpl. (This is not in this CL yet.)
 3.4. Same as 1.4. ProvideWorkerFetchContextToWorker() creates a
      WorkerFetchContextHolder which holds the ServiceWorkerFetchContextImpl and
      provides it to the WorkerClientsusing the Supplement mechanism.
 3.5. Same as 1.5. the WorkerClients is reattached to the worker thread.
 3.6. Same as 1.6.
 3.7. Same as 1.7. When WorkerGlobalScope::FetchContext() is called for the
      first time, WorkerFetchContext::Create() is called to get the
      WorkerFetchContextHolder from the WorkerClients and take the
      ServiceWorkerFetchContextImpl from it and create the WorkerFetchContext.
 3.8. The constructor of WorkerFetchContext calls ServiceWorkerFetchContextImpl
      ::InitializeOnWorkerThread() which creates a ResourceDispatcher and calls
      WorkerURLLoaderFactoryProviderImpl::GetURLLoaderFactory() in the browser
      process via mojo IPC with a request of URLLoaderFactory.
 3.9. WorkerURLLoaderFactoryProviderImpl::GetURLLoaderFactory() binds the
      request of URLLoaderFactory to ResourceMessageFilter.
 3.10. WorkerFetchContext::CreateURLLoader() calls
       ServiceWorkerFetchContextImpl::CreateURLLoader() which returns a new
       WebURLLoaderImpl with the pointer of URLLoaderFactory.

BUG=443374

Review-Url: https://codereview.chromium.org/2804843005
Cr-Commit-Position: refs/heads/master@{#467200}
44 files changed