Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ |
| 6 #define REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ | 6 #define REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "third_party/libjingle/source/talk/base/messagequeue.h" | 11 #include "third_party/libjingle/source/talk/base/messagequeue.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 24 TaskPump(); | 24 TaskPump(); |
| 25 | 25 |
| 26 // TaskRunner methods. | 26 // TaskRunner methods. |
| 27 virtual void WakeTasks(); | 27 virtual void WakeTasks(); |
| 28 virtual int64 CurrentTime(); | 28 virtual int64 CurrentTime(); |
| 29 | 29 |
| 30 // MessageHandler methods. | 30 // MessageHandler methods. |
| 31 virtual void OnMessage(talk_base::Message* pmsg); | 31 virtual void OnMessage(talk_base::Message* pmsg); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class JingleThreadMessageLoop : public MessageLoop { | |
|
Wez
2011/07/01 20:33:00
Isn't this really a Jingle-aware MessageLoop, so n
Sergey Ulanov
2011/07/01 21:14:28
It's a MessageLoop that runs tasks on a libjingle
Wez
2011/07/01 21:49:28
OK, understood.
| |
| 35 public: | |
| 36 JingleThreadMessageLoop(talk_base::Thread* thread); | |
| 37 virtual ~JingleThreadMessageLoop(); | |
| 38 | |
| 39 void Initialize(); | |
| 40 | |
| 41 private: | |
| 42 // AutoRunState sets |state_| for this message loop. It needs to be | |
| 43 // created here because we never call Run() or RunAllPending() for | |
|
Wez
2011/07/01 20:33:00
nit: It's not being created here, this is just the
Sergey Ulanov
2011/07/01 21:14:28
Moved the comment.
Wez
2011/07/01 21:49:28
Yes, but what I'm suggesting is that since we are
Sergey Ulanov
2011/07/01 22:40:54
Done.
| |
| 44 // the thread. | |
| 45 scoped_ptr<AutoRunState> jingle_message_loop_state_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(JingleThreadMessageLoop); | |
| 48 }; | |
| 49 | |
| 34 // TODO(sergeyu): This class should be changed to inherit from Chromiums | 50 // TODO(sergeyu): This class should be changed to inherit from Chromiums |
| 35 // base::Thread instead of libjingle's thread. | 51 // base::Thread instead of libjingle's thread. |
| 36 class JingleThread : public talk_base::Thread, | 52 class JingleThread : public talk_base::Thread, |
| 37 public talk_base::MessageHandler { | 53 public talk_base::MessageHandler { |
| 38 public: | 54 public: |
| 39 JingleThread(); | 55 JingleThread(); |
| 40 virtual ~JingleThread(); | 56 virtual ~JingleThread(); |
| 41 | 57 |
| 42 void Start(); | 58 void Start(); |
| 43 | 59 |
| 44 // Main function for the thread. Should not be called directly. | 60 // Main function for the thread. Should not be called directly. |
| 45 virtual void Run(); | 61 virtual void Run(); |
| 46 | 62 |
| 47 // Stop the thread. | 63 // Stop the thread. |
| 48 virtual void Stop(); | 64 virtual void Stop(); |
| 49 | 65 |
| 50 // Returns Chromiums message loop for this thread. | 66 // Returns Chromiums message loop for this thread. |
| 51 // TODO(sergeyu): remove this method when we use base::Thread instead of | 67 // TODO(sergeyu): remove this method when we use base::Thread instead of |
| 52 // talk_base::Thread | 68 // talk_base::Thread |
| 53 MessageLoop* message_loop(); | 69 MessageLoop* message_loop(); |
| 54 | 70 |
| 55 // Returns task pump if the thread is running, otherwise NULL is returned. | 71 // Returns task pump if the thread is running, otherwise NULL is returned. |
| 56 TaskPump* task_pump(); | 72 TaskPump* task_pump(); |
| 57 | 73 |
| 58 private: | 74 private: |
| 59 class JingleMessageLoop; | |
| 60 class JingleMessagePump; | |
| 61 | |
| 62 virtual void OnMessage(talk_base::Message* msg); | 75 virtual void OnMessage(talk_base::Message* msg); |
| 63 | 76 |
| 64 TaskPump* task_pump_; | 77 TaskPump* task_pump_; |
| 65 base::WaitableEvent started_event_; | 78 base::WaitableEvent started_event_; |
| 66 base::WaitableEvent stopped_event_; | 79 base::WaitableEvent stopped_event_; |
| 67 MessageLoop* message_loop_; | 80 MessageLoop* message_loop_; |
| 68 | 81 |
| 69 DISALLOW_COPY_AND_ASSIGN(JingleThread); | 82 DISALLOW_COPY_AND_ASSIGN(JingleThread); |
| 70 }; | 83 }; |
| 71 | 84 |
| 72 } // namespace remoting | 85 } // namespace remoting |
| 73 | 86 |
| 74 #endif // REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ | 87 #endif // REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_ |
| OLD | NEW |