Commit 9029a481 authored by nhiroki's avatar nhiroki Committed by Commit bot

ServiceWorker: Rename ScriptClientMap to ProviderClientMap

ScriptClientMap actually contains provider clients, not script clients.

BUG=n/a
TEST=compile

Review URL: https://codereview.chromium.org/854543002

Cr-Commit-Position: refs/heads/master@{#311442}
parent 53d0453c
...@@ -196,18 +196,18 @@ void ServiceWorkerDispatcher::RemoveProviderContext( ...@@ -196,18 +196,18 @@ void ServiceWorkerDispatcher::RemoveProviderContext(
worker_to_provider_.erase(provider_context->controller_handle_id()); worker_to_provider_.erase(provider_context->controller_handle_id());
} }
void ServiceWorkerDispatcher::AddScriptClient( void ServiceWorkerDispatcher::AddProviderClient(
int provider_id, int provider_id,
blink::WebServiceWorkerProviderClient* client) { blink::WebServiceWorkerProviderClient* client) {
DCHECK(client); DCHECK(client);
DCHECK(!ContainsKey(script_clients_, provider_id)); DCHECK(!ContainsKey(provider_clients_, provider_id));
script_clients_[provider_id] = client; provider_clients_[provider_id] = client;
} }
void ServiceWorkerDispatcher::RemoveScriptClient(int provider_id) { void ServiceWorkerDispatcher::RemoveProviderClient(int provider_id) {
// This could be possibly called multiple times to ensure termination. // This could be possibly called multiple times to ensure termination.
if (ContainsKey(script_clients_, provider_id)) if (ContainsKey(provider_clients_, provider_id))
script_clients_.erase(provider_id); provider_clients_.erase(provider_id);
} }
ServiceWorkerDispatcher* ServiceWorkerDispatcher*
...@@ -601,8 +601,8 @@ void ServiceWorkerDispatcher::SetReadyRegistration( ...@@ -601,8 +601,8 @@ void ServiceWorkerDispatcher::SetReadyRegistration(
return; return;
} }
ScriptClientMap::iterator client = script_clients_.find(provider_id); ProviderClientMap::iterator client = provider_clients_.find(provider_id);
if (client == script_clients_.end()) if (client == provider_clients_.end())
return; return;
ServiceWorkerRegistrationObjectInfo info = ServiceWorkerRegistrationObjectInfo info =
...@@ -640,8 +640,8 @@ void ServiceWorkerDispatcher::OnSetControllerServiceWorker( ...@@ -640,8 +640,8 @@ void ServiceWorkerDispatcher::OnSetControllerServiceWorker(
provider->second->OnSetControllerServiceWorker(info); provider->second->OnSetControllerServiceWorker(info);
} }
ScriptClientMap::iterator found = script_clients_.find(provider_id); ProviderClientMap::iterator found = provider_clients_.find(provider_id);
if (found != script_clients_.end()) { if (found != provider_clients_.end()) {
// Populate the .controller field with the new worker object. // Populate the .controller field with the new worker object.
found->second->setController(GetServiceWorker(info, false), found->second->setController(GetServiceWorker(info, false),
should_notify_controllerchange); should_notify_controllerchange);
...@@ -661,8 +661,8 @@ void ServiceWorkerDispatcher::OnPostMessage( ...@@ -661,8 +661,8 @@ void ServiceWorkerDispatcher::OnPostMessage(
"ServiceWorkerDispatcher::OnPostMessage", "ServiceWorkerDispatcher::OnPostMessage",
"Thread ID", thread_id); "Thread ID", thread_id);
ScriptClientMap::iterator found = script_clients_.find(provider_id); ProviderClientMap::iterator found = provider_clients_.find(provider_id);
if (found == script_clients_.end()) { if (found == provider_clients_.end()) {
// For now we do no queueing for messages sent to nonexistent / unattached // For now we do no queueing for messages sent to nonexistent / unattached
// client. // client.
return; return;
...@@ -686,10 +686,10 @@ void ServiceWorkerDispatcher::OnGetClientInfo(int thread_id, ...@@ -686,10 +686,10 @@ void ServiceWorkerDispatcher::OnGetClientInfo(int thread_id,
int request_id, int request_id,
int provider_id) { int provider_id) {
blink::WebServiceWorkerClientInfo info; blink::WebServiceWorkerClientInfo info;
ScriptClientMap::iterator found = script_clients_.find(provider_id); ProviderClientMap::iterator found = provider_clients_.find(provider_id);
// TODO(ksakamoto): Could we track these values in the browser side? Except // TODO(ksakamoto): Could we track these values in the browser side? Except
// for |isFocused|, it would be pretty easy. // for |isFocused|, it would be pretty easy.
if (found != script_clients_.end() && found->second->getClientInfo(&info)) { if (found != provider_clients_.end() && found->second->getClientInfo(&info)) {
ServiceWorkerClientInfo result; ServiceWorkerClientInfo result;
result.client_id = info.clientID; result.client_id = info.clientID;
result.page_visibility_state = info.pageVisibilityState; result.page_visibility_state = info.pageVisibilityState;
......
...@@ -83,9 +83,9 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { ...@@ -83,9 +83,9 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer {
// Called when navigator.serviceWorker is instantiated or detached // Called when navigator.serviceWorker is instantiated or detached
// for a document whose provider can be identified by |provider_id|. // for a document whose provider can be identified by |provider_id|.
void AddScriptClient(int provider_id, void AddProviderClient(int provider_id,
blink::WebServiceWorkerProviderClient* client); blink::WebServiceWorkerProviderClient* client);
void RemoveScriptClient(int provider_id); void RemoveProviderClient(int provider_id);
// If an existing WebServiceWorkerImpl exists for the Service // If an existing WebServiceWorkerImpl exists for the Service
// Worker, it is returned; otherwise a WebServiceWorkerImpl is // Worker, it is returned; otherwise a WebServiceWorkerImpl is
...@@ -136,10 +136,12 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { ...@@ -136,10 +136,12 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer {
IDMapOwnPointer> UnregistrationCallbackMap; IDMapOwnPointer> UnregistrationCallbackMap;
typedef IDMap<WebServiceWorkerGetRegistrationCallbacks, typedef IDMap<WebServiceWorkerGetRegistrationCallbacks,
IDMapOwnPointer> GetRegistrationCallbackMap; IDMapOwnPointer> GetRegistrationCallbackMap;
typedef std::map<int, blink::WebServiceWorkerProviderClient*> ScriptClientMap;
typedef std::map<int, blink::WebServiceWorkerProviderClient*>
ProviderClientMap;
typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap; typedef std::map<int, ServiceWorkerProviderContext*> ProviderContextMap;
typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap;
typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap; typedef std::map<int, ServiceWorkerProviderContext*> WorkerToProviderMap;
typedef std::map<int, WebServiceWorkerImpl*> WorkerObjectMap;
typedef std::map<int, WebServiceWorkerRegistrationImpl*> typedef std::map<int, WebServiceWorkerRegistrationImpl*>
RegistrationObjectMap; RegistrationObjectMap;
...@@ -237,8 +239,10 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer { ...@@ -237,8 +239,10 @@ class ServiceWorkerDispatcher : public WorkerTaskRunner::Observer {
RegistrationCallbackMap pending_registration_callbacks_; RegistrationCallbackMap pending_registration_callbacks_;
UnregistrationCallbackMap pending_unregistration_callbacks_; UnregistrationCallbackMap pending_unregistration_callbacks_;
GetRegistrationCallbackMap pending_get_registration_callbacks_; GetRegistrationCallbackMap pending_get_registration_callbacks_;
ScriptClientMap script_clients_;
ProviderClientMap provider_clients_;
ProviderContextMap provider_contexts_; ProviderContextMap provider_contexts_;
WorkerObjectMap service_workers_; WorkerObjectMap service_workers_;
RegistrationObjectMap registrations_; RegistrationObjectMap registrations_;
......
...@@ -31,14 +31,14 @@ WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl( ...@@ -31,14 +31,14 @@ WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl(
} }
WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() { WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() {
// Make sure the script client is removed. // Make sure the provider client is removed.
RemoveScriptClient(); RemoveProviderClient();
} }
void WebServiceWorkerProviderImpl::setClient( void WebServiceWorkerProviderImpl::setClient(
blink::WebServiceWorkerProviderClient* client) { blink::WebServiceWorkerProviderClient* client) {
if (!client) { if (!client) {
RemoveScriptClient(); RemoveProviderClient();
return; return;
} }
...@@ -47,7 +47,7 @@ void WebServiceWorkerProviderImpl::setClient( ...@@ -47,7 +47,7 @@ void WebServiceWorkerProviderImpl::setClient(
// (e.g. on document and on dedicated workers) can properly share // (e.g. on document and on dedicated workers) can properly share
// the single provider context across threads. (http://crbug.com/366538 // the single provider context across threads. (http://crbug.com/366538
// for more context) // for more context)
GetDispatcher()->AddScriptClient(provider_id_, client); GetDispatcher()->AddProviderClient(provider_id_, client);
if (!context_->registration()) { if (!context_->registration()) {
// This provider is not associated with any registration. // This provider is not associated with any registration.
...@@ -101,13 +101,13 @@ void WebServiceWorkerProviderImpl::getRegistration( ...@@ -101,13 +101,13 @@ void WebServiceWorkerProviderImpl::getRegistration(
GetDispatcher()->GetRegistration(provider_id_, document_url, callbacks); GetDispatcher()->GetRegistration(provider_id_, document_url, callbacks);
} }
void WebServiceWorkerProviderImpl::RemoveScriptClient() { void WebServiceWorkerProviderImpl::RemoveProviderClient() {
// Remove the script client, but only if the dispatcher is still there. // Remove the provider client, but only if the dispatcher is still there.
// (For cleanup path we don't need to bother creating a new dispatcher) // (For cleanup path we don't need to bother creating a new dispatcher)
ServiceWorkerDispatcher* dispatcher = ServiceWorkerDispatcher* dispatcher =
ServiceWorkerDispatcher::GetThreadSpecificInstance(); ServiceWorkerDispatcher::GetThreadSpecificInstance();
if (dispatcher) if (dispatcher)
dispatcher->RemoveScriptClient(provider_id_); dispatcher->RemoveProviderClient(provider_id_);
} }
ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() {
......
...@@ -48,7 +48,7 @@ class WebServiceWorkerProviderImpl ...@@ -48,7 +48,7 @@ class WebServiceWorkerProviderImpl
int provider_id() const { return provider_id_; } int provider_id() const { return provider_id_; }
private: private:
void RemoveScriptClient(); void RemoveProviderClient();
ServiceWorkerDispatcher* GetDispatcher(); ServiceWorkerDispatcher* GetDispatcher();
scoped_refptr<ThreadSafeSender> thread_safe_sender_; scoped_refptr<ThreadSafeSender> thread_safe_sender_;
......
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