Commit fde92c70 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Tweak some documentation.

* Add //static annotation for some static functions.
* "WebEmbeddedWorkerInstance" doesn't exist, replace with WebEmbeddedWorker
or delete.
* Clarify ServiceWorkerNetworkProvider documentation.

Change-Id: Id540473565059c1c5aadeffd3bb0ee136fd9e5b1
Reviewed-on: https://chromium-review.googlesource.com/746508Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513015}
parent 89d27148
...@@ -219,8 +219,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost ...@@ -219,8 +219,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// listening to it. // listening to it.
void DisassociateRegistration(); void DisassociateRegistration();
// Returns a handler for a request, the handler may return nullptr if // Returns a handler for a request. May return nullptr if the request doesn't
// the request doesn't require special handling. // require special handling.
std::unique_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( std::unique_ptr<ServiceWorkerRequestHandler> CreateRequestHandler(
network::mojom::FetchRequestMode request_mode, network::mojom::FetchRequestMode request_mode,
network::mojom::FetchCredentialsMode credentials_mode, network::mojom::FetchCredentialsMode credentials_mode,
......
...@@ -62,7 +62,8 @@ class ServiceWorkerRequestInterceptor ...@@ -62,7 +62,8 @@ class ServiceWorkerRequestInterceptor
} // namespace } // namespace
// PlzNavigate // PlzNavigate:
// static
void ServiceWorkerRequestHandler::InitializeForNavigation( void ServiceWorkerRequestHandler::InitializeForNavigation(
net::URLRequest* request, net::URLRequest* request,
ServiceWorkerNavigationHandleCore* navigation_handle_core, ServiceWorkerNavigationHandleCore* navigation_handle_core,
...@@ -173,6 +174,7 @@ ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( ...@@ -173,6 +174,7 @@ ServiceWorkerRequestHandler::InitializeForNavigationNetworkService(
return base::WrapUnique<URLLoaderRequestHandler>(handler.release()); return base::WrapUnique<URLLoaderRequestHandler>(handler.release());
} }
// static
void ServiceWorkerRequestHandler::InitializeHandler( void ServiceWorkerRequestHandler::InitializeHandler(
net::URLRequest* request, net::URLRequest* request,
ServiceWorkerContextWrapper* context_wrapper, ServiceWorkerContextWrapper* context_wrapper,
...@@ -215,12 +217,14 @@ void ServiceWorkerRequestHandler::InitializeHandler( ...@@ -215,12 +217,14 @@ void ServiceWorkerRequestHandler::InitializeHandler(
request->SetUserData(&kUserDataKey, std::move(handler)); request->SetUserData(&kUserDataKey, std::move(handler));
} }
// static
ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
const net::URLRequest* request) { const net::URLRequest* request) {
return static_cast<ServiceWorkerRequestHandler*>( return static_cast<ServiceWorkerRequestHandler*>(
request->GetUserData(&kUserDataKey)); request->GetUserData(&kUserDataKey));
} }
// static
std::unique_ptr<net::URLRequestInterceptor> std::unique_ptr<net::URLRequestInterceptor>
ServiceWorkerRequestHandler::CreateInterceptor( ServiceWorkerRequestHandler::CreateInterceptor(
ResourceContext* resource_context) { ResourceContext* resource_context) {
...@@ -228,6 +232,7 @@ ServiceWorkerRequestHandler::CreateInterceptor( ...@@ -228,6 +232,7 @@ ServiceWorkerRequestHandler::CreateInterceptor(
new ServiceWorkerRequestInterceptor(resource_context)); new ServiceWorkerRequestInterceptor(resource_context));
} }
// static
bool ServiceWorkerRequestHandler::IsControlledByServiceWorker( bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
const net::URLRequest* request) { const net::URLRequest* request) {
ServiceWorkerRequestHandler* handler = GetHandler(request); ServiceWorkerRequestHandler* handler = GetHandler(request);
...@@ -237,6 +242,7 @@ bool ServiceWorkerRequestHandler::IsControlledByServiceWorker( ...@@ -237,6 +242,7 @@ bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
handler->provider_host_->running_hosted_version(); handler->provider_host_->running_hosted_version();
} }
// static
ServiceWorkerProviderHost* ServiceWorkerRequestHandler::GetProviderHost( ServiceWorkerProviderHost* ServiceWorkerRequestHandler::GetProviderHost(
const net::URLRequest* request) { const net::URLRequest* request) {
ServiceWorkerRequestHandler* handler = GetHandler(request); ServiceWorkerRequestHandler* handler = GetHandler(request);
......
...@@ -33,7 +33,7 @@ class ServiceWorkerContextClient; ...@@ -33,7 +33,7 @@ class ServiceWorkerContextClient;
// This class deletes itself when the worker stops (or if start failed). The // This class deletes itself when the worker stops (or if start failed). The
// ownership graph is a cycle like this: // ownership graph is a cycle like this:
// EmbeddedWorkerInstanceClientImpl -(owns)-> WorkerWrapper -(owns)-> // EmbeddedWorkerInstanceClientImpl -(owns)-> WorkerWrapper -(owns)->
// WebEmbeddedWorkerInstance -(owns)-> ServiceWorkerContextClient -(owns)-> // WebEmbeddedWorkerImpl -(owns)-> ServiceWorkerContextClient -(owns)->
// EmbeddedWorkerInstanceClientImpl. Therefore, an instance can delete itself by // EmbeddedWorkerInstanceClientImpl. Therefore, an instance can delete itself by
// releasing its WorkerWrapper. // releasing its WorkerWrapper.
// //
...@@ -100,7 +100,7 @@ class EmbeddedWorkerInstanceClientImpl ...@@ -100,7 +100,7 @@ class EmbeddedWorkerInstanceClientImpl
void AddMessageToConsole(blink::WebConsoleMessage::Level level, void AddMessageToConsole(blink::WebConsoleMessage::Level level,
const std::string& message) override; const std::string& message) override;
// Handler of connection error bound to |binding_| // Handler of connection error bound to |binding_|.
void OnError(); void OnError();
std::unique_ptr<WorkerWrapper> StartWorkerContext( std::unique_ptr<WorkerWrapper> StartWorkerContext(
......
...@@ -72,8 +72,8 @@ class WebWorkerFetchContext; ...@@ -72,8 +72,8 @@ class WebWorkerFetchContext;
// starting up, and destroyed when the service worker stops. It is owned by // starting up, and destroyed when the service worker stops. It is owned by
// EmbeddedWorkerInstanceClientImpl's internal WorkerWrapper class. // EmbeddedWorkerInstanceClientImpl's internal WorkerWrapper class.
// //
// Unless otherwise noted (here or in the superclass documentation), all methods // Unless otherwise noted (here or in base class documentation), all methods are
// are called on the worker thread. // called on the worker thread.
class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
public mojom::ServiceWorkerEventDispatcher { public mojom::ServiceWorkerEventDispatcher {
public: public:
...@@ -387,7 +387,7 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, ...@@ -387,7 +387,7 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
scoped_refptr<ServiceWorkerProviderContext> provider_context_; scoped_refptr<ServiceWorkerProviderContext> provider_context_;
// Not owned; this object is destroyed when proxy_ becomes invalid. // Not owned; |this| is destroyed when |proxy_| becomes invalid.
blink::WebServiceWorkerContextProxy* proxy_; blink::WebServiceWorkerContextProxy* proxy_;
// This is bound on the worker thread. // This is bound on the worker thread.
...@@ -399,11 +399,10 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient, ...@@ -399,11 +399,10 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
instance_host_; instance_host_;
// This is passed to ServiceWorkerNetworkProvider when // This is passed to ServiceWorkerNetworkProvider when
// createServiceWorkerNetworkProvider is called. // CreateServiceWorkerNetworkProvider is called.
std::unique_ptr<ServiceWorkerNetworkProvider> pending_network_provider_; std::unique_ptr<ServiceWorkerNetworkProvider> pending_network_provider_;
// Renderer-side object corresponding to WebEmbeddedWorkerInstance. // This is valid from the ctor to WorkerContextDestroyed.
// This is valid from the ctor to workerContextDestroyed.
std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client_; std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client_;
blink::mojom::BlobRegistryPtr blob_registry_; blink::mojom::BlobRegistryPtr blob_registry_;
......
...@@ -33,16 +33,22 @@ struct RequestNavigationParams; ...@@ -33,16 +33,22 @@ struct RequestNavigationParams;
class ServiceWorkerProviderContext; class ServiceWorkerProviderContext;
class ChildURLLoaderFactoryGetter; class ChildURLLoaderFactoryGetter;
// A unique provider_id is generated for each instance. // ServiceWorkerNetworkProvider enables the browser process to recognize
// Instantiated prior to the main resource load being started and remains // resource requests from Blink that should be handled by service worker
// allocated until after the last subresource load has occurred. // machinery rather than the usual network stack.
// This is used to track the lifetime of a Document to create
// and dispose the ServiceWorkerProviderHost in the browser process
// to match its lifetime. Each request coming from the Document is
// tagged with this id in willSendRequest.
// //
// Basically, it's a scoped integer that sends an ipc upon construction // All requests associated with a network provider are tagged with its
// and destruction. // |provider_id| (from ServiceWorkerProviderContext). The browser
// process can then route the request to this provider's corresponding
// ServiceWorkerProviderHost.
//
// It is created for both service worker clients and execution contexts. It is
// instantiated prior to the main resource load being started and remains
// allocated until after the last subresource load has occurred. It is owned by
// the appropriate DocumentLoader for the provider (i.e., the loader for a
// document, or the shadow page's loader for a shared worker or service worker).
// Each request coming from the DocumentLoader is tagged with the provider_id in
// WillSendRequest.
class CONTENT_EXPORT ServiceWorkerNetworkProvider { class CONTENT_EXPORT ServiceWorkerNetworkProvider {
public: public:
// Creates a ServiceWorkerNetworkProvider for navigation and wraps it // Creates a ServiceWorkerNetworkProvider for navigation and wraps it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment