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

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

Issue 443593002: ServiceWorker: Move worker candidate process knowledge to ServiceWorkerProcessManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_instance.cc
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc
index 7cf0f18f693086b6fa9a6c326383b24376f61ea2..ee909a512eb0406305149e76fb27532d3be1fbb5 100644
--- a/content/browser/service_worker/embedded_worker_instance.cc
+++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -127,7 +127,6 @@ void EmbeddedWorkerInstance::Start(int64 service_worker_version_id,
const GURL& scope,
const GURL& script_url,
bool pause_after_download,
- const std::vector<int>& possible_process_ids,
const StatusCallback& callback) {
if (!context_) {
callback.Run(SERVICE_WORKER_ERROR_ABORT);
@@ -151,7 +150,7 @@ void EmbeddedWorkerInstance::Start(int64 service_worker_version_id,
params->wait_for_debugger = false;
context_->process_manager()->AllocateWorkerProcess(
embedded_worker_id_,
- SortProcesses(possible_process_ids),
+ scope,
script_url,
base::Bind(&EmbeddedWorkerInstance::RunProcessAllocated,
weak_factory_.GetWeakPtr(),
@@ -186,23 +185,6 @@ ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMessage(
thread_id_, embedded_worker_id_, message));
}
-void EmbeddedWorkerInstance::AddProcessReference(int process_id) {
- ProcessRefMap::iterator found = process_refs_.find(process_id);
- if (found == process_refs_.end())
- found = process_refs_.insert(std::make_pair(process_id, 0)).first;
- ++found->second;
-}
-
-void EmbeddedWorkerInstance::ReleaseProcessReference(int process_id) {
- ProcessRefMap::iterator found = process_refs_.find(process_id);
- if (found == process_refs_.end()) {
- NOTREACHED() << "Releasing unknown process ref " << process_id;
- return;
- }
- if (--found->second == 0)
- process_refs_.erase(found);
-}
-
EmbeddedWorkerInstance::EmbeddedWorkerInstance(
base::WeakPtr<ServiceWorkerContextCore> context,
int embedded_worker_id)
@@ -366,26 +348,4 @@ void EmbeddedWorkerInstance::RemoveListener(Listener* listener) {
listener_list_.RemoveObserver(listener);
}
-std::vector<int> EmbeddedWorkerInstance::SortProcesses(
- const std::vector<int>& possible_process_ids) const {
- // Add the |possible_process_ids| to the existing process_refs_ since each one
- // is likely to take a reference once the SW starts up.
- ProcessRefMap refs_with_new_ids = process_refs_;
- for (std::vector<int>::const_iterator it = possible_process_ids.begin();
- it != possible_process_ids.end();
- ++it) {
- refs_with_new_ids[*it]++;
- }
-
- std::vector<std::pair<int, int> > counted(refs_with_new_ids.begin(),
- refs_with_new_ids.end());
- // Sort descending by the reference count.
- std::sort(counted.begin(), counted.end(), SecondGreater());
-
- std::vector<int> result(counted.size());
- for (size_t i = 0; i < counted.size(); ++i)
- result[i] = counted[i].first;
- return result;
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698