OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 // An implementation of WebThread in terms of base::MessageLoop and | 5 // An implementation of WebThread in terms of base::MessageLoop and |
6 // base::Thread | 6 // base::Thread |
7 | 7 |
8 #include "public/platform/scheduler/child/webthread_base.h" | 8 #include "public/platform/scheduler/child/webthread_base.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/pending_task.h" | 13 #include "base/pending_task.h" |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "public/platform/WebTraceLocation.h" |
15 #include "public/platform/scheduler/child/single_thread_idle_task_runner.h" | 16 #include "public/platform/scheduler/child/single_thread_idle_task_runner.h" |
16 #include "public/platform/WebTraceLocation.h" | |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 namespace scheduler { | 19 namespace scheduler { |
20 | 20 |
21 class WebThreadBase::TaskObserverAdapter | 21 class WebThreadBase::TaskObserverAdapter |
22 : public base::MessageLoop::TaskObserver { | 22 : public base::MessageLoop::TaskObserver { |
23 public: | 23 public: |
24 explicit TaskObserverAdapter(WebThread::TaskObserver* observer) | 24 explicit TaskObserverAdapter(WebThread::TaskObserver* observer) |
25 : observer_(observer) {} | 25 : observer_(observer) {} |
26 | 26 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return; | 60 return; |
61 RemoveTaskObserverInternal(iter->second); | 61 RemoveTaskObserverInternal(iter->second); |
62 delete iter->second; | 62 delete iter->second; |
63 task_observer_map_.erase(iter); | 63 task_observer_map_.erase(iter); |
64 } | 64 } |
65 | 65 |
66 void WebThreadBase::addTaskTimeObserver(TaskTimeObserver* task_time_observer) { | 66 void WebThreadBase::addTaskTimeObserver(TaskTimeObserver* task_time_observer) { |
67 AddTaskTimeObserverInternal(task_time_observer); | 67 AddTaskTimeObserverInternal(task_time_observer); |
68 } | 68 } |
69 | 69 |
70 void WebThreadBase::removeTaskTimeObserver(TaskTimeObserver* task_time_observer)
{ | 70 void WebThreadBase::removeTaskTimeObserver( |
| 71 TaskTimeObserver* task_time_observer) { |
71 RemoveTaskTimeObserverInternal(task_time_observer); | 72 RemoveTaskTimeObserverInternal(task_time_observer); |
72 } | 73 } |
73 | 74 |
74 void WebThreadBase::AddTaskObserverInternal( | 75 void WebThreadBase::AddTaskObserverInternal( |
75 base::MessageLoop::TaskObserver* observer) { | 76 base::MessageLoop::TaskObserver* observer) { |
76 base::MessageLoop::current()->AddTaskObserver(observer); | 77 base::MessageLoop::current()->AddTaskObserver(observer); |
77 } | 78 } |
78 | 79 |
79 void WebThreadBase::RemoveTaskObserverInternal( | 80 void WebThreadBase::RemoveTaskObserverInternal( |
80 base::MessageLoop::TaskObserver* observer) { | 81 base::MessageLoop::TaskObserver* observer) { |
(...skipping 13 matching lines...) Expand all Loading... |
94 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, | 95 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
95 base::Passed(base::WrapUnique(idle_task)))); | 96 base::Passed(base::WrapUnique(idle_task)))); |
96 } | 97 } |
97 | 98 |
98 bool WebThreadBase::isCurrentThread() const { | 99 bool WebThreadBase::isCurrentThread() const { |
99 return GetTaskRunner()->BelongsToCurrentThread(); | 100 return GetTaskRunner()->BelongsToCurrentThread(); |
100 } | 101 } |
101 | 102 |
102 } // namespace scheduler | 103 } // namespace scheduler |
103 } // namespace blink | 104 } // namespace blink |
OLD | NEW |