OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #ifndef REMOTING_BASE_PLUGIN_MESSAGE_LOOP_H_ |
| 6 #define REMOTING_BASE_PLUGIN_MESSAGE_LOOP_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop_proxy.h" |
| 11 |
| 12 namespace remoting { |
| 13 |
| 14 // MessageLoopProxy for plugin main threads. |
| 15 class PluginMessageLoopProxy : public base::MessageLoopProxy { |
| 16 public: |
| 17 class Delegate { |
| 18 public: |
| 19 Delegate() { } |
| 20 virtual ~Delegate() { } |
| 21 |
| 22 virtual bool RunOnPluginThread( |
| 23 int delay_ms, void(function)(void*), void* data) = 0; |
| 24 virtual bool IsPluginThread() = 0; |
| 25 }; |
| 26 |
| 27 // Caller keeps ownership of delegate. |
| 28 PluginMessageLoopProxy(Delegate* delegate); |
| 29 virtual ~PluginMessageLoopProxy(); |
| 30 |
| 31 void Detach(); |
| 32 |
| 33 // base::MessageLoopProxy interface. |
| 34 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 35 Task* task) OVERRIDE; |
| 36 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 37 Task* task, |
| 38 int64 delay_ms) OVERRIDE; |
| 39 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, |
| 40 Task* task) OVERRIDE; |
| 41 virtual bool PostNonNestableDelayedTask( |
| 42 const tracked_objects::Location& from_here, |
| 43 Task* task, |
| 44 int64 delay_ms) OVERRIDE; |
| 45 |
| 46 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 47 const base::Closure& task) OVERRIDE; |
| 48 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 49 const base::Closure& task, |
| 50 int64 delay_ms) OVERRIDE; |
| 51 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, |
| 52 const base::Closure& task) OVERRIDE; |
| 53 virtual bool PostNonNestableDelayedTask( |
| 54 const tracked_objects::Location& from_here, |
| 55 const base::Closure& task, |
| 56 int64 delay_ms) OVERRIDE; |
| 57 |
| 58 virtual bool BelongsToCurrentThread() OVERRIDE; |
| 59 |
| 60 private: |
| 61 // |lock_| must be acquired when accessing |delegate_|. |
| 62 base::Lock lock_; |
| 63 Delegate* delegate_; |
| 64 |
| 65 static void RunTask(void* data); |
| 66 static void RunClosure(void* data); |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(PluginMessageLoopProxy); |
| 69 }; |
| 70 |
| 71 } // namespace remoting |
| 72 |
| 73 #endif // REMOTING_BASE_PLUGIN_MESSAGE_LOOP_H_ |
OLD | NEW |