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

Side by Side 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: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 audio_muter_->StopMuting(); 1210 audio_muter_->StopMuting();
1211 } 1211 }
1212 1212
1213 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1213 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1214 DidUpdateAudioMutingState(mute)); 1214 DidUpdateAudioMutingState(mute));
1215 1215
1216 // Notification for UI updates in response to the changed muting state. 1216 // Notification for UI updates in response to the changed muting state.
1217 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); 1217 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1218 } 1218 }
1219 1219
1220 void WebContentsImpl::IncrementBluetoothConnectedDeviceCount() {
1221 // Notify for UI updates if the state changes.
1222 bluetooth_connected_device_count_++;
1223 if (bluetooth_connected_device_count_ == 1) {
1224 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1225 }
1226 }
1227
1228 void WebContentsImpl::DecrementBluetoothConnectedDeviceCount() {
1229 // Notify for UI updates if the state changes.
1230 DCHECK(bluetooth_connected_device_count_ != 0);
1231 bluetooth_connected_device_count_--;
1232 if (bluetooth_connected_device_count_ == 0) {
1233 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1234 }
1235 }
1236
1237 bool WebContentsImpl::IsConnectedToBluetoothDevice() const { 1220 bool WebContentsImpl::IsConnectedToBluetoothDevice() const {
1238 return bluetooth_connected_device_count_ > 0; 1221 return bluetooth_connected_device_count_ > 0;
1239 } 1222 }
1240 1223
1241 bool WebContentsImpl::IsCrashed() const { 1224 bool WebContentsImpl::IsCrashed() const {
1242 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || 1225 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
1243 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 1226 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
1244 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || 1227 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
1245 #if defined(OS_CHROMEOS) 1228 #if defined(OS_CHROMEOS)
1246 crashed_status_ == 1229 crashed_status_ ==
(...skipping 3752 matching lines...) Expand 10 before | Expand all | Expand 10 after
4999 int number_of_matches, 4982 int number_of_matches,
5000 const gfx::Rect& selection_rect, 4983 const gfx::Rect& selection_rect,
5001 int active_match_ordinal, 4984 int active_match_ordinal,
5002 bool final_update) { 4985 bool final_update) {
5003 if (delegate_) { 4986 if (delegate_) {
5004 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, 4987 delegate_->FindReply(this, request_id, number_of_matches, selection_rect,
5005 active_match_ordinal, final_update); 4988 active_match_ordinal, final_update);
5006 } 4989 }
5007 } 4990 }
5008 4991
4992 void WebContentsImpl::IncrementBluetoothConnectedDeviceCount() {
4993 // Trying to update invalidate the tab state while being destroyed
Jeffrey Yasskin 2016/06/06 20:32:20 grammar: "update invalidate"
ortuno 2016/06/06 22:38:05 Done.
4994 // could result in a use after free.
4995 if (IsBeingDestroyed()) {
4996 return;
4997 }
4998 // Notify for UI updates if the state changes.
4999 bluetooth_connected_device_count_++;
5000 if (bluetooth_connected_device_count_ == 1) {
5001 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
5002 }
5003 }
5004
5005 void WebContentsImpl::DecrementBluetoothConnectedDeviceCount() {
5006 // Trying to update invalidate the tab state while being destroyed
Jeffrey Yasskin 2016/06/06 20:32:20 grammar: "update invalidate"
ortuno 2016/06/06 22:38:05 Done. Sorry!
5007 // could result in a use after free.
5008 if (IsBeingDestroyed()) {
5009 return;
5010 }
5011 // Notify for UI updates if the state changes.
5012 DCHECK(bluetooth_connected_device_count_ != 0);
5013 bluetooth_connected_device_count_--;
5014 if (bluetooth_connected_device_count_ == 0) {
5015 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
5016 }
5017 }
5018
5009 #if defined(OS_ANDROID) 5019 #if defined(OS_ANDROID)
5010 void WebContentsImpl::NotifyFindMatchRectsReply( 5020 void WebContentsImpl::NotifyFindMatchRectsReply(
5011 int version, 5021 int version,
5012 const std::vector<gfx::RectF>& rects, 5022 const std::vector<gfx::RectF>& rects,
5013 const gfx::RectF& active_rect) { 5023 const gfx::RectF& active_rect) {
5014 if (delegate_) 5024 if (delegate_)
5015 delegate_->FindMatchRectsReply(this, version, rects, active_rect); 5025 delegate_->FindMatchRectsReply(this, version, rects, active_rect);
5016 } 5026 }
5017 #endif 5027 #endif
5018 5028
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
5070 for (RenderViewHost* render_view_host : render_view_host_set) 5080 for (RenderViewHost* render_view_host : render_view_host_set)
5071 render_view_host->OnWebkitPreferencesChanged(); 5081 render_view_host->OnWebkitPreferencesChanged();
5072 } 5082 }
5073 5083
5074 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5084 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5075 JavaScriptDialogManager* dialog_manager) { 5085 JavaScriptDialogManager* dialog_manager) {
5076 dialog_manager_ = dialog_manager; 5086 dialog_manager_ = dialog_manager;
5077 } 5087 }
5078 5088
5079 } // namespace content 5089 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698