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) { |