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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <queue> | 13 #include <queue> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/callback.h" | 19 #include "base/callback.h" |
20 #include "base/containers/scoped_ptr_hash_map.h" | 20 #include "base/containers/scoped_ptr_hash_map.h" |
21 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
22 #include "base/id_map.h" | 22 #include "base/id_map.h" |
23 #include "base/macros.h" | 23 #include "base/macros.h" |
24 #include "base/memory/ptr_util.h" | 24 #include "base/memory/ptr_util.h" |
25 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
26 #include "base/observer_list.h" | 26 #include "base/observer_list.h" |
| 27 #include "base/optional.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/timer/timer.h" | 29 #include "base/timer/timer.h" |
29 #include "content/browser/service_worker/embedded_worker_instance.h" | 30 #include "content/browser/service_worker/embedded_worker_instance.h" |
30 #include "content/browser/service_worker/embedded_worker_status.h" | 31 #include "content/browser/service_worker/embedded_worker_status.h" |
31 #include "content/browser/service_worker/service_worker_metrics.h" | 32 #include "content/browser/service_worker/service_worker_metrics.h" |
32 #include "content/browser/service_worker/service_worker_script_cache_map.h" | 33 #include "content/browser/service_worker/service_worker_script_cache_map.h" |
33 #include "content/common/content_export.h" | 34 #include "content/common/content_export.h" |
34 #include "content/common/service_worker/service_worker_status_code.h" | 35 #include "content/common/service_worker/service_worker_status_code.h" |
35 #include "content/common/service_worker/service_worker_types.h" | 36 #include "content/common/service_worker/service_worker_types.h" |
36 #include "ipc/ipc_message.h" | 37 #include "ipc/ipc_message.h" |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 void OnStoppedInternal(EmbeddedWorkerStatus old_status); | 645 void OnStoppedInternal(EmbeddedWorkerStatus old_status); |
645 | 646 |
646 // Called when the remote side of a connection to a mojo service is lost. | 647 // Called when the remote side of a connection to a mojo service is lost. |
647 void OnMojoConnectionError(const char* service_name); | 648 void OnMojoConnectionError(const char* service_name); |
648 | 649 |
649 // Called at the beginning of each Dispatch*Event function: records | 650 // Called at the beginning of each Dispatch*Event function: records |
650 // the time elapsed since idle (generally the time since the previous | 651 // the time elapsed since idle (generally the time since the previous |
651 // event ended). | 652 // event ended). |
652 void OnBeginEvent(); | 653 void OnBeginEvent(); |
653 | 654 |
| 655 // Resets |start_worker_first_purpose_| and fires and clears all start |
| 656 // callbacks. |
| 657 void FinishStartWorker(ServiceWorkerStatusCode status); |
| 658 |
654 const int64_t version_id_; | 659 const int64_t version_id_; |
655 const int64_t registration_id_; | 660 const int64_t registration_id_; |
656 const GURL script_url_; | 661 const GURL script_url_; |
657 const GURL scope_; | 662 const GURL scope_; |
658 std::vector<GURL> foreign_fetch_scopes_; | 663 std::vector<GURL> foreign_fetch_scopes_; |
659 std::vector<url::Origin> foreign_fetch_origins_; | 664 std::vector<url::Origin> foreign_fetch_origins_; |
660 bool has_fetch_handler_ = true; | 665 bool has_fetch_handler_ = true; |
661 | 666 |
662 Status status_ = NEW; | 667 Status status_ = NEW; |
663 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; | 668 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // If not OK, the reason that StartWorker failed. Used for | 725 // If not OK, the reason that StartWorker failed. Used for |
721 // running |start_callbacks_|. | 726 // running |start_callbacks_|. |
722 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; | 727 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; |
723 | 728 |
724 std::unique_ptr<PingController> ping_controller_; | 729 std::unique_ptr<PingController> ping_controller_; |
725 std::unique_ptr<Metrics> metrics_; | 730 std::unique_ptr<Metrics> metrics_; |
726 const bool should_exclude_from_uma_ = false; | 731 const bool should_exclude_from_uma_ = false; |
727 | 732 |
728 bool stop_when_devtools_detached_ = false; | 733 bool stop_when_devtools_detached_ = false; |
729 | 734 |
| 735 // Keeps the first purpose of starting the worker for UMA. Cleared in |
| 736 // FinishStartWorker(). |
| 737 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; |
| 738 |
730 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 739 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
731 | 740 |
732 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 741 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
733 }; | 742 }; |
734 | 743 |
735 template <typename Interface> | 744 template <typename Interface> |
736 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest( | 745 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest( |
737 int request_id) { | 746 int request_id) { |
738 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); | 747 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); |
739 PendingRequest* request = pending_requests_.Lookup(request_id); | 748 PendingRequest* request = pending_requests_.Lookup(request_id); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 | 812 |
804 // At this point |this| can have been deleted, so don't do anything other | 813 // At this point |this| can have been deleted, so don't do anything other |
805 // than returning. | 814 // than returning. |
806 | 815 |
807 return true; | 816 return true; |
808 } | 817 } |
809 | 818 |
810 } // namespace content | 819 } // namespace content |
811 | 820 |
812 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 821 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |