OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "public/platform/WebData.h" | 44 #include "public/platform/WebData.h" |
45 #include "public/platform/WebThreadedDataReceiver.h" | 45 #include "public/platform/WebThreadedDataReceiver.h" |
46 #include "public/platform/WebURLError.h" | 46 #include "public/platform/WebURLError.h" |
47 #include "public/platform/WebURLRequest.h" | 47 #include "public/platform/WebURLRequest.h" |
48 #include "public/platform/WebURLResponse.h" | 48 #include "public/platform/WebURLResponse.h" |
49 #include "wtf/Assertions.h" | 49 #include "wtf/Assertions.h" |
50 #include "wtf/CurrentTime.h" | 50 #include "wtf/CurrentTime.h" |
51 | 51 |
52 namespace blink { | 52 namespace blink { |
53 | 53 |
54 ResourceLoader* ResourceLoader::create(ResourceFetcher* fetcher, Resource* resou rce, const ResourceRequest& request, const ResourceLoaderOptions& options) | 54 ResourceLoader* ResourceLoader::create(ResourceFetcher* fetcher, Resource* resou rce, ResourceRequest& request, const ResourceLoaderOptions& options) |
55 { | 55 { |
56 ResourceLoader* loader = new ResourceLoader(fetcher, resource, options); | 56 ResourceLoader* loader = new ResourceLoader(fetcher, resource, options); |
57 loader->init(request); | 57 loader->init(request); |
58 return loader; | 58 return loader; |
59 } | 59 } |
60 | 60 |
61 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource, con st ResourceLoaderOptions& options) | 61 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource, con st ResourceLoaderOptions& options) |
62 : m_fetcher(fetcher) | 62 : m_fetcher(fetcher) |
63 , m_notifiedLoadComplete(false) | 63 , m_notifiedLoadComplete(false) |
64 , m_defersLoading(fetcher->defersLoading()) | 64 , m_defersLoading(fetcher->defersLoading()) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 96 |
97 m_state = Terminated; | 97 m_state = Terminated; |
98 if (m_loader) { | 98 if (m_loader) { |
99 m_loader->cancel(); | 99 m_loader->cancel(); |
100 m_loader.clear(); | 100 m_loader.clear(); |
101 } | 101 } |
102 m_deferredRequest = ResourceRequest(); | 102 m_deferredRequest = ResourceRequest(); |
103 m_fetcher.clear(); | 103 m_fetcher.clear(); |
104 } | 104 } |
105 | 105 |
106 void ResourceLoader::init(const ResourceRequest& passedRequest) | 106 void ResourceLoader::init(ResourceRequest& request) |
107 { | 107 { |
108 ASSERT(m_state != Terminated); | 108 ASSERT(m_state != Terminated); |
109 ResourceRequest request(passedRequest); | |
110 m_fetcher->willSendRequest(m_resource->identifier(), request, ResourceRespon se(), m_options.initiatorInfo); | 109 m_fetcher->willSendRequest(m_resource->identifier(), request, ResourceRespon se(), m_options.initiatorInfo); |
111 ASSERT(m_state != Terminated); | 110 ASSERT(m_state != Terminated); |
112 ASSERT(!request.isNull()); | 111 ASSERT(!request.isNull()); |
113 m_originalRequest = m_request = applyOptions(request); | 112 m_request = applyOptions(request); |
114 m_resource->updateRequest(request); | |
Nate Chapin
2015/11/04 22:13:09
ResourceClients aren't typically attached when ini
| |
115 ASSERT(m_state != Terminated); | 113 ASSERT(m_state != Terminated); |
116 m_fetcher->didInitializeResourceLoader(this); | 114 m_fetcher->didInitializeResourceLoader(this); |
117 } | 115 } |
118 | 116 |
119 void ResourceLoader::start() | 117 void ResourceLoader::start() |
120 { | 118 { |
121 ASSERT(!m_loader); | 119 ASSERT(!m_loader); |
122 ASSERT(!m_request.isNull()); | 120 ASSERT(!m_request.isNull()); |
123 ASSERT(m_deferredRequest.isNull()); | 121 ASSERT(m_deferredRequest.isNull()); |
124 | 122 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 ASSERT(!redirectResponse.isNull()); | 267 ASSERT(!redirectResponse.isNull()); |
270 newRequest.setFollowedRedirect(true); | 268 newRequest.setFollowedRedirect(true); |
271 if (!m_fetcher->canAccessRedirect(m_resource, newRequest, redirectResponse, m_options)) { | 269 if (!m_fetcher->canAccessRedirect(m_resource, newRequest, redirectResponse, m_options)) { |
272 cancel(ResourceError::cancelledDueToAccessCheckError(newRequest.url())); | 270 cancel(ResourceError::cancelledDueToAccessCheckError(newRequest.url())); |
273 return; | 271 return; |
274 } | 272 } |
275 ASSERT(m_state != Terminated); | 273 ASSERT(m_state != Terminated); |
276 | 274 |
277 applyOptions(newRequest); // canAccessRedirect() can modify m_options so we should re-apply it. | 275 applyOptions(newRequest); // canAccessRedirect() can modify m_options so we should re-apply it. |
278 m_fetcher->redirectReceived(m_resource, redirectResponse); | 276 m_fetcher->redirectReceived(m_resource, redirectResponse); |
279 ASSERT(m_state != Terminated); | 277 m_fetcher->willSendRequest(m_resource->identifier(), newRequest, redirectRes ponse, m_options.initiatorInfo); |
Nate Chapin
2015/11/04 22:13:09
This requires updating a couple layout test result
| |
280 m_resource->willFollowRedirect(newRequest, redirectResponse); | 278 m_resource->willFollowRedirect(newRequest, redirectResponse); |
281 if (newRequest.isNull() || m_state == Terminated) | 279 if (newRequest.isNull() || m_state == Terminated) |
282 return; | 280 return; |
283 | |
284 m_fetcher->willSendRequest(m_resource->identifier(), newRequest, redirectRes ponse, m_options.initiatorInfo); | |
285 ASSERT(m_state != Terminated); | |
286 ASSERT(!newRequest.isNull()); | |
287 m_resource->updateRequest(newRequest); | |
288 m_request = newRequest; | 281 m_request = newRequest; |
289 } | 282 } |
290 | 283 |
291 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length) | 284 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length) |
292 { | 285 { |
293 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); | 286 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); |
294 ASSERT(m_state == Initialized); | 287 ASSERT(m_state == Initialized); |
295 m_resource->setSerializedCachedMetadata(data, length); | 288 m_resource->setSerializedCachedMetadata(data, length); |
296 } | 289 } |
297 | 290 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 503 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
511 } | 504 } |
512 | 505 |
513 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const | 506 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const |
514 { | 507 { |
515 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); | 508 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); |
516 return request; | 509 return request; |
517 } | 510 } |
518 | 511 |
519 } | 512 } |
OLD | NEW |