| OLD | NEW |
| (Empty) |
| 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 | |
| 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_forward.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/message_loop_proxy.h" | |
| 11 #include "base/synchronization/lock.h" | |
| 12 #include "base/threading/platform_thread.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 | |
| 16 // MessageLoopProxy for plugin main threads. | |
| 17 class PluginMessageLoopProxy : public base::MessageLoopProxy { | |
| 18 public: | |
| 19 class Delegate { | |
| 20 public: | |
| 21 Delegate() { } | |
| 22 virtual ~Delegate() { } | |
| 23 | |
| 24 virtual bool RunOnPluginThread( | |
| 25 base::TimeDelta delay, void(function)(void*), void* data) = 0; | |
| 26 }; | |
| 27 | |
| 28 // Caller keeps ownership of delegate. | |
| 29 PluginMessageLoopProxy(Delegate* delegate); | |
| 30 | |
| 31 void Detach(); | |
| 32 | |
| 33 // base::MessageLoopProxy implementation. | |
| 34 virtual bool PostDelayedTask( | |
| 35 const tracked_objects::Location& from_here, | |
| 36 const base::Closure& task, | |
| 37 base::TimeDelta delay) OVERRIDE; | |
| 38 virtual bool PostNonNestableDelayedTask( | |
| 39 const tracked_objects::Location& from_here, | |
| 40 const base::Closure& task, | |
| 41 base::TimeDelta delay) OVERRIDE; | |
| 42 | |
| 43 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | |
| 44 | |
| 45 protected: | |
| 46 virtual ~PluginMessageLoopProxy(); | |
| 47 | |
| 48 private: | |
| 49 static void TaskSpringboard(void* data); | |
| 50 | |
| 51 void RunClosureIf(const base::Closure& task); | |
| 52 | |
| 53 base::PlatformThreadId plugin_thread_id_; | |
| 54 | |
| 55 // |lock_| must be acquired when accessing |delegate_|. | |
| 56 base::Lock lock_; | |
| 57 Delegate* delegate_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(PluginMessageLoopProxy); | |
| 60 }; | |
| 61 | |
| 62 } // namespace remoting | |
| 63 | |
| 64 #endif // REMOTING_BASE_PLUGIN_MESSAGE_LOOP_H_ | |
| OLD | NEW |