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

Side by Side Diff: Source/WebCore/loader/DocumentThreadableLoader.cpp

Issue 10765006: Merge 120845 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/reentrant-cancel-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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 DocumentThreadableLoader::~DocumentThreadableLoader() 141 DocumentThreadableLoader::~DocumentThreadableLoader()
142 { 142 {
143 if (m_resource) 143 if (m_resource)
144 m_resource->removeClient(this); 144 m_resource->removeClient(this);
145 } 145 }
146 146
147 void DocumentThreadableLoader::cancel() 147 void DocumentThreadableLoader::cancel()
148 { 148 {
149 if (m_client) { 149 // Cacnel can re-enter and m_resource might be null here as a result.
150 if (m_client && m_resource) {
150 ResourceError error(errorDomainWebKitInternal, 0, m_resource->url(), "Lo ad cancelled"); 151 ResourceError error(errorDomainWebKitInternal, 0, m_resource->url(), "Lo ad cancelled");
151 error.setIsCancellation(true); 152 error.setIsCancellation(true);
152 didFail(error); 153 didFail(error);
153 } 154 }
154 clearResource(); 155 clearResource();
155 m_client = 0; 156 m_client = 0;
156 } 157 }
157 158
158 void DocumentThreadableLoader::setDefersLoading(bool value) 159 void DocumentThreadableLoader::setDefersLoading(bool value)
159 { 160 {
160 if (m_resource) 161 if (m_resource)
161 m_resource->setDefersLoading(value); 162 m_resource->setDefersLoading(value);
162 } 163 }
163 164
164 void DocumentThreadableLoader::clearResource() 165 void DocumentThreadableLoader::clearResource()
165 { 166 {
166 if (m_resource) { 167 // Script can cancel and restart a request reentrantly within removeClient() ,
167 m_resource->removeClient(this); 168 // which could lead to calling CachedResource::removeClient() multiple times for
169 // this DocumentThreadableLoader. Save off a copy of m_resource and clear it to
170 // prevent the reentrancy.
171 if (CachedResourceHandle<CachedRawResource> resource = m_resource) {
168 m_resource = 0; 172 m_resource = 0;
173 resource->removeClient(this);
169 } 174 }
170 } 175 }
171 176
172 void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour ceRequest& request, const ResourceResponse& redirectResponse) 177 void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour ceRequest& request, const ResourceResponse& redirectResponse)
173 { 178 {
174 ASSERT(m_client); 179 ASSERT(m_client);
175 ASSERT_UNUSED(resource, resource == m_resource); 180 ASSERT_UNUSED(resource, resource == m_resource);
176 181
177 RefPtr<DocumentThreadableLoader> protect(this); 182 RefPtr<DocumentThreadableLoader> protect(this);
178 // Allow same origin requests to continue after allowing clients to audit th e redirect. 183 // Allow same origin requests to continue after allowing clients to audit th e redirect.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 428
424 return m_sameOriginRequest && securityOrigin()->canRequest(url); 429 return m_sameOriginRequest && securityOrigin()->canRequest(url);
425 } 430 }
426 431
427 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 432 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
428 { 433 {
429 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t->securityOrigin(); 434 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t->securityOrigin();
430 } 435 }
431 436
432 } // namespace WebCore 437 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/reentrant-cancel-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698