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

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 3112022: Band-aid around an unexplained crasher. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Added more checks Created 10 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/tab_contents.cc
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index dbcf1dded11747686c4c68afc2a38acb7bfeb40a..83b7e49d9e9a194f8c070b5a4937523c4aea0aa6 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1106,12 +1106,20 @@ void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
Source<TabContents>(this),
Details<InfoBarDelegate>(delegate));
- infobar_delegates_.erase(it);
- // Remove ourselves as an observer if we are tracking no more InfoBars.
- if (infobar_delegates_.empty()) {
- registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&controller_));
+ // Just to be safe, make sure the delegate was not removed by an observer.
+ it = find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
+ if (it != infobar_delegates_.end()) {
+ infobar_delegates_.erase(it);
+ // Remove ourselves as an observer if we are tracking no more InfoBars.
+ if (infobar_delegates_.empty()) {
+ registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(&controller_));
+ }
+ } else {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
}
}
}
@@ -1136,10 +1144,21 @@ void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate,
Source<TabContents>(this),
Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get()));
- // Remove the old one.
- infobar_delegates_.erase(it);
+ // Just to be safe, make sure the delegate was not removed by an observer.
+ it = find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
+ if (it != infobar_delegates_.end()) {
+ // Remove the old one.
+ infobar_delegates_.erase(it);
+ } else {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
+ }
// Add the new one.
+ DCHECK(find(infobar_delegates_.begin(),
+ infobar_delegates_.end(), new_delegate) ==
+ infobar_delegates_.end());
infobar_delegates_.push_back(new_delegate);
}
@@ -1502,6 +1521,13 @@ void TabContents::ExpireInfoBars(
for (int i = infobar_delegate_count() - 1; i >= 0; --i) {
InfoBarDelegate* delegate = GetInfoBarDelegateAt(i);
+ if (!delegate) {
+ // If you hit this NOTREACHED, please comment in bug
+ // http://crbug.com/50428 how you got there.
+ NOTREACHED();
+ continue;
+ }
+
if (delegate->ShouldExpire(details))
RemoveInfoBar(delegate);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698