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

Unified Diff: content/browser/devtools/protocol/service_worker_handler.cc

Issue 2000563002: [DevTools] Attach all ServiceWorkers that match the origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« 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/devtools/protocol/service_worker_handler.cc
diff --git a/content/browser/devtools/protocol/service_worker_handler.cc b/content/browser/devtools/protocol/service_worker_handler.cc
index 52a352f38a9a3d6ede8988dc39a6673517b7ad5f..a3034a2a88ac896261f7e803fb48060c50776bdb 100644
--- a/content/browser/devtools/protocol/service_worker_handler.cc
+++ b/content/browser/devtools/protocol/service_worker_handler.cc
@@ -162,34 +162,6 @@ void GetMatchingHostsByScopeMap(
}
}
-GURL GetBestMatchingScope(const ScopeAgentsMap& scope_agents_map,
- const GURL& url) {
- GURL best_scope;
- bool best_scope_matched = false;
- int best_scope_length = 0;
-
- for (const auto& it : scope_agents_map) {
- if (it.first.host_piece() != url.host_piece())
- continue;
- const bool scope_matched = ServiceWorkerUtils::ScopeMatches(it.first, url);
- const int scope_length = it.first.spec().length();
- bool replace = false;
- if (!best_scope.is_empty())
- replace = true;
- else if (best_scope_matched)
- replace = scope_matched && scope_length >= best_scope_length;
- else
- replace = scope_matched || scope_length >= best_scope_length;
-
- if (replace) {
- best_scope = it.first;
- best_scope_matched = scope_matched;
- best_scope_length = scope_length;
- }
- }
- return best_scope;
-}
-
void AddEligibleHosts(const ServiceWorkerDevToolsAgentHost::List& list,
ServiceWorkerDevToolsAgentHost::Map* result) {
base::Time last_installed_time;
@@ -225,15 +197,9 @@ ServiceWorkerDevToolsAgentHost::Map GetMatchingServiceWorkers(
ScopeAgentsMap scope_agents_map;
GetMatchingHostsByScopeMap(agent_hosts, urls, &scope_agents_map);
- std::set<GURL> matching_scopes;
- for (const GURL& url : urls)
- matching_scopes.insert(GetBestMatchingScope(scope_agents_map, url));
-
- for (const auto& it : scope_agents_map) {
- if (matching_scopes.find(it.first) == matching_scopes.end())
- continue;
+ for (const auto& it : scope_agents_map)
AddEligibleHosts(*it.second.get(), &result);
- }
+
return result;
}
« 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