Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc

Issue 2038843003: bluetooth: Don't call methods of WebContentsImpl while it's being destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address jyasskin's comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
diff --git a/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc b/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
index 8a76e565ece2ceb803e3735b600ea634bcf18f3c..339f8806b518f129cf68f37ea44a78f353d357ed 100644
--- a/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
+++ b/content/browser/bluetooth/frame_connected_bluetooth_devices_unittest.cc
@@ -354,4 +354,21 @@ TEST_F(FrameConnectedBluetoothDevicesTest, Destruction_MultipleMaps) {
EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice());
}
+TEST_F(FrameConnectedBluetoothDevicesTest,
+ DestroyedByWebContentsImplDestruction) {
+ // Tests that we don't crash when FrameConnectedBluetoothDevices contains
+ // at least one device, and it is destroyed while WebContentsImpl is being
+ // destroyed.
+
+ map0_->Insert(kDeviceId0, GetConnection(kDeviceAddress0));
+ // A FrameConnectedBluetoothDevices instance is usually owned by a
+ // WebBluetoothServiceImpl instance which is owned by a RenderFrameHost which
+ // is owned by WebContentsImpl. In order to avoid adding unnecessary
+ // complexity to WebBluetoothServiceImpl just so we can perform this test we
+ // add the map directly to a frame and then delete WebContents.
+ contents()->GetMainFrame()->SetFrameConnectedBluetoothDevices(
+ std::move(map0_));
+ DeleteContents();
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.h » ('j') | content/browser/web_contents/web_contents_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698