cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / child / worker_task_runner.h
blob24ae41abb79cda514b077c302d96e644f4a1f59d
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_WORKER_TASK_RUNNER_H_
6 #define CONTENT_CHILD_WORKER_TASK_RUNNER_H_
8 #include <map>
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/platform_thread.h"
14 #include "content/common/content_export.h"
15 #include "content/public/child/worker_thread.h"
17 namespace base {
18 class TaskRunner;
21 namespace content {
23 class CONTENT_EXPORT WorkerTaskRunner {
24 public:
25 WorkerTaskRunner();
27 bool PostTask(int id, const base::Closure& task);
28 int PostTaskToAllThreads(const base::Closure& task);
29 static WorkerTaskRunner* Instance();
31 void DidStartWorkerRunLoop();
32 void WillStopWorkerRunLoop();
34 base::TaskRunner* GetTaskRunnerFor(int worker_id);
36 private:
37 friend class WorkerTaskRunnerTest;
39 using IDToTaskRunnerMap = std::map<base::PlatformThreadId, base::TaskRunner*>;
41 ~WorkerTaskRunner();
43 // It is possible for an IPC message to arrive for a worker thread that has
44 // already gone away. In such cases, it is still necessary to provide a
45 // task-runner for that particular thread, because otherwise the message will
46 // end up being handled as per usual in the main-thread, causing incorrect
47 // results. |task_runner_for_dead_worker_| is used to handle such messages,
48 // which silently discards all the tasks it receives.
49 scoped_refptr<base::TaskRunner> task_runner_for_dead_worker_;
51 IDToTaskRunnerMap task_runner_map_;
52 base::Lock task_runner_map_lock_;
55 } // namespace content
57 #endif // CONTENT_CHILD_WORKER_TASK_RUNNER_H_