Index: remoting/jingle_glue/jingle_thread.cc |
diff --git a/remoting/jingle_glue/jingle_thread.cc b/remoting/jingle_glue/jingle_thread.cc |
index 9dc3915a3b9f4fc6d1fa40a8bcd1d9c2101827bb..7c2b868347ec4b0a071d21e38dc2da0c43543a8d 100644 |
--- a/remoting/jingle_glue/jingle_thread.cc |
+++ b/remoting/jingle_glue/jingle_thread.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -15,10 +15,14 @@ namespace remoting { |
const uint32 kRunTasksMessageId = 1; |
const uint32 kStopMessageId = 2; |
-class JingleThread::JingleMessagePump : public base::MessagePump, |
- public talk_base::MessageHandler { |
+namespace { |
+ |
+class JingleMessagePump : public base::MessagePump, |
+ public talk_base::MessageHandler { |
public: |
- JingleMessagePump(JingleThread* thread) : thread_(thread) { } |
+ JingleMessagePump(talk_base::Thread* thread, MessageLoop* message_loop) |
+ : thread_(thread), message_loop_(message_loop) { |
+ } |
virtual void Run(Delegate* delegate) { NOTIMPLEMENTED(); } |
virtual void Quit() { NOTIMPLEMENTED(); } |
@@ -41,7 +45,7 @@ class JingleThread::JingleMessagePump : public base::MessagePump, |
// JingleMessagePump posts new tasks in the jingle thread. |
// TODO(sergeyu): Remove it when JingleThread moved on Chromium's |
// base::Thread. |
- base::MessagePump::Delegate* delegate = thread_->message_loop(); |
+ base::MessagePump::Delegate* delegate = message_loop_; |
// Process all pending tasks. |
while (true) { |
if (delegate->DoWork()) |
@@ -56,7 +60,7 @@ class JingleThread::JingleMessagePump : public base::MessagePump, |
private: |
void ScheduleNextDelayedTask() { |
- DCHECK_EQ(thread_->message_loop(), MessageLoop::current()); |
+ DCHECK_EQ(message_loop_, MessageLoop::current()); |
if (!delayed_work_time_.is_null()) { |
base::TimeTicks now = base::TimeTicks::Now(); |
@@ -69,27 +73,24 @@ class JingleThread::JingleMessagePump : public base::MessagePump, |
} |
} |
- JingleThread* thread_; |
+ talk_base::Thread* thread_; |
+ MessageLoop* message_loop_; |
Wez
2011/07/01 20:33:00
Normally the pump is created by the relevant Messa
Sergey Ulanov
2011/07/01 21:14:28
No, because nobody ever calls Run() on this Pump.
|
base::TimeTicks delayed_work_time_; |
}; |
-class JingleThread::JingleMessageLoop : public MessageLoop { |
- public: |
- JingleMessageLoop(JingleThread* thread) |
- : MessageLoop(MessageLoop::TYPE_IO) { |
- pump_ = new JingleMessagePump(thread); |
- } |
+} // namespace |
- void Initialize() { |
- jingle_message_loop_state_.reset(new AutoRunState(this)); |
- } |
+JingleThreadMessageLoop::JingleThreadMessageLoop(talk_base::Thread* thread) |
+ : MessageLoop(MessageLoop::TYPE_IO) { |
+ pump_ = new JingleMessagePump(thread, this); |
+} |
- private: |
- // AutoRunState sets |state_| for this message loop. It needs to be |
- // created here because we never call Run() or RunAllPending() for |
- // the thread. |
- scoped_ptr<AutoRunState> jingle_message_loop_state_; |
-}; |
+JingleThreadMessageLoop::~JingleThreadMessageLoop() { |
+} |
+ |
+void JingleThreadMessageLoop::Initialize() { |
+ jingle_message_loop_state_.reset(new AutoRunState(this)); |
+} |
TaskPump::TaskPump() { |
} |
@@ -121,7 +122,7 @@ void JingleThread::Start() { |
} |
void JingleThread::Run() { |
- JingleMessageLoop message_loop(this); |
+ JingleThreadMessageLoop message_loop(this); |
message_loop.Initialize(); |
message_loop_ = &message_loop; |