OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "remoting/base/plugin_message_loop_proxy.h" | 5 #include "remoting/base/plugin_message_loop_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 bool PluginMessageLoopProxy::PostNonNestableDelayedTask( | 54 bool PluginMessageLoopProxy::PostNonNestableDelayedTask( |
55 const tracked_objects::Location& from_here, | 55 const tracked_objects::Location& from_here, |
56 const base::Closure& task, | 56 const base::Closure& task, |
57 int64 delay_ms) { | 57 int64 delay_ms) { |
58 // All tasks running on this message loop are non-nestable. | 58 // All tasks running on this message loop are non-nestable. |
59 return PostDelayedTask(from_here, task, delay_ms); | 59 return PostDelayedTask(from_here, task, delay_ms); |
60 } | 60 } |
61 | 61 |
62 bool PluginMessageLoopProxy::BelongsToCurrentThread() { | 62 bool PluginMessageLoopProxy::RunsTasksOnCurrentThread() const { |
63 // In pepper plugins ideally we should use pp::Core::IsMainThread, | 63 // In pepper plugins ideally we should use pp::Core::IsMainThread, |
64 // but it is problematic because we would need to keep reference to | 64 // but it is problematic because we would need to keep reference to |
65 // Core somewhere, e.g. make the delegate ref-counted. | 65 // Core somewhere, e.g. make the delegate ref-counted. |
66 return base::PlatformThread::CurrentId() == plugin_thread_id_; | 66 return base::PlatformThread::CurrentId() == plugin_thread_id_; |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 void PluginMessageLoopProxy::TaskSpringboard(void* data) { | 70 void PluginMessageLoopProxy::TaskSpringboard(void* data) { |
71 base::Closure* task = reinterpret_cast<base::Closure*>(data); | 71 base::Closure* task = reinterpret_cast<base::Closure*>(data); |
72 task->Run(); | 72 task->Run(); |
73 delete task; | 73 delete task; |
74 } | 74 } |
75 | 75 |
76 void PluginMessageLoopProxy::RunClosureIf(const base::Closure& task) { | 76 void PluginMessageLoopProxy::RunClosureIf(const base::Closure& task) { |
77 // |delegate_| can be changed only from our thread, so it's safe to | 77 // |delegate_| can be changed only from our thread, so it's safe to |
78 // access it without acquiring |lock_|. | 78 // access it without acquiring |lock_|. |
79 if (delegate_) | 79 if (delegate_) |
80 task.Run(); | 80 task.Run(); |
81 } | 81 } |
82 | 82 |
83 } // namespace remoting | 83 } // namespace remoting |
OLD | NEW |