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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 embedded_worker_->RemoveListener(this); | 342 embedded_worker_->RemoveListener(this); |
343 } | 343 } |
344 | 344 |
345 void ServiceWorkerVersion::SetStatus(Status status) { | 345 void ServiceWorkerVersion::SetStatus(Status status) { |
346 if (status_ == status) | 346 if (status_ == status) |
347 return; | 347 return; |
348 | 348 |
349 TRACE_EVENT2("ServiceWorker", "ServiceWorkerVersion::SetStatus", "Script URL", | 349 TRACE_EVENT2("ServiceWorker", "ServiceWorkerVersion::SetStatus", "Script URL", |
350 script_url_.spec(), "New Status", VersionStatusToString(status)); | 350 script_url_.spec(), "New Status", VersionStatusToString(status)); |
351 | 351 |
| 352 // |has_fetch_handler_| must be set before setting the status to INSTALLED, |
| 353 // ACTIVATING or ACTIVATED. |
| 354 DCHECK(has_fetch_handler_ || |
| 355 !(status == INSTALLED || status == ACTIVATING || status == ACTIVATED)); |
| 356 |
352 status_ = status; | 357 status_ = status; |
353 if (skip_waiting_ && status_ == ACTIVATED) { | 358 if (skip_waiting_ && status_ == ACTIVATED) { |
354 for (int request_id : pending_skip_waiting_requests_) | 359 for (int request_id : pending_skip_waiting_requests_) |
355 DidSkipWaiting(request_id); | 360 DidSkipWaiting(request_id); |
356 pending_skip_waiting_requests_.clear(); | 361 pending_skip_waiting_requests_.clear(); |
357 } | 362 } |
358 | 363 |
359 // OnVersionStateChanged() invokes updates of the status using state | 364 // OnVersionStateChanged() invokes updates of the status using state |
360 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and | 365 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and |
361 // ServiceWorkerContextCore (for devtools and serviceworker-internals). | 366 // 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() - | 1762 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1758 idle_time_); | 1763 idle_time_); |
1759 } | 1764 } |
1760 | 1765 |
1761 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { | 1766 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { |
1762 start_worker_first_purpose_ = base::nullopt; | 1767 start_worker_first_purpose_ = base::nullopt; |
1763 RunCallbacks(this, &start_callbacks_, status); | 1768 RunCallbacks(this, &start_callbacks_, status); |
1764 } | 1769 } |
1765 | 1770 |
1766 } // namespace content | 1771 } // namespace content |
OLD | NEW |