Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Unified Diff: content/browser/service_worker/embedded_worker_registry.cc

Issue 489303002: Use DCHECK instead of LOG(ERROR) in embedded_worker_registry.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2560bec9f2200b9dcc6a3d0d8492ad339a7e8d11 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())
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(found->second->process_id() == process_id);
nhiroki 2014/08/21 02:13:18 Can you use DCHECK_EQ instead here and elsewhere?
horo 2014/08/21 03:56:39 Done.
+ 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(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(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(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(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(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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698