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

Side by Side Diff: chrome_frame/urlmon_url_request.cc

Issue 456013: Fix a crash caused by a race condition between the time the UrlmonUrlRequest:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/urlmon_url_request.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome_frame/urlmon_url_request.h" 5 #include "chrome_frame/urlmon_url_request.h"
6 6
7 #include <wininet.h> 7 #include <wininet.h>
8 8
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 " - Request stopped, Result: " << std::hex << result << 308 " - Request stopped, Result: " << std::hex << result <<
309 " Status: " << status_.status(); 309 " Status: " << status_.status();
310 310
311 if (FAILED(result)) { 311 if (FAILED(result)) {
312 status_.set_status(URLRequestStatus::FAILED); 312 status_.set_status(URLRequestStatus::FAILED);
313 status_.set_os_error(HresultToNetError(result)); 313 status_.set_os_error(HresultToNetError(result));
314 EndRequest(); 314 EndRequest();
315 } else { 315 } else {
316 status_.set_status(URLRequestStatus::SUCCESS); 316 status_.set_status(URLRequestStatus::SUCCESS);
317 status_.set_os_error(0); 317 status_.set_os_error(0);
318 } 318 ReleaseBindings();
319
320 DLOG(INFO) << "OnStopBinding received for request id: " << id();
321
322 // Release these variables after reporting EndRequest since we might need to
323 // access their state.
324 binding_.Release();
325 if (bind_context_) {
326 ::RevokeBindStatusCallback(bind_context_, this);
327 bind_context_.Release();
328 } 319 }
329 320
330 return S_OK; 321 return S_OK;
331 } 322 }
332 323
333 STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags, 324 STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags,
334 BINDINFO *bind_info) { 325 BINDINFO *bind_info) {
335 DCHECK(worker_thread_ != NULL); 326 DCHECK(worker_thread_ != NULL);
336 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); 327 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id());
337 328
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 if (status >= 300 && status < 400) { 708 if (status >= 300 && status < 400) {
718 redirect_status_ = status; // store the latest redirect status value. 709 redirect_status_ = status; // store the latest redirect status value.
719 status_.set_os_error(net::ERR_UNSAFE_REDIRECT); 710 status_.set_os_error(net::ERR_UNSAFE_REDIRECT);
720 } 711 }
721 } 712 }
722 OnResponseEnd(status_); 713 OnResponseEnd(status_);
723 } else { 714 } else {
724 ignore_redirect_stop_binding_error_ = false; 715 ignore_redirect_stop_binding_error_ = false;
725 } 716 }
726 717
718 ReleaseBindings();
727 // Remove the request mapping and release the outstanding reference to us in 719 // Remove the request mapping and release the outstanding reference to us in
728 // the context of the UI thread. 720 // the context of the UI thread.
721 // We should not access any members of the UrlmonUrlRequest object after this
722 // as the object would be deleted.
729 PostTask(FROM_HERE, 723 PostTask(FROM_HERE,
730 NewRunnableMethod(this, &UrlmonUrlRequest::EndRequestInternal)); 724 NewRunnableMethod(this, &UrlmonUrlRequest::EndRequestInternal));
731 } 725 }
732 726
733 void UrlmonUrlRequest::EndRequestInternal() { 727 void UrlmonUrlRequest::EndRequestInternal() {
734 // The request object could have been removed from the map in the 728 // The request object could have been removed from the map in the
735 // OnRequestEnd callback which executes on receiving the 729 // OnRequestEnd callback which executes on receiving the
736 // AutomationMsg_RequestEnd IPC from Chrome. 730 // AutomationMsg_RequestEnd IPC from Chrome.
737 request_handler()->RemoveRequest(this); 731 request_handler()->RemoveRequest(this);
738 // The current instance could get destroyed in the context of DestroyWindow. 732 // The current instance could get destroyed in the context of DestroyWindow.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 hr = info->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, buffer.get(), 790 hr = info->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, buffer.get(),
797 &size, &flags, &reserved); 791 &size, &flags, &reserved);
798 if (FAILED(hr)) { 792 if (FAILED(hr)) {
799 DLOG(WARNING) << "Failed to query HTTP headers. Error 0x%x" << hr; 793 DLOG(WARNING) << "Failed to query HTTP headers. Error 0x%x" << hr;
800 return std::string(); 794 return std::string();
801 } 795 }
802 796
803 return buffer.get(); 797 return buffer.get();
804 } 798 }
805 799
800 void UrlmonUrlRequest::ReleaseBindings() {
801 binding_.Release();
802 if (bind_context_) {
803 ::RevokeBindStatusCallback(bind_context_, this);
804 bind_context_.Release();
805 }
806 }
807
806 // 808 //
807 // UrlmonUrlRequest::Cache implementation. 809 // UrlmonUrlRequest::Cache implementation.
808 // 810 //
809 811
810 size_t UrlmonUrlRequest::Cache::Size() { 812 size_t UrlmonUrlRequest::Cache::Size() {
811 size_t size = 0; 813 size_t size = 0;
812 if (stream_) { 814 if (stream_) {
813 STATSTG cache_stat = {0}; 815 STATSTG cache_stat = {0};
814 stream_->Stat(&cache_stat, STATFLAG_NONAME); 816 stream_->Stat(&cache_stat, STATFLAG_NONAME);
815 817
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 ret = net::ERR_ACCESS_DENIED; 968 ret = net::ERR_ACCESS_DENIED;
967 break; 969 break;
968 970
969 default: 971 default:
970 DLOG(WARNING) 972 DLOG(WARNING)
971 << StringPrintf("TODO: translate HRESULT 0x%08X to net::Error", hr); 973 << StringPrintf("TODO: translate HRESULT 0x%08X to net::Error", hr);
972 break; 974 break;
973 } 975 }
974 return ret; 976 return ret;
975 } 977 }
OLDNEW
« no previous file with comments | « chrome_frame/urlmon_url_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698