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

Unified Diff: webkit/support/weburl_loader_mock_factory.cc

Issue 9874008: Make WebURLLoaderMock handle redirects correctly in the case where the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/support/weburl_loader_mock_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/support/weburl_loader_mock_factory.cc
===================================================================
--- webkit/support/weburl_loader_mock_factory.cc (revision 129167)
+++ webkit/support/weburl_loader_mock_factory.cc (working copy)
@@ -71,17 +71,18 @@
WebURLError error;
WebData data;
LoadRequest(request, &response, &error, &data);
- // Follow any redirect chain.
+ // Follow any redirects while the loader is still active.
while (response.httpStatusCode() >= 300 &&
response.httpStatusCode() < 400) {
WebURLRequest newRequest = loader->ServeRedirect(response);
- if (loader->isDeferred())
+ if (!IsPending(loader) || loader->isDeferred())
break;
LoadRequest(newRequest, &response, &error, &data);
}
- if (!loader->isDeferred())
+ // Serve the request if the loader is still active.
+ if (IsPending(loader) && !loader->isDeferred())
loader->ServeAsynchronousRequest(response, data, error);
- // If the load has been canceled, the loader may not be in the map.
+ // The loader might have already been removed.
pending_loaders_.erase(loader);
}
}
@@ -136,6 +137,11 @@
*response = iter->second.response;
}
+bool WebURLLoaderMockFactory::IsPending(WebURLLoaderMock* loader) {
+ LoaderToRequestMap::iterator iter = pending_loaders_.find(loader);
+ return iter != pending_loaders_.end();
+}
+
// static
bool WebURLLoaderMockFactory::ReadFile(const FilePath& file_path,
WebData* data) {
« no previous file with comments | « webkit/support/weburl_loader_mock_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698