Fix crashes/assertions when CefBrowserImpl is destroyed on a non-UI thread (issue #694).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@736 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-08-13 16:24:53 +00:00
parent 26a2281486
commit 6ab23a802f
5 changed files with 30 additions and 19 deletions

View File

@@ -111,7 +111,8 @@ BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry()
const {
if (last_committed_entry_index_ == -1)
return NULL;
return entries_[last_committed_entry_index_].get();
return const_cast<BrowserNavigationEntry*>(
entries_[last_committed_entry_index_]);
}
BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const {
@@ -133,13 +134,14 @@ BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex(
if (index < 0 || index >= GetEntryCount())
return NULL;
return entries_[index].get();
return const_cast<BrowserNavigationEntry*>(entries_[index]);
}
BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID(
int32 page_id) const {
int index = GetEntryIndexWithPageID(page_id);
return (index != -1) ? entries_[index].get() : NULL;
return (index != -1) ?
const_cast<BrowserNavigationEntry*>(entries_[index]) : NULL;
}
void BrowserNavigationController::DidNavigateToEntry(
@@ -158,7 +160,7 @@ void BrowserNavigationController::DidNavigateToEntry(
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ?
entries_[existing_entry_index].get() : NULL;
entries_[existing_entry_index] : NULL;
if (!existing_entry) {
// No existing entry, then simply ignore this navigation!
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
@@ -191,7 +193,7 @@ void BrowserNavigationController::DidNavigateToEntry(
}
void BrowserNavigationController::DiscardPendingEntry() {
if (pending_entry_index_ == -1)
if (pending_entry_index_ == -1 && pending_entry_)
delete pending_entry_;
pending_entry_ = NULL;
pending_entry_index_ = -1;
@@ -210,13 +212,13 @@ void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
int current_size = static_cast<int>(entries_.size());
if (current_size > 0) {
while (last_committed_entry_index_ < (current_size - 1)) {
entries_.pop_back();
entries_.erase(entries_.end() - 1);
current_size--;
}
}
}
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
entries_.push_back(entry);
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
UpdateMaxPageID();
}
@@ -234,7 +236,7 @@ void BrowserNavigationController::NavigateToPendingEntry(bool reload,
// For session history navigations only the pending_entry_index_ is set.
if (!pending_entry_) {
DCHECK_NE(pending_entry_index_, -1);
pending_entry_ = entries_[pending_entry_index_].get();
pending_entry_ = entries_[pending_entry_index_];
}
if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) {