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> |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 | 403 |
404 // Returns true if the service worker has work to do: it has pending | 404 // Returns true if the service worker has work to do: it has pending |
405 // requests, in-progress streaming URLRequestJobs, or pending start callbacks. | 405 // requests, in-progress streaming URLRequestJobs, or pending start callbacks. |
406 bool HasWork() const; | 406 bool HasWork() const; |
407 | 407 |
408 // Returns the number of pending external request count of this worker. | 408 // Returns the number of pending external request count of this worker. |
409 size_t GetExternalRequestCountForTest() const { | 409 size_t GetExternalRequestCountForTest() const { |
410 return external_request_uuid_to_request_id_.size(); | 410 return external_request_uuid_to_request_id_.size(); |
411 } | 411 } |
412 | 412 |
413 // Returns the amount of time left until the request with the latest | |
414 // expiration time expires. | |
415 base::TimeDelta remaining_timeout() const { | |
416 return max_request_expiration_time_ - tick_clock_->NowTicks(); | |
417 } | |
418 | |
413 private: | 419 private: |
414 friend class base::RefCounted<ServiceWorkerVersion>; | 420 friend class base::RefCounted<ServiceWorkerVersion>; |
415 friend class ServiceWorkerMetrics; | 421 friend class ServiceWorkerMetrics; |
416 friend class ServiceWorkerReadFromCacheJobTest; | 422 friend class ServiceWorkerReadFromCacheJobTest; |
417 friend class ServiceWorkerStallInStoppingTest; | 423 friend class ServiceWorkerStallInStoppingTest; |
418 friend class ServiceWorkerURLRequestJobTest; | 424 friend class ServiceWorkerURLRequestJobTest; |
419 friend class ServiceWorkerVersionBrowserTest; | 425 friend class ServiceWorkerVersionBrowserTest; |
420 friend class ServiceWorkerVersionTestP; | 426 friend class ServiceWorkerVersionTestP; |
421 | 427 |
422 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTestP, | 428 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTestP, |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 base::TimeTicks idle_time_; | 786 base::TimeTicks idle_time_; |
781 // Holds the time that the outstanding StartWorker() request started. | 787 // Holds the time that the outstanding StartWorker() request started. |
782 base::TimeTicks start_time_; | 788 base::TimeTicks start_time_; |
783 // Holds the time the worker entered STOPPING status. This is also used as a | 789 // Holds the time the worker entered STOPPING status. This is also used as a |
784 // trace event id. | 790 // trace event id. |
785 base::TimeTicks stop_time_; | 791 base::TimeTicks stop_time_; |
786 // Holds the time the worker was detected as stale and needs updating. We try | 792 // Holds the time the worker was detected as stale and needs updating. We try |
787 // to update once the worker stops, but will also update if it stays alive too | 793 // to update once the worker stops, but will also update if it stays alive too |
788 // long. | 794 // long. |
789 base::TimeTicks stale_time_; | 795 base::TimeTicks stale_time_; |
796 // The latest expiration time of all requests that have ever been started. In | |
797 // particular this is not just the maximum of the expiration times of all | |
798 // currently existing requests, but also takes into account the former | |
799 // expiration times of finished requests. | |
falken
2016/12/05 02:31:51
Thanks for the precise comment.
| |
800 base::TimeTicks max_request_expiration_time_; | |
790 | 801 |
791 // Keeps track of requests for timeout purposes. Requests are sorted by | 802 // Keeps track of requests for timeout purposes. Requests are sorted by |
792 // their expiration time (soonest to expire on top of the priority queue). The | 803 // their expiration time (soonest to expire on top of the priority queue). The |
793 // timeout timer periodically checks |timeout_queue_| for entries that should | 804 // timeout timer periodically checks |timeout_queue_| for entries that should |
794 // time out or have already been fulfilled (i.e., removed from | 805 // time out or have already been fulfilled (i.e., removed from |
795 // |pending_requests_|). | 806 // |pending_requests_|). |
796 RequestInfoPriorityQueue timeout_queue_; | 807 RequestInfoPriorityQueue timeout_queue_; |
797 | 808 |
798 bool skip_waiting_ = false; | 809 bool skip_waiting_ = false; |
799 bool skip_recording_startup_time_ = false; | 810 bool skip_recording_startup_time_ = false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 | 886 |
876 // At this point |this| can have been deleted, so don't do anything other | 887 // At this point |this| can have been deleted, so don't do anything other |
877 // than returning. | 888 // than returning. |
878 | 889 |
879 return true; | 890 return true; |
880 } | 891 } |
881 | 892 |
882 } // namespace content | 893 } // namespace content |
883 | 894 |
884 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 895 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |