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 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 set_foreign_fetch_scopes(sub_scopes); | 1277 set_foreign_fetch_scopes(sub_scopes); |
1278 set_foreign_fetch_origins(origins); | 1278 set_foreign_fetch_origins(origins); |
1279 } | 1279 } |
1280 | 1280 |
1281 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( | 1281 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( |
1282 ServiceWorkerMetrics::EventType purpose, | 1282 ServiceWorkerMetrics::EventType purpose, |
1283 Status prestart_status, | 1283 Status prestart_status, |
1284 bool is_browser_startup_complete, | 1284 bool is_browser_startup_complete, |
1285 const StatusCallback& callback, | 1285 const StatusCallback& callback, |
1286 ServiceWorkerStatusCode status, | 1286 ServiceWorkerStatusCode status, |
1287 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 1287 scoped_refptr<ServiceWorkerRegistration> registration) { |
1288 scoped_refptr<ServiceWorkerRegistration> protect = registration; | 1288 scoped_refptr<ServiceWorkerRegistration> protect = registration; |
1289 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 1289 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
1290 // When the registration has already been deleted from the storage but its | 1290 // When the registration has already been deleted from the storage but its |
1291 // active worker is still controlling clients, the event should be | 1291 // active worker is still controlling clients, the event should be |
1292 // dispatched on the worker. However, the storage cannot find the | 1292 // dispatched on the worker. However, the storage cannot find the |
1293 // registration. To handle the case, check the live registrations here. | 1293 // registration. To handle the case, check the live registrations here. |
1294 protect = context_->GetLiveRegistration(registration_id_); | 1294 protect = context_->GetLiveRegistration(registration_id_); |
1295 if (protect) { | 1295 if (protect) { |
1296 DCHECK(protect->is_deleted()); | 1296 DCHECK(protect->is_deleted()); |
1297 status = SERVICE_WORKER_OK; | 1297 status = SERVICE_WORKER_OK; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 return; | 1647 return; |
1648 base::TimeDelta time_since_last_check = | 1648 base::TimeDelta time_since_last_check = |
1649 base::Time::Now() - registration->last_update_check(); | 1649 base::Time::Now() - registration->last_update_check(); |
1650 if (time_since_last_check > | 1650 if (time_since_last_check > |
1651 base::TimeDelta::FromHours(kServiceWorkerScriptMaxCacheAgeInHours)) | 1651 base::TimeDelta::FromHours(kServiceWorkerScriptMaxCacheAgeInHours)) |
1652 RestartTick(&stale_time_); | 1652 RestartTick(&stale_time_); |
1653 } | 1653 } |
1654 | 1654 |
1655 void ServiceWorkerVersion::FoundRegistrationForUpdate( | 1655 void ServiceWorkerVersion::FoundRegistrationForUpdate( |
1656 ServiceWorkerStatusCode status, | 1656 ServiceWorkerStatusCode status, |
1657 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 1657 scoped_refptr<ServiceWorkerRegistration> registration) { |
1658 if (!context_) | 1658 if (!context_) |
1659 return; | 1659 return; |
1660 | 1660 |
1661 const scoped_refptr<ServiceWorkerVersion> protect = this; | 1661 const scoped_refptr<ServiceWorkerVersion> protect = this; |
1662 if (is_update_scheduled_) { | 1662 if (is_update_scheduled_) { |
1663 context_->UnprotectVersion(version_id_); | 1663 context_->UnprotectVersion(version_id_); |
1664 is_update_scheduled_ = false; | 1664 is_update_scheduled_ = false; |
1665 } | 1665 } |
1666 | 1666 |
1667 if (status != SERVICE_WORKER_OK || registration->active_version() != this) | 1667 if (status != SERVICE_WORKER_OK || registration->active_version() != this) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 if (should_exclude_from_uma_ || | 1737 if (should_exclude_from_uma_ || |
1738 running_status() != EmbeddedWorkerStatus::RUNNING || | 1738 running_status() != EmbeddedWorkerStatus::RUNNING || |
1739 idle_time_.is_null()) { | 1739 idle_time_.is_null()) { |
1740 return; | 1740 return; |
1741 } | 1741 } |
1742 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1742 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1743 idle_time_); | 1743 idle_time_); |
1744 } | 1744 } |
1745 | 1745 |
1746 } // namespace content | 1746 } // namespace content |
OLD | NEW |