Chromium Code Reviews| Index: third_party/libjingle/overrides/talk/base/messagequeue.cc |
| =================================================================== |
| --- third_party/libjingle/overrides/talk/base/messagequeue.cc (revision 123769) |
| +++ third_party/libjingle/overrides/talk/base/messagequeue.cc (working copy) |
| @@ -44,6 +44,28 @@ |
| const uint32 kMaxMsgLatency = 150; // 150 ms |
| //------------------------------------------------------------------ |
| +// DummySocketServer |
| + |
| +class DummySocketServer : public talk_base::SocketServer { |
|
Sergey Ulanov
2012/02/28 07:14:32
May be better to call it NullSocketServer
Ronghua Wu (Left Chromium)
2012/02/28 17:50:47
Done.
|
| + virtual bool Wait(int cms, bool process_io) OVERRIDE { |
| + return false; |
|
Sergey Ulanov
2012/02/28 07:14:32
That doesn't look right. I think that message queu
Ronghua Wu (Left Chromium)
2012/02/28 17:50:47
Done.
|
| + } |
| + |
| + virtual void WakeUp() OVERRIDE { |
|
Sergey Ulanov
2012/02/28 07:14:32
This should signal event that Wait() waits on.
Ronghua Wu (Left Chromium)
2012/02/28 17:50:47
Done.
|
| + } |
| + |
| + virtual talk_base::Socket* CreateSocket(int type) OVERRIDE { |
| + return NULL; |
| + } |
| + |
| + // Returns a new socket for nonblocking communication. The type can be |
| + // SOCK_DGRAM and SOCK_STREAM. |
|
Sergey Ulanov
2012/02/28 07:14:32
s/and/or/
Ronghua Wu (Left Chromium)
2012/02/28 17:50:47
Done.
|
| + virtual talk_base::AsyncSocket* CreateAsyncSocket(int type) OVERRIDE { |
| + return NULL; |
| + } |
| +}; |
| + |
| +//------------------------------------------------------------------ |
| // MessageQueueManager |
| MessageQueueManager* MessageQueueManager::instance_; |
| @@ -105,18 +127,29 @@ |
| //------------------------------------------------------------------ |
| // MessageQueue |
| -MessageQueue::MessageQueue(SocketServer* ss) |
| - : ss_(ss), fStop_(false), fPeekKeep_(false), active_(false), |
| - dmsgq_next_num_(0) { |
| - if (!ss_) { |
| - // Currently, MessageQueue holds a socket server, and is the base class for |
| - // Thread. It seems like it makes more sense for Thread to hold the socket |
| - // server, and provide it to the MessageQueue, since the Thread controls |
| - // the I/O model, and MQ is agnostic to those details. Anyway, this causes |
| - // messagequeue_unittest to depend on network libraries... yuck. |
| - default_ss_.reset(new PhysicalSocketServer()); |
| - ss_ = default_ss_.get(); |
| +MessageQueue::MessageQueue() { |
| + // Currently, MessageQueue holds a socket server, and is the base class for |
| + // Thread. It seems like it makes more sense for Thread to hold the socket |
| + // server, and provide it to the MessageQueue, since the Thread controls |
| + // the I/O model, and MQ is agnostic to those details. Anyway, this causes |
| + // messagequeue_unittest to depend on network libraries... yuck. |
|
Sergey Ulanov
2012/02/28 07:14:32
mark this as TODO?
|
| + default_ss_.reset(new PhysicalSocketServer()); |
| + Construct(); |
| +} |
| + |
| +MessageQueue::MessageQueue(SocketServer* ss) { |
| + if (!ss) { |
| + default_ss_.reset(new DummySocketServer()); |
| } |
| + Construct(); |
| +} |
| + |
| +void MessageQueue::Construct() { |
| + fStop_ = false; |
| + fPeekKeep_ = false; |
| + active_ = false; |
| + dmsgq_next_num_ = 0; |
| + ss_ = default_ss_.get(); |
|
Sergey Ulanov
2012/02/28 07:14:32
Why not set this in the constructor? That way you
Ronghua Wu (Left Chromium)
2012/02/28 17:50:47
If a socket server is passed from external, the Me
Sergey Ulanov
2012/02/28 21:54:01
In that case it's better to rename owned_ss_ (to b
|
| ss_->SetMessageQueue(this); |
| } |