#ifndef CONTENT_RENDERER_WORKER_WORKER_THREAD_REGISTRY_H_
#define CONTENT_RENDERER_WORKER_WORKER_THREAD_REGISTRY_H_
#include <map>
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "content/common/content_export.h"
#include "content/public/renderer/worker_thread.h"
namespace base {
class SequencedTaskRunner;
}
namespace content {
class CONTENT_EXPORT WorkerThreadRegistry {
public:
WorkerThreadRegistry();
int PostTaskToAllThreads(const base::RepeatingClosure& task);
static WorkerThreadRegistry* Instance();
void DidStartCurrentWorkerThread();
void WillStopCurrentWorkerThread();
base::SequencedTaskRunner* GetTaskRunnerFor(int worker_id);
private:
friend class WorkerThread;
friend class WorkerThreadRegistryTest;
bool PostTask(int id, base::OnceClosure task);
~WorkerThreadRegistry();
scoped_refptr<base::SequencedTaskRunner> task_runner_for_dead_worker_;
std::map<int , base::SequencedTaskRunner*>
task_runner_map_;
base::Lock task_runner_map_lock_;
};
}
#endif