OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); | 395 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 0); |
396 | 396 |
397 // Create a new channel and ensure it works after closing the previous one. | 397 // Create a new channel and ensure it works after closing the previous one. |
398 caller_dc = caller_->CreateDataChannel("data2", init); | 398 caller_dc = caller_->CreateDataChannel("data2", init); |
399 | 399 |
400 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); | 400 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 1); |
401 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); | 401 TestDataChannelSendAndReceive(caller_dc, callee_signaled_data_channels_[1]); |
402 | 402 |
403 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); | 403 CloseDataChannels(caller_dc, callee_signaled_data_channels_, 1); |
404 } | 404 } |
405 | |
406 // This tests that if a data channel is closed remotely while not referenced | |
407 // by the application (meaning only the PeerConnection contributes to its | |
408 // reference count), no memory access violation will occur. | |
409 // See: https://code.google.com/p/chromium/issues/detail?id=565048 | |
410 TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { | |
411 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
412 | |
413 CreatePcs(); | |
414 | |
415 webrtc::DataChannelInit init; | |
416 rtc::scoped_refptr<DataChannelInterface> caller_dc( | |
417 caller_->CreateDataChannel("data", init)); | |
418 | |
419 Negotiate(); | |
420 WaitForConnection(); | |
421 | |
422 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | |
423 // This removes the reference to the remote data channel that we hold. | |
424 callee_signaled_data_channels_.clear(); | |
425 caller_dc->Close(); | |
426 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); | |
427 | |
428 // Wait for a bit longer so the remote data channel will receive the | |
429 // close message and be destroyed. | |
430 rtc::Thread::Current()->ProcessMessages(100); | |
431 } | |
OLD | NEW |