Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "content/browser/service_worker/embedded_worker_instance.h" | 10 #include "content/browser/service_worker/embedded_worker_instance.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 stop_worker_timer_.Stop(); | 381 stop_worker_timer_.Stop(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void ServiceWorkerVersion::RemoveControllee( | 384 void ServiceWorkerVersion::RemoveControllee( |
| 385 ServiceWorkerProviderHost* provider_host) { | 385 ServiceWorkerProviderHost* provider_host) { |
| 386 ControlleeMap::iterator found = controllee_map_.find(provider_host); | 386 ControlleeMap::iterator found = controllee_map_.find(provider_host); |
| 387 DCHECK(found != controllee_map_.end()); | 387 DCHECK(found != controllee_map_.end()); |
| 388 controllee_by_id_.Remove(found->second); | 388 controllee_by_id_.Remove(found->second); |
| 389 controllee_map_.erase(found); | 389 controllee_map_.erase(found); |
| 390 RemoveProcessFromWorker(provider_host->process_id()); | 390 RemoveProcessFromWorker(provider_host->process_id()); |
| 391 if (!HasControllee()) | 391 |
| 392 ScheduleStopWorker(); | 392 if (HasControllee()) |
| 393 // TODO(kinuko): Fire NoControllees notification when the # of controllees | 393 return; |
| 394 // reaches 0, so that a new pending version can be activated (which will | 394 ScheduleStopWorker(); |
| 395 // deactivate this version). | 395 if (!context_) |
| 396 // TODO(michaeln): On no controllees call storage DeleteVersionResources | 396 return; |
| 397 // if this version has been deactivated. Probably storage can listen for | 397 ServiceWorkerRegistration* registration = |
| 398 // NoControllees for versions that have been deleted. | 398 context_->GetLiveRegistration(registration_id_); |
| 399 if (status() == REDUNDANT || | |
| 400 (registration && registration->is_uninstalling())) | |
| 401 context_->storage()->DeleteVersionResources( | |
|
michaeln
2014/06/28 02:29:31
I this should StartPurging()
| |
| 402 version_id_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | |
| 399 } | 403 } |
| 400 | 404 |
| 401 void ServiceWorkerVersion::AddWaitingControllee( | 405 void ServiceWorkerVersion::AddWaitingControllee( |
| 402 ServiceWorkerProviderHost* provider_host) { | 406 ServiceWorkerProviderHost* provider_host) { |
| 403 AddProcessToWorker(provider_host->process_id()); | 407 AddProcessToWorker(provider_host->process_id()); |
| 404 } | 408 } |
| 405 | 409 |
| 406 void ServiceWorkerVersion::RemoveWaitingControllee( | 410 void ServiceWorkerVersion::RemoveWaitingControllee( |
| 407 ServiceWorkerProviderHost* provider_host) { | 411 ServiceWorkerProviderHost* provider_host) { |
| 408 RemoveProcessFromWorker(provider_host->process_id()); | 412 RemoveProcessFromWorker(provider_host->process_id()); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 return; | 658 return; |
| 655 } | 659 } |
| 656 stop_worker_timer_.Start( | 660 stop_worker_timer_.Start( |
| 657 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), | 661 FROM_HERE, base::TimeDelta::FromSeconds(kStopWorkerDelay), |
| 658 base::Bind(&ServiceWorkerVersion::StopWorker, | 662 base::Bind(&ServiceWorkerVersion::StopWorker, |
| 659 weak_factory_.GetWeakPtr(), | 663 weak_factory_.GetWeakPtr(), |
| 660 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); | 664 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback))); |
| 661 } | 665 } |
| 662 | 666 |
| 663 } // namespace content | 667 } // namespace content |
| OLD | NEW |