| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 ServiceWorkerVersion::ServiceWorkerVersion( | 299 ServiceWorkerVersion::ServiceWorkerVersion( |
| 300 ServiceWorkerRegistration* registration, | 300 ServiceWorkerRegistration* registration, |
| 301 const GURL& script_url, | 301 const GURL& script_url, |
| 302 int64_t version_id, | 302 int64_t version_id, |
| 303 base::WeakPtr<ServiceWorkerContextCore> context) | 303 base::WeakPtr<ServiceWorkerContextCore> context) |
| 304 : version_id_(version_id), | 304 : version_id_(version_id), |
| 305 registration_id_(registration->id()), | 305 registration_id_(registration->id()), |
| 306 script_url_(script_url), | 306 script_url_(script_url), |
| 307 scope_(registration->pattern()), | 307 scope_(registration->pattern()), |
| 308 fetch_handler_status_(FetchHandlerStatus::UNKNOWN), |
| 308 context_(context), | 309 context_(context), |
| 309 script_cache_map_(this, context), | 310 script_cache_map_(this, context), |
| 310 ping_controller_(new PingController(this)), | 311 ping_controller_(new PingController(this)), |
| 311 should_exclude_from_uma_( | 312 should_exclude_from_uma_( |
| 312 ServiceWorkerMetrics::ShouldExcludeURLFromHistogram(scope_)), | 313 ServiceWorkerMetrics::ShouldExcludeURLFromHistogram(scope_)), |
| 313 weak_factory_(this) { | 314 weak_factory_(this) { |
| 314 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); | 315 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); |
| 315 DCHECK(context_); | 316 DCHECK(context_); |
| 316 DCHECK(registration); | 317 DCHECK(registration); |
| 317 DCHECK(script_url_.is_valid()); | 318 DCHECK(script_url_.is_valid()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 342 embedded_worker_->RemoveListener(this); | 343 embedded_worker_->RemoveListener(this); |
| 343 } | 344 } |
| 344 | 345 |
| 345 void ServiceWorkerVersion::SetStatus(Status status) { | 346 void ServiceWorkerVersion::SetStatus(Status status) { |
| 346 if (status_ == status) | 347 if (status_ == status) |
| 347 return; | 348 return; |
| 348 | 349 |
| 349 TRACE_EVENT2("ServiceWorker", "ServiceWorkerVersion::SetStatus", "Script URL", | 350 TRACE_EVENT2("ServiceWorker", "ServiceWorkerVersion::SetStatus", "Script URL", |
| 350 script_url_.spec(), "New Status", VersionStatusToString(status)); | 351 script_url_.spec(), "New Status", VersionStatusToString(status)); |
| 351 | 352 |
| 353 // |fetch_handler_status_| must be set before setting the status to INSTALLED, |
| 354 // ACTIVATING or ACTIVATED. |
| 355 DCHECK(fetch_handler_status_ != FetchHandlerStatus::UNKNOWN || |
| 356 !(status == INSTALLED || status == ACTIVATING || status == ACTIVATED)); |
| 357 |
| 352 status_ = status; | 358 status_ = status; |
| 353 if (skip_waiting_ && status_ == ACTIVATED) { | 359 if (skip_waiting_ && status_ == ACTIVATED) { |
| 354 for (int request_id : pending_skip_waiting_requests_) | 360 for (int request_id : pending_skip_waiting_requests_) |
| 355 DidSkipWaiting(request_id); | 361 DidSkipWaiting(request_id); |
| 356 pending_skip_waiting_requests_.clear(); | 362 pending_skip_waiting_requests_.clear(); |
| 357 } | 363 } |
| 358 | 364 |
| 359 // OnVersionStateChanged() invokes updates of the status using state | 365 // OnVersionStateChanged() invokes updates of the status using state |
| 360 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and | 366 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and |
| 361 // ServiceWorkerContextCore (for devtools and serviceworker-internals). | 367 // ServiceWorkerContextCore (for devtools and serviceworker-internals). |
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1763 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
| 1758 idle_time_); | 1764 idle_time_); |
| 1759 } | 1765 } |
| 1760 | 1766 |
| 1761 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { | 1767 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { |
| 1762 start_worker_first_purpose_ = base::nullopt; | 1768 start_worker_first_purpose_ = base::nullopt; |
| 1763 RunCallbacks(this, &start_callbacks_, status); | 1769 RunCallbacks(this, &start_callbacks_, status); |
| 1764 } | 1770 } |
| 1765 | 1771 |
| 1766 } // namespace content | 1772 } // namespace content |
| OLD | NEW |