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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/bluetooth/frame_connected_bluetooth_devices.h" 5 #include "content/browser/bluetooth/frame_connected_bluetooth_devices.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "content/test/test_render_view_host.h" 9 #include "content/test/test_render_view_host.h"
10 #include "content/test/test_web_contents.h" 10 #include "content/test/test_web_contents.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 map0_.reset(); 347 map0_.reset();
348 348
349 // WebContents should still be connected because of map1_. 349 // WebContents should still be connected because of map1_.
350 EXPECT_TRUE(contents()->IsConnectedToBluetoothDevice()); 350 EXPECT_TRUE(contents()->IsConnectedToBluetoothDevice());
351 351
352 map1_.reset(); 352 map1_.reset();
353 353
354 EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice()); 354 EXPECT_FALSE(contents()->IsConnectedToBluetoothDevice());
355 } 355 }
356 356
357 TEST_F(FrameConnectedBluetoothDevicesTest,
358 DestroyedByWebContentsImplDestruction) {
359 // Tests that we don't crash when FrameConnectedBluetoothDevices contains
360 // at least one device, and it is destroyed while WebContentsImpl is being
361 // destroyed.
362
363 map0_->Insert(kDeviceId0, GetConnection(kDeviceAddress0));
364 // A FrameConnectedBluetoothDevices instance is usually owned by a
365 // WebBluetoothServiceImpl instance which is owned by a RenderFrameHost which
366 // is owned by WebContentsImpl. In order to avoid adding unnecessary
367 // complexity to WebBluetoothServiceImpl just so we can perform this test we
368 // add the map directly to a frame and then delete WebContents.
369 contents()->GetMainFrame()->SetFrameConnectedBluetoothDevices(
370 std::move(map0_));
371 DeleteContents();
372 }
373
357 } // namespace content 374 } // namespace content
OLDNEW
« 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