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

Unified Diff: content/browser/web_contents/web_contents_impl.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: Remove test 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a765509ab267c2910635e57728031b46d1b37006..4e2628b2098388566b48958c0728165ece8280a2 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1221,23 +1221,6 @@ void WebContentsImpl::SetAudioMuted(bool mute) {
NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
}
-void WebContentsImpl::IncrementBluetoothConnectedDeviceCount() {
- // Notify for UI updates if the state changes.
- bluetooth_connected_device_count_++;
- if (bluetooth_connected_device_count_ == 1) {
- NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
- }
-}
-
-void WebContentsImpl::DecrementBluetoothConnectedDeviceCount() {
- // Notify for UI updates if the state changes.
- DCHECK(bluetooth_connected_device_count_ != 0);
- bluetooth_connected_device_count_--;
- if (bluetooth_connected_device_count_ == 0) {
- NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
- }
-}
-
bool WebContentsImpl::IsConnectedToBluetoothDevice() const {
return bluetooth_connected_device_count_ > 0;
}
@@ -5056,6 +5039,33 @@ void WebContentsImpl::NotifyFindReply(int request_id,
}
}
+void WebContentsImpl::IncrementBluetoothConnectedDeviceCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed()) {
+ return;
+ }
+ // Notify for UI updates if the state changes.
+ bluetooth_connected_device_count_++;
+ if (bluetooth_connected_device_count_ == 1) {
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+ }
+}
+
+void WebContentsImpl::DecrementBluetoothConnectedDeviceCount() {
+ // Trying to invalidate the tab state while being destroyed could result in a
+ // use after free.
+ if (IsBeingDestroyed()) {
+ return;
+ }
+ // Notify for UI updates if the state changes.
+ DCHECK(bluetooth_connected_device_count_ != 0);
+ bluetooth_connected_device_count_--;
+ if (bluetooth_connected_device_count_ == 0) {
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+ }
+}
+
#if defined(OS_ANDROID)
void WebContentsImpl::NotifyFindMatchRectsReply(
int version,
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698