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

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

Issue 268753004: Add WorkerScriptLoaded message to support attaching DevTools while starting ServiceWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated nasko's comment Created 6 years, 7 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
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 82b9bb0397b63b2bfba37239102f9b26975012ac..a859268c396b222b3eec789382d84b4ba1c48f5f 100644
--- a/content/browser/service_worker/embedded_worker_registry.cc
+++ b/content/browser/service_worker/embedded_worker_registry.cc
@@ -84,6 +84,34 @@ void EmbeddedWorkerRegistry::Shutdown() {
}
}
+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";
+ 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";
+ return;
+ }
+ found->second->OnScriptLoadFailed();
+}
+
void EmbeddedWorkerRegistry::OnWorkerStarted(
int process_id, int thread_id, int embedded_worker_id) {
DCHECK(!ContainsKey(worker_process_map_, process_id) ||
@@ -93,8 +121,11 @@ void EmbeddedWorkerRegistry::OnWorkerStarted(
LOG(ERROR) << "Worker " << embedded_worker_id << " not registered";
return;
}
+ if (found->second->process_id() != process_id) {
+ LOG(ERROR) << "Incorrect embedded_worker_id";
+ return;
+ }
worker_process_map_[process_id].insert(embedded_worker_id);
- DCHECK_EQ(found->second->process_id(), process_id);
found->second->OnStarted(thread_id);
}
@@ -105,7 +136,10 @@ void EmbeddedWorkerRegistry::OnWorkerStopped(
LOG(ERROR) << "Worker " << embedded_worker_id << " not registered";
return;
}
- DCHECK_EQ(found->second->process_id(), process_id);
+ if (found->second->process_id() != process_id) {
+ LOG(ERROR) << "Incorrect embedded_worker_id";
+ return;
+ }
worker_process_map_[process_id].erase(embedded_worker_id);
found->second->OnStopped();
}

Powered by Google App Engine
This is Rietveld 408576698