diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 03:53:05 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 03:53:05 +0000 |
commit | 562d9746c44721e346cc54c6e576cd1074e81002 (patch) | |
tree | c71b06229ce33d8230cc41040ab043f96564ac4e /jingle | |
parent | dda1ce3b1a74fcbeecbddd5fc19224ebc5dd366e (diff) | |
download | chromium_src-562d9746c44721e346cc54c6e576cd1074e81002.zip chromium_src-562d9746c44721e346cc54c6e576cd1074e81002.tar.gz chromium_src-562d9746c44721e346cc54c6e576cd1074e81002.tar.bz2 |
Fix Dispose() method in JingleThreadWrapper.
BUG=93812
TEST=unittests, repro steps in the bug
Review URL: http://codereview.chromium.org/7850007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/glue/thread_wrapper.cc | 10 | ||||
-rw-r--r-- | jingle/glue/thread_wrapper_unittest.cc | 28 |
2 files changed, 36 insertions, 2 deletions
diff --git a/jingle/glue/thread_wrapper.cc b/jingle/glue/thread_wrapper.cc index 036122b..6983087 100644 --- a/jingle/glue/thread_wrapper.cc +++ b/jingle/glue/thread_wrapper.cc @@ -224,8 +224,14 @@ void JingleThreadWrapper::RunTask(int task_id) { } } - if (have_message) - message.phandler->OnMessage(&message); + if (have_message) { + if (message.message_id == talk_base::MQID_DISPOSE) { + DCHECK(message.phandler == NULL); + delete message.pdata; + } else { + message.phandler->OnMessage(&message); + } + } } // All methods below are marked as not reached. See comments in the diff --git a/jingle/glue/thread_wrapper_unittest.cc b/jingle/glue/thread_wrapper_unittest.cc index 87ef510..116b36b 100644 --- a/jingle/glue/thread_wrapper_unittest.cc +++ b/jingle/glue/thread_wrapper_unittest.cc @@ -25,6 +25,8 @@ static const int kTestDelayMs3 = 30; static const int kTestDelayMs4 = 40; static const int kMaxTestDelay = 40; +namespace { + class MockMessageHandler : public talk_base::MessageHandler { public: MOCK_METHOD1(OnMessage, void(talk_base::Message* msg)); @@ -40,6 +42,24 @@ ACTION(DeleteMessageData) { delete arg0->pdata; } +// Helper class used in the Dispose test. +class DeletableObject { + public: + DeletableObject(bool* deleted) + : deleted_(deleted) { + *deleted = false; + } + + ~DeletableObject() { + *deleted_ = true; + } + + private: + bool* deleted_; +}; + +} // namespace + class ThreadWrapperTest : public testing::Test { public: // This method is used by the SendDuringSend test. It sends message to the @@ -272,4 +292,12 @@ TEST_F(ThreadWrapperTest, SendDuringSend) { Mock::VerifyAndClearExpectations(&handler1_); } +TEST_F(ThreadWrapperTest, Dispose) { + bool deleted_; + thread_->Dispose(new DeletableObject(&deleted_)); + EXPECT_FALSE(deleted_); + message_loop_.RunAllPending(); + EXPECT_TRUE(deleted_); +} + } // namespace jingle_glue |