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

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 23005006: Fix XMLHttpRequest leak document when send() is called multiple times. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-leaks-on-multiple-send-expected.txt ('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 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page. 755 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page.
756 // This is true while running onunload handlers. 756 // This is true while running onunload handlers.
757 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload , <http://bugs.webkit.org/show_bug.cgi?id=10904>. 757 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload , <http://bugs.webkit.org/show_bug.cgi?id=10904>.
758 // FIXME: Maybe create() can return null for other reasons too? 758 // FIXME: Maybe create() can return null for other reasons too?
759 m_loader = ThreadableLoader::create(scriptExecutionContext(), this, requ est, options); 759 m_loader = ThreadableLoader::create(scriptExecutionContext(), this, requ est, options);
760 if (m_loader) { 760 if (m_loader) {
761 // Neither this object nor the JavaScript wrapper should be deleted while 761 // Neither this object nor the JavaScript wrapper should be deleted while
762 // a request is in progress because we need to keep the listeners al ive, 762 // a request is in progress because we need to keep the listeners al ive,
763 // and they are referenced by the JavaScript wrapper. 763 // and they are referenced by the JavaScript wrapper.
764 setPendingActivity(this); 764 if (!hasPendingActivity())
haraken 2013/08/14 01:30:59 I'm not sure if this is a right fix. If send() is
kouhei (in TOK) 2013/08/14 02:30:09 There should not be a pending activity at this poi
765 setPendingActivity(this);
765 } 766 }
766 } else { 767 } else {
767 request.setPriority(ResourceLoadPriorityVeryHigh); 768 request.setPriority(ResourceLoadPriorityVeryHigh);
768 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex t()); 769 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex t());
769 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re quest, *this, options); 770 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re quest, *this, options);
770 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext ()); 771 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext ());
771 } 772 }
772 773
773 if (!m_exceptionCode && m_error) 774 if (!m_exceptionCode && m_error)
774 m_exceptionCode = NetworkError; 775 m_exceptionCode = NetworkError;
775 if (m_exceptionCode) 776 if (m_exceptionCode)
776 es.throwDOMException(m_exceptionCode); 777 es.throwDOMException(m_exceptionCode);
777 } 778 }
778 779
779 void XMLHttpRequest::abort() 780 void XMLHttpRequest::abort()
780 { 781 {
781 // internalAbort() calls dropProtection(), which may release the last refere nce.
782 RefPtr<XMLHttpRequest> protect(this);
783
784 bool sendFlag = m_loader; 782 bool sendFlag = m_loader;
785 783
786 internalAbort(); 784 internalAbort();
787 785
788 clearResponseBuffers(); 786 clearResponseBuffers();
789 787
790 // Clear headers as required by the spec 788 // Clear headers as required by the spec
791 m_requestHeaders.clear(); 789 m_requestHeaders.clear();
792 790
793 if ((m_state <= OPENED && !sendFlag) || m_state == DONE) 791 if ((m_state <= OPENED && !sendFlag) || m_state == DONE)
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 { 1248 {
1251 return &m_eventTargetData; 1249 return &m_eventTargetData;
1252 } 1250 }
1253 1251
1254 EventTargetData* XMLHttpRequest::ensureEventTargetData() 1252 EventTargetData* XMLHttpRequest::ensureEventTargetData()
1255 { 1253 {
1256 return &m_eventTargetData; 1254 return &m_eventTargetData;
1257 } 1255 }
1258 1256
1259 } // namespace WebCore 1257 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-leaks-on-multiple-send-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698