Chromium Code Reviews| Index: content/browser/service_worker/embedded_worker_registry.cc |
| diff --git a/content/browser/service_worker/embedded_worker_registry.cc b/content/browser/service_worker/embedded_worker_registry.cc |
| index e7e444159f99358e32350cdb1e83514dab25129a..93743ee400aa0e03b9e60086622a7364c48f949b 100644 |
| --- a/content/browser/service_worker/embedded_worker_registry.cc |
| +++ b/content/browser/service_worker/embedded_worker_registry.cc |
| @@ -53,10 +53,9 @@ bool EmbeddedWorkerRegistry::OnMessageReceived(const IPC::Message& message) { |
| // ServiceWorkerDispatcherHost. |
| WorkerInstanceMap::iterator found = worker_map_.find(message.routing_id()); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << message.routing_id() << " not registered"; |
| + DCHECK(found != worker_map_.end()); |
| + if (found == worker_map_.end()) |
|
falken
2014/11/06 02:07:54
Typically we should not have constructions of the
|
| return false; |
| - } |
| return found->second->OnMessageReceived(message); |
| } |
| @@ -72,42 +71,30 @@ void EmbeddedWorkerRegistry::OnWorkerReadyForInspection( |
| int process_id, |
| int embedded_worker_id) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| found->second->OnReadyForInspection(); |
| } |
| void EmbeddedWorkerRegistry::OnWorkerScriptLoaded(int process_id, |
| int embedded_worker_id) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| found->second->OnScriptLoaded(); |
| } |
| void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, |
| int embedded_worker_id) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| found->second->OnScriptLoadFailed(); |
| } |
| @@ -116,14 +103,10 @@ void EmbeddedWorkerRegistry::OnWorkerStarted( |
| DCHECK(!ContainsKey(worker_process_map_, process_id) || |
| worker_process_map_[process_id].count(embedded_worker_id) == 0); |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| worker_process_map_[process_id].insert(embedded_worker_id); |
| found->second->OnStarted(thread_id); |
| } |
| @@ -131,14 +114,10 @@ void EmbeddedWorkerRegistry::OnWorkerStarted( |
| void EmbeddedWorkerRegistry::OnWorkerStopped( |
| int process_id, int embedded_worker_id) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| worker_process_map_[process_id].erase(embedded_worker_id); |
| found->second->OnStopped(); |
| } |
| @@ -146,14 +125,10 @@ void EmbeddedWorkerRegistry::OnWorkerStopped( |
| void EmbeddedWorkerRegistry::OnPausedAfterDownload( |
| int process_id, int embedded_worker_id) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| - return; |
| - } |
| - if (found->second->process_id() != process_id) { |
| - LOG(ERROR) << "Incorrect embedded_worker_id"; |
| + DCHECK(found != worker_map_.end()); |
| + DCHECK_EQ(found->second->process_id(), process_id); |
| + if (found == worker_map_.end() || found->second->process_id() != process_id) |
| return; |
| - } |
| found->second->OnPausedAfterDownload(); |
| } |
| @@ -164,10 +139,9 @@ void EmbeddedWorkerRegistry::OnReportException( |
| int column_number, |
| const GURL& source_url) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| + DCHECK(found != worker_map_.end()); |
| + if (found == worker_map_.end()) |
| return; |
| - } |
| found->second->OnReportException( |
| error_message, line_number, column_number, source_url); |
| } |
| @@ -180,10 +154,9 @@ void EmbeddedWorkerRegistry::OnReportConsoleMessage( |
| int line_number, |
| const GURL& source_url) { |
| WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| - if (found == worker_map_.end()) { |
| - LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| + DCHECK(found != worker_map_.end()); |
| + if (found == worker_map_.end()) |
| return; |
| - } |
| found->second->OnReportConsoleMessage( |
| source_identifier, message_level, message, line_number, source_url); |
| } |