diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 23:28:59 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 23:28:59 +0000 |
commit | db567f2bfd128fad15e389356dd99eebda704823 (patch) | |
tree | dff13ed32a994920019d80064824cafa72f74c7a /jingle | |
parent | 59906589d90c082d91f268206eadaf6b71c1aad1 (diff) | |
download | chromium_src-db567f2bfd128fad15e389356dd99eebda704823.zip chromium_src-db567f2bfd128fad15e389356dd99eebda704823.tar.gz chromium_src-db567f2bfd128fad15e389356dd99eebda704823.tar.bz2 |
Implement P2P Transport Dev using P2PTransportImpl.
BUG=None
TEST=Unittests
Review URL: http://codereview.chromium.org/6823021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/glue/thread_wrapper.cc | 2 | ||||
-rw-r--r-- | jingle/glue/thread_wrapper_unittest.cc | 20 |
2 files changed, 16 insertions, 6 deletions
diff --git a/jingle/glue/thread_wrapper.cc b/jingle/glue/thread_wrapper.cc index fe26094..979064b 100644 --- a/jingle/glue/thread_wrapper.cc +++ b/jingle/glue/thread_wrapper.cc @@ -30,6 +30,7 @@ JingleThreadWrapper::JingleThreadWrapper(MessageLoop* message_loop) DCHECK_EQ(message_loop_, MessageLoop::current()); talk_base::ThreadManager::SetCurrent(this); + talk_base::MessageQueueManager::Instance()->Add(this); message_loop_->AddDestructionObserver(this); } @@ -38,6 +39,7 @@ JingleThreadWrapper::~JingleThreadWrapper() { void JingleThreadWrapper::WillDestroyCurrentMessageLoop() { talk_base::ThreadManager::SetCurrent(NULL); + talk_base::MessageQueueManager::Instance()->Remove(this); message_loop_->RemoveDestructionObserver(this); delete this; } diff --git a/jingle/glue/thread_wrapper_unittest.cc b/jingle/glue/thread_wrapper_unittest.cc index 18f8bb4..042970e 100644 --- a/jingle/glue/thread_wrapper_unittest.cc +++ b/jingle/glue/thread_wrapper_unittest.cc @@ -35,20 +35,15 @@ class ThreadWrapperTest : public testing::Test { } virtual void SetUp() OVERRIDE { - wrapper_ = new JingleThreadWrapper(&message_loop_); + JingleThreadWrapper::EnsureForCurrentThread(); } // ThreadWrapper destroyes itself when |message_loop_| is destroyed. - JingleThreadWrapper* wrapper_; MessageLoop message_loop_; MockMessageHandler handler1_; MockMessageHandler handler2_; }; -TEST_F(ThreadWrapperTest, Create) { - EXPECT_EQ(thread(), static_cast<talk_base::Thread*>(wrapper_)); -} - MATCHER_P3(MatchMessageAndDeleteData, handler, message_id, data, "") { delete arg->pdata; return arg->phandler == handler && @@ -156,4 +151,17 @@ TEST_F(ThreadWrapperTest, ClearDelayed) { message_loop_.Run(); } +// Verify that the queue is cleared when a handler is destroyed. +TEST_F(ThreadWrapperTest, ClearDestoroyed) { + MockMessageHandler* handler_ptr; + { + MockMessageHandler handler; + handler_ptr = &handler; + thread()->Post(&handler, kTestMessage1, NULL); + } + talk_base::MessageList removed; + thread()->Clear(handler_ptr, talk_base::MQID_ANY, &removed); + DCHECK_EQ(0U, removed.size()); +} + } // namespace jingle_glue |