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

Unified Diff: chrome_frame/chrome_frame_automation.cc

Issue 388008: This CL fixes the following issues:-... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | chrome_frame/urlmon_url_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/chrome_frame_automation.cc
===================================================================
--- chrome_frame/chrome_frame_automation.cc (revision 31553)
+++ chrome_frame/chrome_frame_automation.cc (working copy)
@@ -1018,8 +1018,13 @@
void ChromeFrameAutomationClient::RemoveRequest(PluginUrlRequest* request) {
DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_);
- DCHECK(request_map_.end() != request_map_.find(request->id()));
- request_map_.erase(request->id());
+
+ // We check if the request pointer passed in is actually present in the map
+ // before going ahead and deleting it. This avoids the issue where we would
+ // incorrectly delete a different request with the same request id.
+ if (IsValidRequest(request)) {
+ request_map_.erase(request->id());
+ }
}
void ChromeFrameAutomationClient::RemoveRequest(int request_id, bool abort) {
@@ -1081,17 +1086,23 @@
void ChromeFrameAutomationClient::CleanupAsyncRequests() {
DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_);
+
+ std::vector<scoped_refptr<PluginUrlRequest> > request_list;
+ // We copy the pending requests into a temporary vector as the Stop
+ // function in the request could also try to delete the request from
+ // the request map and the iterator could end up being invalid.
RequestMap::iterator index = request_map_.begin();
while (index != request_map_.end()) {
PluginUrlRequest* request = (*index).second;
- if (request) {
- int request_id = request->id();
- request->Stop();
- }
+ DCHECK(request != NULL);
+ request_list.push_back(request);
index++;
}
+ request_map_.clear();
- request_map_.clear();
+ for (unsigned int index = 0; index < request_list.size(); ++index) {
+ request_list[index]->Stop();
+ }
}
bool ChromeFrameAutomationClient::Reinitialize(
@@ -1108,6 +1119,7 @@
return false;
}
+ CleanupAsyncRequests();
chrome_frame_delegate_ = delegate;
SetParentWindow(NULL);
return true;
« no previous file with comments | « no previous file | chrome_frame/urlmon_url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698