| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 } | 607 } |
| 608 | 608 |
| 609 void ServiceWorkerVersion::SetStartWorkerStatusCode( | 609 void ServiceWorkerVersion::SetStartWorkerStatusCode( |
| 610 ServiceWorkerStatusCode status) { | 610 ServiceWorkerStatusCode status) { |
| 611 start_worker_status_ = status; | 611 start_worker_status_ = status; |
| 612 } | 612 } |
| 613 | 613 |
| 614 void ServiceWorkerVersion::Doom() { | 614 void ServiceWorkerVersion::Doom() { |
| 615 DCHECK(!HasControllee()); | 615 DCHECK(!HasControllee()); |
| 616 SetStatus(REDUNDANT); | 616 SetStatus(REDUNDANT); |
| 617 if (running_status() == STARTING || running_status() == RUNNING) | 617 if (running_status() == STARTING || running_status() == RUNNING) { |
| 618 embedded_worker_->Stop(); | 618 if (embedded_worker()->devtools_attached()) |
| 619 stop_when_devtools_detached_ = true; |
| 620 else |
| 621 embedded_worker_->Stop(); |
| 622 } |
| 619 if (!context_) | 623 if (!context_) |
| 620 return; | 624 return; |
| 621 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 625 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
| 622 script_cache_map_.GetResources(&resources); | 626 script_cache_map_.GetResources(&resources); |
| 623 context_->storage()->PurgeResources(resources); | 627 context_->storage()->PurgeResources(resources); |
| 624 } | 628 } |
| 625 | 629 |
| 626 void ServiceWorkerVersion::SetDevToolsAttached(bool attached) { | 630 void ServiceWorkerVersion::SetDevToolsAttached(bool attached) { |
| 627 embedded_worker()->set_devtools_attached(attached); | 631 embedded_worker()->set_devtools_attached(attached); |
| 632 if (stop_when_devtools_detached_ && !attached) { |
| 633 DCHECK_EQ(REDUNDANT, status()); |
| 634 if (running_status() == STARTING || running_status() == RUNNING) |
| 635 embedded_worker_->Stop(); |
| 636 return; |
| 637 } |
| 628 if (attached) { | 638 if (attached) { |
| 629 // TODO(falken): Canceling the timeouts when debugging could cause | 639 // TODO(falken): Canceling the timeouts when debugging could cause |
| 630 // heisenbugs; we should instead run them as normal show an educational | 640 // heisenbugs; we should instead run them as normal show an educational |
| 631 // message in DevTools when they occur. crbug.com/470419 | 641 // message in DevTools when they occur. crbug.com/470419 |
| 632 | 642 |
| 633 // Don't record the startup time metric once DevTools is attached. | 643 // Don't record the startup time metric once DevTools is attached. |
| 634 ClearTick(&start_time_); | 644 ClearTick(&start_time_); |
| 635 skip_recording_startup_time_ = true; | 645 skip_recording_startup_time_ = true; |
| 636 | 646 |
| 637 // Cancel request timeouts. | 647 // Cancel request timeouts. |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 void ServiceWorkerVersion::OnBeginEvent() { | 1687 void ServiceWorkerVersion::OnBeginEvent() { |
| 1678 if (should_exclude_from_uma_ || running_status() != RUNNING || | 1688 if (should_exclude_from_uma_ || running_status() != RUNNING || |
| 1679 idle_time_.is_null()) { | 1689 idle_time_.is_null()) { |
| 1680 return; | 1690 return; |
| 1681 } | 1691 } |
| 1682 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1692 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
| 1683 idle_time_); | 1693 idle_time_); |
| 1684 } | 1694 } |
| 1685 | 1695 |
| 1686 } // namespace content | 1696 } // namespace content |
| OLD | NEW |