OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_JINGLE_GLUE_JINGLE_THREAD_H |
| 6 #define REMOTING_JINGLE_GLUE_JINGLE_THREAD_H |
| 7 |
| 8 #include "base/tracked_objects.h" |
| 9 #include "base/waitable_event.h" |
| 10 #include "talk/base/messagequeue.h" |
| 11 #include "talk/base/taskrunner.h" |
| 12 #include "talk/base/thread.h" |
| 13 |
| 14 class MessageLoop; |
| 15 |
| 16 namespace buzz { |
| 17 class XmppClient; |
| 18 } |
| 19 |
| 20 namespace remoting { |
| 21 |
| 22 class TaskPump : public talk_base::MessageHandler, |
| 23 public talk_base::TaskRunner { |
| 24 public: |
| 25 TaskPump(); |
| 26 |
| 27 // TaskRunner methods. |
| 28 void WakeTasks(); |
| 29 int64 CurrentTime(); |
| 30 |
| 31 // MessageHandler methods. |
| 32 void OnMessage(talk_base::Message* pmsg); |
| 33 }; |
| 34 |
| 35 // TODO(sergeyu): This class should be changed to inherit from Chromiums |
| 36 // base::Thread instead of libjingle's thread. |
| 37 class JingleThread : public talk_base::Thread, |
| 38 private talk_base::MessageHandler { |
| 39 public: |
| 40 JingleThread(); |
| 41 virtual ~JingleThread(); |
| 42 |
| 43 void Start(); |
| 44 |
| 45 // Main function for the thread. Should not be called directly. |
| 46 void Run(); |
| 47 |
| 48 // Returns Chromiums message loop for this thread. |
| 49 // TODO(sergeyu): remove this methid when we use base::Thread insted of |
| 50 // talk_base::Thread |
| 51 MessageLoop* message_loop() { return message_loop_; } |
| 52 |
| 53 // Returns task pump if the thread is running, otherwise NULL is returned. |
| 54 TaskPump* task_pump() { return task_pump_; } |
| 55 |
| 56 private: |
| 57 virtual void OnMessage(talk_base::Message* msg); |
| 58 |
| 59 void PumpAuxiliaryLoops(); |
| 60 |
| 61 TaskPump* task_pump_; |
| 62 base::WaitableEvent started_event_; |
| 63 MessageLoop* message_loop_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(JingleThread); |
| 66 }; |
| 67 |
| 68 } // namespace remoting |
| 69 |
| 70 #endif // REMOTING_JINGLE_GLUE_JINGLE_THREAD_H |
OLD | NEW |