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
// listening to it.
void DisassociateRegistration();
// Returns a handler for a request, the handler may return nullptr if
// the request doesn't require special handling.
// Returns a handler for a request. May return nullptr if the request doesn't
// require special handling.
std::unique_ptr<ServiceWorkerRequestHandler> CreateRequestHandler(
network::mojom::FetchRequestMode request_mode,
network::mojom::FetchCredentialsMode credentials_mode,
......
......@@ -62,7 +62,8 @@ class ServiceWorkerRequestInterceptor
} // namespace
// PlzNavigate
// PlzNavigate:
// static
void ServiceWorkerRequestHandler::InitializeForNavigation(
net::URLRequest* request,
ServiceWorkerNavigationHandleCore* navigation_handle_core,
......@@ -173,6 +174,7 @@ ServiceWorkerRequestHandler::InitializeForNavigationNetworkService(
return base::WrapUnique<URLLoaderRequestHandler>(handler.release());
}
// static
void ServiceWorkerRequestHandler::InitializeHandler(
net::URLRequest* request,
ServiceWorkerContextWrapper* context_wrapper,
......@@ -215,12 +217,14 @@ void ServiceWorkerRequestHandler::InitializeHandler(
request->SetUserData(&kUserDataKey, std::move(handler));
}
// static
ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
const net::URLRequest* request) {
return static_cast<ServiceWorkerRequestHandler*>(
request->GetUserData(&kUserDataKey));
}
// static
std::unique_ptr<net::URLRequestInterceptor>
ServiceWorkerRequestHandler::CreateInterceptor(
ResourceContext* resource_context) {
......@@ -228,6 +232,7 @@ ServiceWorkerRequestHandler::CreateInterceptor(
new ServiceWorkerRequestInterceptor(resource_context));
}
// static
bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
const net::URLRequest* request) {
ServiceWorkerRequestHandler* handler = GetHandler(request);
......@@ -237,6 +242,7 @@ bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
handler->provider_host_->running_hosted_version();
}
// static
ServiceWorkerProviderHost* ServiceWorkerRequestHandler::GetProviderHost(
const net::URLRequest* request) {
ServiceWorkerRequestHandler* handler = GetHandler(request);
......
......@@ -33,7 +33,7 @@ class ServiceWorkerContextClient;
// This class deletes itself when the worker stops (or if start failed). The
// ownership graph is a cycle like this:
// EmbeddedWorkerInstanceClientImpl -(owns)-> WorkerWrapper -(owns)->
// WebEmbeddedWorkerInstance -(owns)-> ServiceWorkerContextClient -(owns)->
// WebEmbeddedWorkerImpl -(owns)-> ServiceWorkerContextClient -(owns)->
// EmbeddedWorkerInstanceClientImpl. Therefore, an instance can delete itself by
// releasing its WorkerWrapper.
//
......@@ -100,7 +100,7 @@ class EmbeddedWorkerInstanceClientImpl
void AddMessageToConsole(blink::WebConsoleMessage::Level level,
const std::string& message) override;
// Handler of connection error bound to |binding_|
// Handler of connection error bound to |binding_|.
void OnError();
std::unique_ptr<WorkerWrapper> StartWorkerContext(
......
......@@ -72,8 +72,8 @@ class WebWorkerFetchContext;
// starting up, and destroyed when the service worker stops. It is owned by
// EmbeddedWorkerInstanceClientImpl's internal WorkerWrapper class.
//
// Unless otherwise noted (here or in the superclass documentation), all methods
// are called on the worker thread.
// Unless otherwise noted (here or in base class documentation), all methods are
// called on the worker thread.
class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
public mojom::ServiceWorkerEventDispatcher {
public:
......@@ -387,7 +387,7 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
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_;
// This is bound on the worker thread.
......@@ -399,11 +399,10 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
instance_host_;
// This is passed to ServiceWorkerNetworkProvider when
// createServiceWorkerNetworkProvider is called.
// CreateServiceWorkerNetworkProvider is called.
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_;
blink::mojom::BlobRegistryPtr blob_registry_;
......
......@@ -33,16 +33,22 @@ struct RequestNavigationParams;
class ServiceWorkerProviderContext;
class ChildURLLoaderFactoryGetter;
// A unique provider_id is generated for each instance.
// Instantiated prior to the main resource load being started and remains
// allocated until after the last subresource load has occurred.
// 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.
// ServiceWorkerNetworkProvider enables the browser process to recognize
// resource requests from Blink that should be handled by service worker
// machinery rather than the usual network stack.
//
// Basically, it's a scoped integer that sends an ipc upon construction
// and destruction.
// All requests associated with a network provider are tagged with its
// |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 {
public:
// 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