Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: content/browser/service_worker/service_worker_version.h

Issue 2045153003: Speculatively launch Service Workers on mouse/touch events. [4/5] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 void OnStoppedInternal(EmbeddedWorkerStatus old_status); 644 void OnStoppedInternal(EmbeddedWorkerStatus old_status);
645 645
646 // Called when the remote side of a connection to a mojo service is lost. 646 // Called when the remote side of a connection to a mojo service is lost.
647 void OnMojoConnectionError(const char* service_name); 647 void OnMojoConnectionError(const char* service_name);
648 648
649 // Called at the beginning of each Dispatch*Event function: records 649 // Called at the beginning of each Dispatch*Event function: records
650 // the time elapsed since idle (generally the time since the previous 650 // the time elapsed since idle (generally the time since the previous
651 // event ended). 651 // event ended).
652 void OnBeginEvent(); 652 void OnBeginEvent();
653 653
654 // Resets |start_worker_first_purpose_| and fires and clears all start
655 // callbacks.
656 void FinishStartWorker(ServiceWorkerStatusCode status);
657
654 const int64_t version_id_; 658 const int64_t version_id_;
655 const int64_t registration_id_; 659 const int64_t registration_id_;
656 const GURL script_url_; 660 const GURL script_url_;
657 const GURL scope_; 661 const GURL scope_;
658 std::vector<GURL> foreign_fetch_scopes_; 662 std::vector<GURL> foreign_fetch_scopes_;
659 std::vector<url::Origin> foreign_fetch_origins_; 663 std::vector<url::Origin> foreign_fetch_origins_;
660 bool has_fetch_handler_ = true; 664 bool has_fetch_handler_ = true;
661 665
662 Status status_ = NEW; 666 Status status_ = NEW;
663 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; 667 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 // If not OK, the reason that StartWorker failed. Used for 724 // If not OK, the reason that StartWorker failed. Used for
721 // running |start_callbacks_|. 725 // running |start_callbacks_|.
722 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; 726 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK;
723 727
724 std::unique_ptr<PingController> ping_controller_; 728 std::unique_ptr<PingController> ping_controller_;
725 std::unique_ptr<Metrics> metrics_; 729 std::unique_ptr<Metrics> metrics_;
726 const bool should_exclude_from_uma_ = false; 730 const bool should_exclude_from_uma_ = false;
727 731
728 bool stop_when_devtools_detached_ = false; 732 bool stop_when_devtools_detached_ = false;
729 733
734 // Keeps the first purpose of starting the worker for UMA. Cleared in
735 // FinishStartWorker().
736 std::unique_ptr<ServiceWorkerMetrics::EventType> start_worker_first_purpose_;
nhiroki 2016/07/28 05:38:37 base::Optional<ServiceWorkerMetrics::EventType> co
horo 2016/07/28 08:15:48 Done.
737
730 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 738 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
731 739
732 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 740 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
733 }; 741 };
734 742
735 template <typename Interface> 743 template <typename Interface>
736 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest( 744 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest(
737 int request_id) { 745 int request_id) {
738 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); 746 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status());
739 PendingRequest* request = pending_requests_.Lookup(request_id); 747 PendingRequest* request = pending_requests_.Lookup(request_id);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 811
804 // At this point |this| can have been deleted, so don't do anything other 812 // At this point |this| can have been deleted, so don't do anything other
805 // than returning. 813 // than returning.
806 814
807 return true; 815 return true;
808 } 816 }
809 817
810 } // namespace content 818 } // namespace content
811 819
812 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 820 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698