Commit 20f60637 authored by Hayato Ito's avatar Hayato Ito Committed by Commit Bot

Rename ServiceWorkerTimeoutTimer to ServiceWorkerEventQueue

Follow-up of http://crrev/c/1906452.
This CL intentionally did only the file renaming and necessary minimum
changes so that Gerrit can recognize the file renaming correctly.

Note if we did all follow-up tasks in one CL, Gerrit
couldn't recognize the file renaming, as seen in http://crrev/c/1942903.

Other trivial and non-trivial changes, such as PushTask -> EnqueueNormal,
renaming functions and variables, will be included in other follow-up
CLs.

TBR=kinuko@chromium.org

Bug: 965802
Change-Id: I68ee6edfdad4083a7056928b246c6ff916619067
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1945951
Commit-Queue: Hayato Ito <hayato@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720847}
parent 4bb949f4
...@@ -395,8 +395,8 @@ jumbo_source_set("unit_tests") { ...@@ -395,8 +395,8 @@ jumbo_source_set("unit_tests") {
"sensor/sensor_test_utils.cc", "sensor/sensor_test_utils.cc",
"sensor/sensor_test_utils.h", "sensor/sensor_test_utils.h",
"service_worker/service_worker_container_test.cc", "service_worker/service_worker_container_test.cc",
"service_worker/service_worker_event_queue_test.cc",
"service_worker/service_worker_installed_scripts_manager_test.cc", "service_worker/service_worker_installed_scripts_manager_test.cc",
"service_worker/service_worker_timeout_timer_test.cc",
"service_worker/thread_safe_script_container_test.cc", "service_worker/thread_safe_script_container_test.cc",
"service_worker/web_embedded_worker_impl_test.cc", "service_worker/web_embedded_worker_impl_test.cc",
"wake_lock/wake_lock_manager_test.cc", "wake_lock/wake_lock_manager_test.cc",
......
...@@ -36,6 +36,8 @@ blink_modules_sources("service_worker") { ...@@ -36,6 +36,8 @@ blink_modules_sources("service_worker") {
"service_worker_content_settings_proxy.h", "service_worker_content_settings_proxy.h",
"service_worker_error.cc", "service_worker_error.cc",
"service_worker_error.h", "service_worker_error.h",
"service_worker_event_queue.cc",
"service_worker_event_queue.h",
"service_worker_global_scope.cc", "service_worker_global_scope.cc",
"service_worker_global_scope.h", "service_worker_global_scope.h",
"service_worker_global_scope_proxy.cc", "service_worker_global_scope_proxy.cc",
...@@ -50,8 +52,6 @@ blink_modules_sources("service_worker") { ...@@ -50,8 +52,6 @@ blink_modules_sources("service_worker") {
"service_worker_script_cached_metadata_handler.h", "service_worker_script_cached_metadata_handler.h",
"service_worker_thread.cc", "service_worker_thread.cc",
"service_worker_thread.h", "service_worker_thread.h",
"service_worker_timeout_timer.cc",
"service_worker_timeout_timer.h",
"service_worker_window_client.cc", "service_worker_window_client.cc",
"service_worker_window_client.h", "service_worker_window_client.h",
"thread_safe_script_container.cc", "thread_safe_script_container.cc",
......
...@@ -33,7 +33,7 @@ specific_include_rules = { ...@@ -33,7 +33,7 @@ specific_include_rules = {
"+base/run_loop.h", "+base/run_loop.h",
"+mojo/public/cpp/bindings/binding.h", "+mojo/public/cpp/bindings/binding.h",
], ],
"service_worker_timeout_timer_test\.cc": [ "service_worker_event_queue_test\.cc": [
"+base/test/test_mock_time_task_runner.h", "+base/test/test_mock_time_task_runner.h",
], ],
"web_embedded_worker_impl_test\.cc": [ "web_embedded_worker_impl_test\.cc": [
......
...@@ -140,7 +140,7 @@ class FetchLoaderClient final : public GarbageCollected<FetchLoaderClient>, ...@@ -140,7 +140,7 @@ class FetchLoaderClient final : public GarbageCollected<FetchLoaderClient>,
public: public:
FetchLoaderClient( FetchLoaderClient(
std::unique_ptr<ServiceWorkerTimeoutTimer::StayAwakeToken> token) std::unique_ptr<ServiceWorkerEventQueue::StayAwakeToken> token)
: token_(std::move(token)) { : token_(std::move(token)) {
// We need to make |callback_| callable in the first place because some // We need to make |callback_| callable in the first place because some
// DidFetchDataLoadXXX() accessing it may be called synchronously from // DidFetchDataLoadXXX() accessing it may be called synchronously from
...@@ -187,7 +187,7 @@ class FetchLoaderClient final : public GarbageCollected<FetchLoaderClient>, ...@@ -187,7 +187,7 @@ class FetchLoaderClient final : public GarbageCollected<FetchLoaderClient>,
callback_receiver_; callback_receiver_;
mojo::Remote<mojom::blink::ServiceWorkerStreamCallback> callback_; mojo::Remote<mojom::blink::ServiceWorkerStreamCallback> callback_;
std::unique_ptr<ServiceWorkerTimeoutTimer::StayAwakeToken> token_; std::unique_ptr<ServiceWorkerEventQueue::StayAwakeToken> token_;
DISALLOW_COPY_AND_ASSIGN(FetchLoaderClient); DISALLOW_COPY_AND_ASSIGN(FetchLoaderClient);
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/modules/service_worker/service_worker_timeout_timer.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_event_queue.h"
#include "base/atomic_sequence_num.h" #include "base/atomic_sequence_num.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -28,40 +28,40 @@ int NextEventId() { ...@@ -28,40 +28,40 @@ int NextEventId() {
} // namespace } // namespace
// static // static
constexpr base::TimeDelta ServiceWorkerTimeoutTimer::kIdleDelay; constexpr base::TimeDelta ServiceWorkerEventQueue::kIdleDelay;
constexpr base::TimeDelta ServiceWorkerTimeoutTimer::kEventTimeout; constexpr base::TimeDelta ServiceWorkerEventQueue::kEventTimeout;
constexpr base::TimeDelta ServiceWorkerTimeoutTimer::kUpdateInterval; constexpr base::TimeDelta ServiceWorkerEventQueue::kUpdateInterval;
ServiceWorkerTimeoutTimer::StayAwakeToken::StayAwakeToken( ServiceWorkerEventQueue::StayAwakeToken::StayAwakeToken(
base::WeakPtr<ServiceWorkerTimeoutTimer> timer) base::WeakPtr<ServiceWorkerEventQueue> event_queue)
: timer_(std::move(timer)) { : event_queue_(std::move(event_queue)) {
DCHECK(timer_); DCHECK(event_queue_);
timer_->num_of_stay_awake_tokens_++; event_queue_->num_of_stay_awake_tokens_++;
} }
ServiceWorkerTimeoutTimer::StayAwakeToken::~StayAwakeToken() { ServiceWorkerEventQueue::StayAwakeToken::~StayAwakeToken() {
// If |timer_| has already been destroyed, it means the worker thread has // If |event_queue_| has already been destroyed, it means the worker thread
// already been killed. // has already been killed.
if (!timer_) if (!event_queue_)
return; return;
DCHECK_GT(timer_->num_of_stay_awake_tokens_, 0); DCHECK_GT(event_queue_->num_of_stay_awake_tokens_, 0);
timer_->num_of_stay_awake_tokens_--; event_queue_->num_of_stay_awake_tokens_--;
if (!timer_->HasInflightEvent()) if (!event_queue_->HasInflightEvent())
timer_->OnNoInflightEvent(); event_queue_->OnNoInflightEvent();
} }
ServiceWorkerTimeoutTimer::ServiceWorkerTimeoutTimer( ServiceWorkerEventQueue::ServiceWorkerEventQueue(
base::RepeatingClosure idle_callback) base::RepeatingClosure idle_callback)
: ServiceWorkerTimeoutTimer(std::move(idle_callback), : ServiceWorkerEventQueue(std::move(idle_callback),
base::DefaultTickClock::GetInstance()) {} base::DefaultTickClock::GetInstance()) {}
ServiceWorkerTimeoutTimer::ServiceWorkerTimeoutTimer( ServiceWorkerEventQueue::ServiceWorkerEventQueue(
base::RepeatingClosure idle_callback, base::RepeatingClosure idle_callback,
const base::TickClock* tick_clock) const base::TickClock* tick_clock)
: idle_callback_(std::move(idle_callback)), tick_clock_(tick_clock) {} : idle_callback_(std::move(idle_callback)), tick_clock_(tick_clock) {}
ServiceWorkerTimeoutTimer::~ServiceWorkerTimeoutTimer() { ServiceWorkerEventQueue::~ServiceWorkerEventQueue() {
in_dtor_ = true; in_dtor_ = true;
// Abort all callbacks. // Abort all callbacks.
for (auto& event : id_event_map_) { for (auto& event : id_event_map_) {
...@@ -70,17 +70,17 @@ ServiceWorkerTimeoutTimer::~ServiceWorkerTimeoutTimer() { ...@@ -70,17 +70,17 @@ ServiceWorkerTimeoutTimer::~ServiceWorkerTimeoutTimer() {
} }
} }
void ServiceWorkerTimeoutTimer::Start() { void ServiceWorkerEventQueue::Start() {
DCHECK(!timer_.IsRunning()); DCHECK(!timer_.IsRunning());
// |idle_callback_| will be invoked if no event happens in |kIdleDelay|. // |idle_callback_| will be invoked if no event happens in |kIdleDelay|.
if (!HasInflightEvent() && idle_time_.is_null()) if (!HasInflightEvent() && idle_time_.is_null())
idle_time_ = tick_clock_->NowTicks() + kIdleDelay; idle_time_ = tick_clock_->NowTicks() + kIdleDelay;
timer_.Start(FROM_HERE, kUpdateInterval, timer_.Start(FROM_HERE, kUpdateInterval,
WTF::BindRepeating(&ServiceWorkerTimeoutTimer::UpdateStatus, WTF::BindRepeating(&ServiceWorkerEventQueue::UpdateStatus,
WTF::Unretained(this))); WTF::Unretained(this)));
} }
void ServiceWorkerTimeoutTimer::PushTask(std::unique_ptr<Task> task) { void ServiceWorkerEventQueue::PushTask(std::unique_ptr<Task> task) {
DCHECK(task->type != Task::Type::Pending || did_idle_timeout()); DCHECK(task->type != Task::Type::Pending || did_idle_timeout());
bool can_start_processing_tasks = bool can_start_processing_tasks =
!processing_tasks_ && task->type != Task::Type::Pending; !processing_tasks_ && task->type != Task::Type::Pending;
...@@ -94,7 +94,7 @@ void ServiceWorkerTimeoutTimer::PushTask(std::unique_ptr<Task> task) { ...@@ -94,7 +94,7 @@ void ServiceWorkerTimeoutTimer::PushTask(std::unique_ptr<Task> task) {
ProcessTasks(); ProcessTasks();
} }
void ServiceWorkerTimeoutTimer::ProcessTasks() { void ServiceWorkerEventQueue::ProcessTasks() {
DCHECK(!processing_tasks_); DCHECK(!processing_tasks_);
processing_tasks_ = true; processing_tasks_ = true;
while (!task_queue_.IsEmpty()) { while (!task_queue_.IsEmpty()) {
...@@ -110,13 +110,13 @@ void ServiceWorkerTimeoutTimer::ProcessTasks() { ...@@ -110,13 +110,13 @@ void ServiceWorkerTimeoutTimer::ProcessTasks() {
OnNoInflightEvent(); OnNoInflightEvent();
} }
void ServiceWorkerTimeoutTimer::StartTask(std::unique_ptr<Task> task) { void ServiceWorkerEventQueue::StartTask(std::unique_ptr<Task> task) {
int event_id = StartEvent(std::move(task->abort_callback), int event_id = StartEvent(std::move(task->abort_callback),
task->custom_timeout.value_or(kEventTimeout)); task->custom_timeout.value_or(kEventTimeout));
std::move(task->start_callback).Run(event_id); std::move(task->start_callback).Run(event_id);
} }
int ServiceWorkerTimeoutTimer::StartEvent(AbortCallback abort_callback, int ServiceWorkerEventQueue::StartEvent(AbortCallback abort_callback,
base::TimeDelta timeout) { base::TimeDelta timeout) {
idle_time_ = base::TimeTicks(); idle_time_ = base::TimeTicks();
const int event_id = NextEventId(); const int event_id = NextEventId();
...@@ -128,7 +128,7 @@ int ServiceWorkerTimeoutTimer::StartEvent(AbortCallback abort_callback, ...@@ -128,7 +128,7 @@ int ServiceWorkerTimeoutTimer::StartEvent(AbortCallback abort_callback,
return event_id; return event_id;
} }
void ServiceWorkerTimeoutTimer::EndEvent(int event_id) { void ServiceWorkerEventQueue::EndEvent(int event_id) {
DCHECK(HasEvent(event_id)); DCHECK(HasEvent(event_id));
id_event_map_.erase(event_id); id_event_map_.erase(event_id);
// Check |processing_tasks_| here because EndEvent() can be called // Check |processing_tasks_| here because EndEvent() can be called
...@@ -138,23 +138,23 @@ void ServiceWorkerTimeoutTimer::EndEvent(int event_id) { ...@@ -138,23 +138,23 @@ void ServiceWorkerTimeoutTimer::EndEvent(int event_id) {
OnNoInflightEvent(); OnNoInflightEvent();
} }
bool ServiceWorkerTimeoutTimer::HasEvent(int event_id) const { bool ServiceWorkerEventQueue::HasEvent(int event_id) const {
return id_event_map_.find(event_id) != id_event_map_.end(); return id_event_map_.find(event_id) != id_event_map_.end();
} }
std::unique_ptr<ServiceWorkerTimeoutTimer::StayAwakeToken> std::unique_ptr<ServiceWorkerEventQueue::StayAwakeToken>
ServiceWorkerTimeoutTimer::CreateStayAwakeToken() { ServiceWorkerEventQueue::CreateStayAwakeToken() {
return std::make_unique<ServiceWorkerTimeoutTimer::StayAwakeToken>( return std::make_unique<ServiceWorkerEventQueue::StayAwakeToken>(
weak_factory_.GetWeakPtr()); weak_factory_.GetWeakPtr());
} }
void ServiceWorkerTimeoutTimer::SetIdleTimerDelayToZero() { void ServiceWorkerEventQueue::SetIdleTimerDelayToZero() {
zero_idle_timer_delay_ = true; zero_idle_timer_delay_ = true;
if (!HasInflightEvent()) if (!HasInflightEvent())
MaybeTriggerIdleTimer(); MaybeTriggerIdleTimer();
} }
void ServiceWorkerTimeoutTimer::UpdateStatus() { void ServiceWorkerEventQueue::UpdateStatus() {
base::TimeTicks now = tick_clock_->NowTicks(); base::TimeTicks now = tick_clock_->NowTicks();
HashMap<int /* event_id */, std::unique_ptr<EventInfo>> new_id_event_map; HashMap<int /* event_id */, std::unique_ptr<EventInfo>> new_id_event_map;
...@@ -187,7 +187,7 @@ void ServiceWorkerTimeoutTimer::UpdateStatus() { ...@@ -187,7 +187,7 @@ void ServiceWorkerTimeoutTimer::UpdateStatus() {
} }
} }
bool ServiceWorkerTimeoutTimer::MaybeTriggerIdleTimer() { bool ServiceWorkerEventQueue::MaybeTriggerIdleTimer() {
DCHECK(!HasInflightEvent()); DCHECK(!HasInflightEvent());
if (!zero_idle_timer_delay_) if (!zero_idle_timer_delay_)
return false; return false;
...@@ -197,18 +197,18 @@ bool ServiceWorkerTimeoutTimer::MaybeTriggerIdleTimer() { ...@@ -197,18 +197,18 @@ bool ServiceWorkerTimeoutTimer::MaybeTriggerIdleTimer() {
return true; return true;
} }
void ServiceWorkerTimeoutTimer::OnNoInflightEvent() { void ServiceWorkerEventQueue::OnNoInflightEvent() {
DCHECK(!HasInflightEvent()); DCHECK(!HasInflightEvent());
idle_time_ = tick_clock_->NowTicks() + kIdleDelay; idle_time_ = tick_clock_->NowTicks() + kIdleDelay;
MaybeTriggerIdleTimer(); MaybeTriggerIdleTimer();
} }
bool ServiceWorkerTimeoutTimer::HasInflightEvent() const { bool ServiceWorkerEventQueue::HasInflightEvent() const {
return !id_event_map_.IsEmpty() || num_of_stay_awake_tokens_ > 0; return !id_event_map_.IsEmpty() || num_of_stay_awake_tokens_ > 0;
} }
ServiceWorkerTimeoutTimer::Task::Task( ServiceWorkerEventQueue::Task::Task(
ServiceWorkerTimeoutTimer::Task::Type type, ServiceWorkerEventQueue::Task::Type type,
StartCallback start_callback, StartCallback start_callback,
AbortCallback abort_callback, AbortCallback abort_callback,
base::Optional<base::TimeDelta> custom_timeout) base::Optional<base::TimeDelta> custom_timeout)
...@@ -217,15 +217,15 @@ ServiceWorkerTimeoutTimer::Task::Task( ...@@ -217,15 +217,15 @@ ServiceWorkerTimeoutTimer::Task::Task(
abort_callback(std::move(abort_callback)), abort_callback(std::move(abort_callback)),
custom_timeout(custom_timeout) {} custom_timeout(custom_timeout) {}
ServiceWorkerTimeoutTimer::Task::~Task() = default; ServiceWorkerEventQueue::Task::~Task() = default;
ServiceWorkerTimeoutTimer::EventInfo::EventInfo( ServiceWorkerEventQueue::EventInfo::EventInfo(
base::TimeTicks expiration_time, base::TimeTicks expiration_time,
base::OnceCallback<void(blink::mojom::ServiceWorkerEventStatus)> base::OnceCallback<void(blink::mojom::ServiceWorkerEventStatus)>
abort_callback) abort_callback)
: expiration_time(expiration_time), : expiration_time(expiration_time),
abort_callback(std::move(abort_callback)) {} abort_callback(std::move(abort_callback)) {}
ServiceWorkerTimeoutTimer::EventInfo::~EventInfo() = default; ServiceWorkerEventQueue::EventInfo::~EventInfo() = default;
} // namespace blink } // namespace blink
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_TIMEOUT_TIMER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_EVENT_QUEUE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_TIMEOUT_TIMER_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_EVENT_QUEUE_H_
#include <set> #include <set>
...@@ -24,7 +24,7 @@ class TickClock; ...@@ -24,7 +24,7 @@ class TickClock;
namespace blink { namespace blink {
// ServiceWorkerTimeoutTimer manages two types of timeouts: the long standing // ServiceWorkerEventQueue manages two types of timeouts: the long standing
// event timeout and the idle timeout. // event timeout and the idle timeout.
// //
// 1) Event timeout: when an event starts, StartEvent() records the expiration // 1) Event timeout: when an event starts, StartEvent() records the expiration
...@@ -33,39 +33,39 @@ namespace blink { ...@@ -33,39 +33,39 @@ namespace blink {
// status TIMEOUT. Also, |zero_idle_timer_delay_| is set to true to shut down // status TIMEOUT. Also, |zero_idle_timer_delay_| is set to true to shut down
// the worker as soon as possible since the worker may have gone into bad state. // the worker as soon as possible since the worker may have gone into bad state.
// 2) Idle timeout: when a certain time has passed (kIdleDelay) since all of // 2) Idle timeout: when a certain time has passed (kIdleDelay) since all of
// events have ended, ServiceWorkerTimeoutTimer calls the |idle_callback|. // events have ended, ServiceWorkerEventQueue calls the |idle_callback|.
// |idle_callback| will be continuously called at a certain interval // |idle_callback| will be continuously called at a certain interval
// (kUpdateInterval) until the next event starts. // (kUpdateInterval) until the next event starts.
// //
// The lifetime of ServiceWorkerTimeoutTimer is the same with the worker // The lifetime of ServiceWorkerEventQueue is the same with the worker
// thread. If ServiceWorkerTimeoutTimer is destructed while there are inflight // thread. If ServiceWorkerEventQueue is destructed while there are inflight
// events, all |abort_callback|s will be immediately called with status ABORTED. // events, all |abort_callback|s will be immediately called with status ABORTED.
class MODULES_EXPORT ServiceWorkerTimeoutTimer { class MODULES_EXPORT ServiceWorkerEventQueue {
public: public:
// A token to keep the timeout timer from going into the idle state if any of // A token to keep the event queue from going into the idle state if any of
// them are alive. // them are alive.
class MODULES_EXPORT StayAwakeToken { class MODULES_EXPORT StayAwakeToken {
public: public:
explicit StayAwakeToken(base::WeakPtr<ServiceWorkerTimeoutTimer> timer); explicit StayAwakeToken(base::WeakPtr<ServiceWorkerEventQueue> event_queue);
~StayAwakeToken(); ~StayAwakeToken();
private: private:
base::WeakPtr<ServiceWorkerTimeoutTimer> timer_; base::WeakPtr<ServiceWorkerEventQueue> event_queue_;
}; };
using AbortCallback = using AbortCallback =
base::OnceCallback<void(int /* event_id */, base::OnceCallback<void(int /* event_id */,
mojom::blink::ServiceWorkerEventStatus)>; mojom::blink::ServiceWorkerEventStatus)>;
explicit ServiceWorkerTimeoutTimer(base::RepeatingClosure idle_callback); explicit ServiceWorkerEventQueue(base::RepeatingClosure idle_callback);
// For testing. // For testing.
ServiceWorkerTimeoutTimer(base::RepeatingClosure idle_callback, ServiceWorkerEventQueue(base::RepeatingClosure idle_callback,
const base::TickClock* tick_clock); const base::TickClock* tick_clock);
~ServiceWorkerTimeoutTimer(); ~ServiceWorkerEventQueue();
// Starts the timer. This may also update |idle_time_| if there was no // Starts the event_queue. This may also update |idle_time_| if there was no
// activities (i.e., StartEvent()/EndEvent() or StayAwakeToken creation) // activities (i.e., StartEvent()/EndEvent() or StayAwakeToken creation)
// on the timer before. // on the event_queue before.
void Start(); void Start();
using StartCallback = base::OnceCallback<void(int /* event_id */)>; using StartCallback = base::OnceCallback<void(int /* event_id */)>;
...@@ -93,12 +93,12 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer { ...@@ -93,12 +93,12 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer {
base::Optional<base::TimeDelta> custom_timeout); base::Optional<base::TimeDelta> custom_timeout);
~Task(); ~Task();
Type type; Type type;
// Callback which is run when the timer starts this task. The // Callback which is run when the event_queue starts this task. The
// callback receives |event_id|, which is the result of // callback receives |event_id|, which is the result of
// StartEvent(). When an event finishes, EndEvent() should be // StartEvent(). When an event finishes, EndEvent() should be
// called with the given |event_id|. // called with the given |event_id|.
StartCallback start_callback; StartCallback start_callback;
// Callback which is run when the timer aborts a started task. // Callback which is run when the event_queue aborts a started task.
AbortCallback abort_callback; AbortCallback abort_callback;
// The custom timeout value. // The custom timeout value.
base::Optional<base::TimeDelta> custom_timeout; base::Optional<base::TimeDelta> custom_timeout;
...@@ -106,8 +106,8 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer { ...@@ -106,8 +106,8 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer {
void EndEvent(int event_id); void EndEvent(int event_id);
// Push the task to the task queue in the timer and tasks in the queue can run // Push the task to the queue, and tasks in the queue can run synchronously.
// synchronously. See also Task's comment. // See also Task's comment.
void PushTask(std::unique_ptr<Task> task); void PushTask(std::unique_ptr<Task> task);
// Returns true if |event_id| was started and hasn't ended. // Returns true if |event_id| was started and hasn't ended.
...@@ -134,7 +134,7 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer { ...@@ -134,7 +134,7 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer {
// called. // called.
static constexpr base::TimeDelta kEventTimeout = static constexpr base::TimeDelta kEventTimeout =
base::TimeDelta::FromMinutes(5); base::TimeDelta::FromMinutes(5);
// ServiceWorkerTimeoutTimer periodically updates the timeout state by // ServiceWorkerEventQueue periodically updates the timeout state by
// kUpdateInterval. // kUpdateInterval.
static constexpr base::TimeDelta kUpdateInterval = static constexpr base::TimeDelta kUpdateInterval =
base::TimeDelta::FromSeconds(30); base::TimeDelta::FromSeconds(30);
...@@ -214,9 +214,9 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer { ...@@ -214,9 +214,9 @@ class MODULES_EXPORT ServiceWorkerTimeoutTimer {
bool in_dtor_ = false; bool in_dtor_ = false;
base::WeakPtrFactory<ServiceWorkerTimeoutTimer> weak_factory_{this}; base::WeakPtrFactory<ServiceWorkerEventQueue> weak_factory_{this};
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_TIMEOUT_TIMER_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_SERVICE_WORKER_EVENT_QUEUE_H_
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include "third_party/blink/renderer/bindings/core/v8/request_or_usv_string.h" #include "third_party/blink/renderer/bindings/core/v8/request_or_usv_string.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_event_queue.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_timeout_timer.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
...@@ -168,9 +168,9 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final ...@@ -168,9 +168,9 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final
// PauseEvaluation() is called. // PauseEvaluation() is called.
void ResumeEvaluation(); void ResumeEvaluation();
// Creates a ServiceWorkerTimeoutTimer::StayAwakeToken to ensure that the idle // Creates a ServiceWorkerEventQueue::StayAwakeToken to ensure that the idle
// timer won't be triggered while any of these are alive. // timer won't be triggered while any of these are alive.
std::unique_ptr<ServiceWorkerTimeoutTimer::StayAwakeToken> std::unique_ptr<ServiceWorkerEventQueue::StayAwakeToken>
CreateStayAwakeToken(); CreateStayAwakeToken();
// Returns the ServiceWorker object described by the given info. Creates a new // Returns the ServiceWorker object described by the given info. Creates a new
...@@ -338,7 +338,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final ...@@ -338,7 +338,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final
// number of scripts and the total bytes of scripts. // number of scripts and the total bytes of scripts.
void CountScriptInternal(size_t script_size, size_t cached_metadata_size); void CountScriptInternal(size_t script_size, size_t cached_metadata_size);
// Called by ServiceWorkerTimeoutTimer when a certain time has passed since // Called by ServiceWorkerEventQueue when a certain time has passed since
// the last task finished. // the last task finished.
void OnIdleTimeout(); void OnIdleTimeout();
...@@ -583,7 +583,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final ...@@ -583,7 +583,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final
mojo::Receiver<mojom::blink::ServiceWorker> receiver_{this}; mojo::Receiver<mojom::blink::ServiceWorker> receiver_{this};
// Maps for inflight event callbacks. // Maps for inflight event callbacks.
// These are mapped from an event id issued from ServiceWorkerTimeoutTimer to // These are mapped from an event id issued from ServiceWorkerEventQueue to
// the Mojo callback to notify the end of the event. // the Mojo callback to notify the end of the event.
HashMap<int, DispatchInstallEventCallback> install_event_callbacks_; HashMap<int, DispatchInstallEventCallback> install_event_callbacks_;
HashMap<int, DispatchActivateEventCallback> activate_event_callbacks_; HashMap<int, DispatchActivateEventCallback> activate_event_callbacks_;
...@@ -643,7 +643,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final ...@@ -643,7 +643,7 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final
// Timer triggered when the service worker considers it should be stopped or // Timer triggered when the service worker considers it should be stopped or
// an event should be aborted. // an event should be aborted.
std::unique_ptr<ServiceWorkerTimeoutTimer> timeout_timer_; std::unique_ptr<ServiceWorkerEventQueue> event_queue_;
// InitializeGlobalScope() pauses the top level script evaluation when this // InitializeGlobalScope() pauses the top level script evaluation when this
// flag is true. // flag is true.
...@@ -653,9 +653,9 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final ...@@ -653,9 +653,9 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final
// Connected by the ServiceWorkerProviderHost in the browser process and by // Connected by the ServiceWorkerProviderHost in the browser process and by
// the controllees. |controller_bindings_| should be destroyed before // the controllees. |controller_bindings_| should be destroyed before
// |timeout_timer_| since the pipe needs to be disconnected before callbacks // |event_queue_| since the pipe needs to be disconnected before callbacks
// passed by DispatchSomeEvent() get destructed, which may be stored in // passed by DispatchSomeEvent() get destructed, which may be stored in
// |timeout_timer_|. // |event_queue_|.
// network::mojom::blink::CrossOriginEmbedderPolicy set as the context of // network::mojom::blink::CrossOriginEmbedderPolicy set as the context of
// mojo::ReceiverSet is the policy for the client which dispatches FetchEvents // mojo::ReceiverSet is the policy for the client which dispatches FetchEvents
// to the ControllerServiceWorker. It should be referred to before sending the // to the ControllerServiceWorker. It should be referred to before sending the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment