Commit df19039a authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Replace use of std containers with WTF's equivalents in scheduler/*

This CL replaces the use of std::unordered_set and
std::unordered_map of std containers with WTF::HashSet and
WTF::HashMap in scheduler/*, and removes unnecessary including
<unordered_set> and <unordered_map> headers.

Bug: 952716
Change-Id: I40fa847083b8883bcc5b22ae9c5d6295aaa04219
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692402Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#676913}
parent 495db68b
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_gc_controller.h" #include "third_party/blink/renderer/bindings/core/v8/v8_gc_controller.h"
#include <algorithm> #include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include "third_party/blink/public/platform/blame_context.h" #include "third_party/blink/public/platform/blame_context.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_FACTORY_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_FACTORY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_FACTORY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_FACTORY_H_
#include <unordered_map>
#include "third_party/blink/public/platform/web_pointer_event.h" #include "third_party/blink/public/platform/web_pointer_event.h"
#include "third_party/blink/public/platform/web_pointer_properties.h" #include "third_party/blink/public/platform/web_pointer_properties.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include <unordered_map>
namespace blink { namespace blink {
class DOMException; class DOMException;
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "third_party/blink/renderer/platform/heap/blink_gc_memory_dump_provider.h" #include "third_party/blink/renderer/platform/heap/blink_gc_memory_dump_provider.h"
#include <unordered_map>
#include "base/trace_event/memory_allocator_dump.h" #include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h" #include "base/trace_event/process_memory_dump.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "third_party/blink/renderer/platform/partition_alloc_memory_dump_provider.h" #include "third_party/blink/renderer/platform/partition_alloc_memory_dump_provider.h"
#include <unordered_map>
#include "base/allocator/partition_allocator/partition_alloc.h" #include "base/allocator/partition_allocator/partition_alloc.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
......
...@@ -72,7 +72,7 @@ FrameOrWorkerScheduler::AddLifecycleObserver(ObserverType type, ...@@ -72,7 +72,7 @@ FrameOrWorkerScheduler::AddLifecycleObserver(ObserverType type,
Observer* observer) { Observer* observer) {
DCHECK(observer); DCHECK(observer);
observer->OnLifecycleStateChanged(CalculateLifecycleState(type)); observer->OnLifecycleStateChanged(CalculateLifecycleState(type));
lifecycle_observers_[observer] = type; lifecycle_observers_.Set(observer, type);
return std::make_unique<LifecycleObserverHandle>(this, observer); return std::make_unique<LifecycleObserverHandle>(this, observer);
} }
...@@ -85,8 +85,8 @@ void FrameOrWorkerScheduler::RemoveLifecycleObserver(Observer* observer) { ...@@ -85,8 +85,8 @@ void FrameOrWorkerScheduler::RemoveLifecycleObserver(Observer* observer) {
void FrameOrWorkerScheduler::NotifyLifecycleObservers() { void FrameOrWorkerScheduler::NotifyLifecycleObservers() {
for (const auto& observer : lifecycle_observers_) { for (const auto& observer : lifecycle_observers_) {
observer.first->OnLifecycleStateChanged( observer.key->OnLifecycleStateChanged(
CalculateLifecycleState(observer.second)); CalculateLifecycleState(observer.value));
} }
} }
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_BUDGET_POOL_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_BUDGET_POOL_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_BUDGET_POOL_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_BUDGET_POOL_H_
#include <unordered_set>
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
...@@ -14,6 +12,7 @@ ...@@ -14,6 +12,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace base { namespace base {
namespace sequence_manager { namespace sequence_manager {
...@@ -114,8 +113,7 @@ class PLATFORM_EXPORT BudgetPool { ...@@ -114,8 +113,7 @@ class PLATFORM_EXPORT BudgetPool {
BudgetPoolController* budget_pool_controller_; BudgetPoolController* budget_pool_controller_;
std::unordered_set<base::sequence_manager::TaskQueue*> HashSet<base::sequence_manager::TaskQueue*> associated_task_queues_;
associated_task_queues_;
bool is_enabled_; bool is_enabled_;
private: private:
......
...@@ -90,7 +90,7 @@ TaskQueueThrottler::~TaskQueueThrottler() { ...@@ -90,7 +90,7 @@ TaskQueueThrottler::~TaskQueueThrottler() {
// It's possible for queues to be still throttled, so we need to tidy up // It's possible for queues to be still throttled, so we need to tidy up
// before unregistering the time domain. // before unregistering the time domain.
for (const TaskQueueMap::value_type& map_entry : queue_details_) { for (const TaskQueueMap::value_type& map_entry : queue_details_) {
TaskQueue* task_queue = map_entry.first; TaskQueue* task_queue = map_entry.key;
if (IsThrottled(task_queue)) { if (IsThrottled(task_queue)) {
task_queue->SetTimeDomain(thread_scheduler_->GetActiveTimeDomain()); task_queue->SetTimeDomain(thread_scheduler_->GetActiveTimeDomain());
task_queue->RemoveFence(); task_queue->RemoveFence();
...@@ -101,9 +101,9 @@ TaskQueueThrottler::~TaskQueueThrottler() { ...@@ -101,9 +101,9 @@ TaskQueueThrottler::~TaskQueueThrottler() {
} }
void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) { void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) {
std::pair<TaskQueueMap::iterator, bool> insert_result = queue_details_.insert( auto insert_result = queue_details_.insert(
std::make_pair(task_queue, Metadata(task_queue, this))); task_queue, std::make_unique<Metadata>(task_queue, this));
if (!insert_result.first->second.IncrementRefCount()) if (!insert_result.stored_value->value->IncrementRefCount())
return; return;
// Task queue is newly throttled. // Task queue is newly throttled.
...@@ -133,7 +133,7 @@ void TaskQueueThrottler::DecreaseThrottleRefCount(TaskQueue* task_queue) { ...@@ -133,7 +133,7 @@ void TaskQueueThrottler::DecreaseThrottleRefCount(TaskQueue* task_queue) {
if (iter == queue_details_.end()) if (iter == queue_details_.end())
return; return;
if (!iter->second.DecrementRefCount()) if (!iter->value->DecrementRefCount())
return; return;
TRACE_EVENT1("renderer.scheduler", "TaskQueueThrottler_TaskQueueUnthrottled", TRACE_EVENT1("renderer.scheduler", "TaskQueueThrottler_TaskQueueUnthrottled",
...@@ -155,7 +155,7 @@ bool TaskQueueThrottler::IsThrottled(TaskQueue* task_queue) const { ...@@ -155,7 +155,7 @@ bool TaskQueueThrottler::IsThrottled(TaskQueue* task_queue) const {
auto find_it = queue_details_.find(task_queue); auto find_it = queue_details_.find(task_queue);
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return false; return false;
return find_it->second.throttling_ref_count() > 0; return find_it->value->throttling_ref_count() > 0;
} }
void TaskQueueThrottler::ShutdownTaskQueue(TaskQueue* task_queue) { void TaskQueueThrottler::ShutdownTaskQueue(TaskQueue* task_queue) {
...@@ -169,7 +169,7 @@ void TaskQueueThrottler::ShutdownTaskQueue(TaskQueue* task_queue) { ...@@ -169,7 +169,7 @@ void TaskQueueThrottler::ShutdownTaskQueue(TaskQueue* task_queue) {
task_queue->RemoveFence(); task_queue->RemoveFence();
// Copy intended. // Copy intended.
std::unordered_set<BudgetPool*> budget_pools = find_it->second.budget_pools(); auto budget_pools = find_it->value->budget_pools();
for (BudgetPool* budget_pool : budget_pools) { for (BudgetPool* budget_pool : budget_pools) {
budget_pool->UnregisterQueue(task_queue); budget_pool->UnregisterQueue(task_queue);
} }
...@@ -206,7 +206,7 @@ void TaskQueueThrottler::OnQueueNextWakeUpChanged( ...@@ -206,7 +206,7 @@ void TaskQueueThrottler::OnQueueNextWakeUpChanged(
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return; return;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
budget_pool->OnQueueNextWakeUpChanged(queue, now, next_wake_up); budget_pool->OnQueueNextWakeUpChanged(queue, now, next_wake_up);
} }
...@@ -225,10 +225,10 @@ void TaskQueueThrottler::PumpThrottledTasks() { ...@@ -225,10 +225,10 @@ void TaskQueueThrottler::PumpThrottledTasks() {
LazyNow lazy_now(tick_clock_); LazyNow lazy_now(tick_clock_);
for (const auto& pair : budget_pools_) for (const auto& pair : budget_pools_)
pair.first->OnWakeUp(lazy_now.Now()); pair.key->OnWakeUp(lazy_now.Now());
for (const TaskQueueMap::value_type& map_entry : queue_details_) { for (const TaskQueueMap::value_type& map_entry : queue_details_) {
TaskQueue* task_queue = map_entry.first; TaskQueue* task_queue = map_entry.key;
UpdateQueueSchedulingLifecycleStateInternal(lazy_now.Now(), task_queue, UpdateQueueSchedulingLifecycleStateInternal(lazy_now.Now(), task_queue,
true); true);
} }
...@@ -279,14 +279,14 @@ CPUTimeBudgetPool* TaskQueueThrottler::CreateCPUTimeBudgetPool( ...@@ -279,14 +279,14 @@ CPUTimeBudgetPool* TaskQueueThrottler::CreateCPUTimeBudgetPool(
const char* name) { const char* name) {
CPUTimeBudgetPool* time_budget_pool = new CPUTimeBudgetPool( CPUTimeBudgetPool* time_budget_pool = new CPUTimeBudgetPool(
name, this, tracing_controller_, tick_clock_->NowTicks()); name, this, tracing_controller_, tick_clock_->NowTicks());
budget_pools_[time_budget_pool] = base::WrapUnique(time_budget_pool); budget_pools_.Set(time_budget_pool, base::WrapUnique(time_budget_pool));
return time_budget_pool; return time_budget_pool;
} }
WakeUpBudgetPool* TaskQueueThrottler::CreateWakeUpBudgetPool(const char* name) { WakeUpBudgetPool* TaskQueueThrottler::CreateWakeUpBudgetPool(const char* name) {
WakeUpBudgetPool* wake_up_budget_pool = WakeUpBudgetPool* wake_up_budget_pool =
new WakeUpBudgetPool(name, this, tick_clock_->NowTicks()); new WakeUpBudgetPool(name, this, tick_clock_->NowTicks());
budget_pools_[wake_up_budget_pool] = base::WrapUnique(wake_up_budget_pool); budget_pools_.Set(wake_up_budget_pool, base::WrapUnique(wake_up_budget_pool));
return wake_up_budget_pool; return wake_up_budget_pool;
} }
...@@ -300,7 +300,7 @@ void TaskQueueThrottler::OnTaskRunTimeReported(TaskQueue* task_queue, ...@@ -300,7 +300,7 @@ void TaskQueueThrottler::OnTaskRunTimeReported(TaskQueue* task_queue,
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return; return;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
budget_pool->RecordTaskRunTime(task_queue, start_time, end_time); budget_pool->RecordTaskRunTime(task_queue, start_time, end_time);
} }
} }
...@@ -402,7 +402,7 @@ base::Optional<QueueBlockType> TaskQueueThrottler::GetQueueBlockType( ...@@ -402,7 +402,7 @@ base::Optional<QueueBlockType> TaskQueueThrottler::GetQueueBlockType(
bool has_new_tasks_only_block = false; bool has_new_tasks_only_block = false;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
if (!budget_pool->CanRunTasksAt(now, false)) { if (!budget_pool->CanRunTasksAt(now, false)) {
if (budget_pool->GetBlockType() == QueueBlockType::kAllTasks) if (budget_pool->GetBlockType() == QueueBlockType::kAllTasks)
return QueueBlockType::kAllTasks; return QueueBlockType::kAllTasks;
...@@ -428,17 +428,17 @@ void TaskQueueThrottler::AsValueInto(base::trace_event::TracedValue* state, ...@@ -428,17 +428,17 @@ void TaskQueueThrottler::AsValueInto(base::trace_event::TracedValue* state,
state->BeginDictionary("time_budget_pools"); state->BeginDictionary("time_budget_pools");
for (const auto& map_entry : budget_pools_) { for (const auto& map_entry : budget_pools_) {
BudgetPool* pool = map_entry.first; BudgetPool* pool = map_entry.key;
pool->AsValueInto(state, now); pool->AsValueInto(state, now);
} }
state->EndDictionary(); state->EndDictionary();
state->BeginDictionary("queue_details"); state->BeginDictionary("queue_details");
for (const auto& map_entry : queue_details_) { for (const auto& map_entry : queue_details_) {
state->BeginDictionaryWithCopiedName(PointerToString(map_entry.first)); state->BeginDictionaryWithCopiedName(PointerToString(map_entry.key));
state->SetInteger( state->SetInteger(
"throttling_ref_count", "throttling_ref_count",
static_cast<int>(map_entry.second.throttling_ref_count())); static_cast<int>(map_entry.value->throttling_ref_count()));
state->EndDictionary(); state->EndDictionary();
} }
state->EndDictionary(); state->EndDictionary();
...@@ -446,25 +446,25 @@ void TaskQueueThrottler::AsValueInto(base::trace_event::TracedValue* state, ...@@ -446,25 +446,25 @@ void TaskQueueThrottler::AsValueInto(base::trace_event::TracedValue* state,
void TaskQueueThrottler::AddQueueToBudgetPool(TaskQueue* queue, void TaskQueueThrottler::AddQueueToBudgetPool(TaskQueue* queue,
BudgetPool* budget_pool) { BudgetPool* budget_pool) {
std::pair<TaskQueueMap::iterator, bool> insert_result = auto insert_result =
queue_details_.insert(std::make_pair(queue, Metadata(queue, this))); queue_details_.insert(queue, std::make_unique<Metadata>(queue, this));
Metadata& metadata = insert_result.first->second; Metadata* metadata = insert_result.stored_value->value.get();
DCHECK(metadata.budget_pools().find(budget_pool) == DCHECK(metadata->budget_pools().find(budget_pool) ==
metadata.budget_pools().end()); metadata->budget_pools().end());
metadata.budget_pools().insert(budget_pool); metadata->budget_pools().insert(budget_pool);
} }
void TaskQueueThrottler::RemoveQueueFromBudgetPool(TaskQueue* queue, void TaskQueueThrottler::RemoveQueueFromBudgetPool(TaskQueue* queue,
BudgetPool* budget_pool) { BudgetPool* budget_pool) {
auto find_it = queue_details_.find(queue); auto find_it = queue_details_.find(queue);
DCHECK(find_it != queue_details_.end() && DCHECK(find_it != queue_details_.end() &&
find_it->second.budget_pools().find(budget_pool) != find_it->value->budget_pools().find(budget_pool) !=
find_it->second.budget_pools().end()); find_it->value->budget_pools().end());
find_it->second.budget_pools().erase(budget_pool); find_it->value->budget_pools().erase(budget_pool);
MaybeDeleteQueueMetadata(find_it); MaybeDeleteQueueMetadata(find_it);
} }
...@@ -482,7 +482,7 @@ base::TimeTicks TaskQueueThrottler::GetNextAllowedRunTime( ...@@ -482,7 +482,7 @@ base::TimeTicks TaskQueueThrottler::GetNextAllowedRunTime(
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return next_run_time; return next_run_time;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
next_run_time = std::max( next_run_time = std::max(
next_run_time, budget_pool->GetNextAllowedRunTime(desired_run_time)); next_run_time, budget_pool->GetNextAllowedRunTime(desired_run_time));
} }
...@@ -497,7 +497,7 @@ bool TaskQueueThrottler::CanRunTasksAt(TaskQueue* queue, ...@@ -497,7 +497,7 @@ bool TaskQueueThrottler::CanRunTasksAt(TaskQueue* queue,
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return true; return true;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
if (!budget_pool->CanRunTasksAt(moment, is_wake_up)) if (!budget_pool->CanRunTasksAt(moment, is_wake_up))
return false; return false;
} }
...@@ -514,7 +514,7 @@ base::Optional<base::TimeTicks> TaskQueueThrottler::GetTimeTasksCanRunUntil( ...@@ -514,7 +514,7 @@ base::Optional<base::TimeTicks> TaskQueueThrottler::GetTimeTasksCanRunUntil(
if (find_it == queue_details_.end()) if (find_it == queue_details_.end())
return result; return result;
for (BudgetPool* budget_pool : find_it->second.budget_pools()) { for (BudgetPool* budget_pool : find_it->value->budget_pools()) {
result = Min(result, budget_pool->GetTimeTasksCanRunUntil(now, is_wake_up)); result = Min(result, budget_pool->GetTimeTasksCanRunUntil(now, is_wake_up));
} }
...@@ -522,8 +522,8 @@ base::Optional<base::TimeTicks> TaskQueueThrottler::GetTimeTasksCanRunUntil( ...@@ -522,8 +522,8 @@ base::Optional<base::TimeTicks> TaskQueueThrottler::GetTimeTasksCanRunUntil(
} }
void TaskQueueThrottler::MaybeDeleteQueueMetadata(TaskQueueMap::iterator it) { void TaskQueueThrottler::MaybeDeleteQueueMetadata(TaskQueueMap::iterator it) {
if (it->second.throttling_ref_count() == 0 && if (it->value->throttling_ref_count() == 0 &&
it->second.budget_pools().empty()) { it->value->budget_pools().IsEmpty()) {
queue_details_.erase(it); queue_details_.erase(it);
} }
} }
...@@ -535,10 +535,10 @@ void TaskQueueThrottler::DisableThrottling() { ...@@ -535,10 +535,10 @@ void TaskQueueThrottler::DisableThrottling() {
allow_throttling_ = false; allow_throttling_ = false;
for (const auto& map_entry : queue_details_) { for (const auto& map_entry : queue_details_) {
if (map_entry.second.throttling_ref_count() == 0) if (map_entry.value->throttling_ref_count() == 0)
continue; continue;
TaskQueue* queue = map_entry.first; TaskQueue* queue = map_entry.key;
queue->SetTimeDomain(thread_scheduler_->GetActiveTimeDomain()); queue->SetTimeDomain(thread_scheduler_->GetActiveTimeDomain());
queue->RemoveFence(); queue->RemoveFence();
...@@ -559,10 +559,10 @@ void TaskQueueThrottler::EnableThrottling() { ...@@ -559,10 +559,10 @@ void TaskQueueThrottler::EnableThrottling() {
LazyNow lazy_now(tick_clock_); LazyNow lazy_now(tick_clock_);
for (const auto& map_entry : queue_details_) { for (const auto& map_entry : queue_details_) {
if (map_entry.second.throttling_ref_count() == 0) if (map_entry.value->throttling_ref_count() == 0)
continue; continue;
TaskQueue* queue = map_entry.first; TaskQueue* queue = map_entry.key;
// Throttling is enabled and task queue should be blocked immediately // Throttling is enabled and task queue should be blocked immediately
// to enforce task alignment. // to enforce task alignment.
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_
#include <unordered_map>
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -20,6 +18,8 @@ ...@@ -20,6 +18,8 @@
#include "third_party/blink/renderer/platform/scheduler/common/throttling/cpu_time_budget_pool.h" #include "third_party/blink/renderer/platform/scheduler/common/throttling/cpu_time_budget_pool.h"
#include "third_party/blink/renderer/platform/scheduler/common/throttling/wake_up_budget_pool.h" #include "third_party/blink/renderer/platform/scheduler/common/throttling/wake_up_budget_pool.h"
#include "third_party/blink/renderer/platform/scheduler/common/tracing_helper.h" #include "third_party/blink/renderer/platform/scheduler/common/tracing_helper.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace base { namespace base {
namespace trace_event { namespace trace_event {
...@@ -174,20 +174,19 @@ class PLATFORM_EXPORT TaskQueueThrottler : public BudgetPoolController { ...@@ -174,20 +174,19 @@ class PLATFORM_EXPORT TaskQueueThrottler : public BudgetPoolController {
size_t throttling_ref_count() const { return throttling_ref_count_; } size_t throttling_ref_count() const { return throttling_ref_count_; }
const std::unordered_set<BudgetPool*>& budget_pools() const { const HashSet<BudgetPool*>& budget_pools() const { return budget_pools_; }
return budget_pools_;
}
std::unordered_set<BudgetPool*>& budget_pools() { return budget_pools_; } HashSet<BudgetPool*>& budget_pools() { return budget_pools_; }
private: private:
base::sequence_manager::TaskQueue* const queue_; base::sequence_manager::TaskQueue* const queue_;
TaskQueueThrottler* const throttler_; TaskQueueThrottler* const throttler_;
size_t throttling_ref_count_ = 0; size_t throttling_ref_count_ = 0;
std::unordered_set<BudgetPool*> budget_pools_; HashSet<BudgetPool*> budget_pools_;
}; };
using TaskQueueMap = using TaskQueueMap =
std::unordered_map<base::sequence_manager::TaskQueue*, Metadata>; HashMap<base::sequence_manager::TaskQueue*, std::unique_ptr<Metadata>>;
void PumpThrottledTasks(); void PumpThrottledTasks();
...@@ -238,7 +237,7 @@ class PLATFORM_EXPORT TaskQueueThrottler : public BudgetPoolController { ...@@ -238,7 +237,7 @@ class PLATFORM_EXPORT TaskQueueThrottler : public BudgetPoolController {
base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_;
bool allow_throttling_; bool allow_throttling_;
std::unordered_map<BudgetPool*, std::unique_ptr<BudgetPool>> budget_pools_; HashMap<BudgetPool*, std::unique_ptr<BudgetPool>> budget_pools_;
base::WeakPtrFactory<TaskQueueThrottler> weak_factory_{this}; base::WeakPtrFactory<TaskQueueThrottler> weak_factory_{this};
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "third_party/blink/renderer/platform/scheduler/common/tracing_helper.h" #include "third_party/blink/renderer/platform/scheduler/common/tracing_helper.h"
#include <unordered_set>
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
......
...@@ -5,13 +5,12 @@ ...@@ -5,13 +5,12 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_FRAME_OR_WORKER_SCHEDULER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_FRAME_OR_WORKER_SCHEDULER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_FRAME_OR_WORKER_SCHEDULER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_FRAME_OR_WORKER_SCHEDULER_H_
#include <unordered_map>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/scheduler/public/scheduling_lifecycle_state.h" #include "third_party/blink/renderer/platform/scheduler/public/scheduling_lifecycle_state.h"
#include "third_party/blink/renderer/platform/scheduler/public/scheduling_policy.h" #include "third_party/blink/renderer/platform/scheduler/public/scheduling_policy.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
namespace blink { namespace blink {
class FrameScheduler; class FrameScheduler;
...@@ -137,7 +136,7 @@ class PLATFORM_EXPORT FrameOrWorkerScheduler { ...@@ -137,7 +136,7 @@ class PLATFORM_EXPORT FrameOrWorkerScheduler {
void RemoveLifecycleObserver(Observer* observer); void RemoveLifecycleObserver(Observer* observer);
// Observers are not owned by the scheduler. // Observers are not owned by the scheduler.
std::unordered_map<Observer*, ObserverType> lifecycle_observers_; HashMap<Observer*, ObserverType> lifecycle_observers_;
base::WeakPtrFactory<FrameOrWorkerScheduler> weak_factory_{this}; base::WeakPtrFactory<FrameOrWorkerScheduler> weak_factory_{this};
}; };
......
...@@ -67,7 +67,7 @@ class WorkerThreadSchedulerForTest : public WorkerThreadScheduler { ...@@ -67,7 +67,7 @@ class WorkerThreadSchedulerForTest : public WorkerThreadScheduler {
WorkerSchedulerProxy* proxy) WorkerSchedulerProxy* proxy)
: WorkerThreadScheduler(thread_type, manager, proxy) {} : WorkerThreadScheduler(thread_type, manager, proxy) {}
const std::unordered_set<WorkerScheduler*>& worker_schedulers() { const HashSet<WorkerScheduler*>& worker_schedulers() {
return GetWorkerSchedulersForTesting(); return GetWorkerSchedulersForTesting();
} }
......
...@@ -123,7 +123,7 @@ WorkerThreadScheduler::~WorkerThreadScheduler() { ...@@ -123,7 +123,7 @@ WorkerThreadScheduler::~WorkerThreadScheduler() {
TRACE_EVENT_OBJECT_DELETED_WITH_ID( TRACE_EVENT_OBJECT_DELETED_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("worker.scheduler"), "WorkerScheduler", this); TRACE_DISABLED_BY_DEFAULT("worker.scheduler"), "WorkerScheduler", this);
DCHECK(worker_schedulers_.empty()); DCHECK(worker_schedulers_.IsEmpty());
} }
scoped_refptr<SingleThreadIdleTaskRunner> scoped_refptr<SingleThreadIdleTaskRunner>
...@@ -308,7 +308,7 @@ void WorkerThreadScheduler::SetCPUTimeBudgetPoolForTesting( ...@@ -308,7 +308,7 @@ void WorkerThreadScheduler::SetCPUTimeBudgetPoolForTesting(
cpu_time_budget_pool_ = cpu_time_budget_pool; cpu_time_budget_pool_ = cpu_time_budget_pool;
} }
std::unordered_set<WorkerScheduler*>& HashSet<WorkerScheduler*>&
WorkerThreadScheduler::GetWorkerSchedulersForTesting() { WorkerThreadScheduler::GetWorkerSchedulersForTesting() {
return worker_schedulers_; return worker_schedulers_;
} }
......
...@@ -120,7 +120,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler : public NonMainThreadSchedulerImpl, ...@@ -120,7 +120,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler : public NonMainThreadSchedulerImpl,
void SetCPUTimeBudgetPoolForTesting(CPUTimeBudgetPool* cpu_time_budget_pool); void SetCPUTimeBudgetPoolForTesting(CPUTimeBudgetPool* cpu_time_budget_pool);
std::unordered_set<WorkerScheduler*>& GetWorkerSchedulersForTesting(); HashSet<WorkerScheduler*>& GetWorkerSchedulersForTesting();
void SetUkmTaskSamplingRateForTest(double rate); void SetUkmTaskSamplingRateForTest(double rate);
void SetUkmRecorderForTest(std::unique_ptr<ukm::UkmRecorder> ukm_recorder); void SetUkmRecorderForTest(std::unique_ptr<ukm::UkmRecorder> ukm_recorder);
...@@ -150,7 +150,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler : public NonMainThreadSchedulerImpl, ...@@ -150,7 +150,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler : public NonMainThreadSchedulerImpl,
TraceableVariableController traceable_variable_controller_; TraceableVariableController traceable_variable_controller_;
// Worker schedulers associated with this thread. // Worker schedulers associated with this thread.
std::unordered_set<WorkerScheduler*> worker_schedulers_; HashSet<WorkerScheduler*> worker_schedulers_;
std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; std::unique_ptr<TaskQueueThrottler> task_queue_throttler_;
// Owned by |task_queue_throttler_|. // Owned by |task_queue_throttler_|.
......
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