OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
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 Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 DEFINE_TRACE(Resource) | 194 DEFINE_TRACE(Resource) |
195 { | 195 { |
196 visitor->trace(m_loader); | 196 visitor->trace(m_loader); |
197 #if ENABLE(OILPAN) | 197 #if ENABLE(OILPAN) |
198 visitor->trace(m_cacheHandler); | 198 visitor->trace(m_cacheHandler); |
199 #endif | 199 #endif |
200 } | 200 } |
201 | 201 |
202 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) | 202 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) |
203 { | 203 { |
| 204 RELEASE_ASSERT(!m_loader); |
204 m_options = options; | 205 m_options = options; |
205 m_loading = true; | 206 m_loading = true; |
| 207 m_status = Pending; |
206 | 208 |
207 ResourceRequest request(m_revalidatingRequest.isNull() ? m_resourceRequest :
m_revalidatingRequest); | 209 ResourceRequest& request(m_revalidatingRequest.isNull() ? m_resourceRequest
: m_revalidatingRequest); |
208 if (!accept().isEmpty()) | 210 if (!accept().isEmpty()) |
209 request.setHTTPAccept(accept()); | 211 request.setHTTPAccept(accept()); |
| 212 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC
redentials); |
210 | 213 |
211 // FIXME: It's unfortunate that the cache layer and below get to know anythi
ng about fragment identifiers. | 214 // FIXME: It's unfortunate that the cache layer and below get to know anythi
ng about fragment identifiers. |
212 // We should look into removing the expectation of that knowledge from the p
latform network stacks. | 215 // We should look into removing the expectation of that knowledge from the p
latform network stacks. |
| 216 KURL urlWithoutFragment = request.url(); |
213 if (!m_fragmentIdentifierForRequest.isNull()) { | 217 if (!m_fragmentIdentifierForRequest.isNull()) { |
214 KURL url = request.url(); | 218 KURL url = request.url(); |
215 url.setFragmentIdentifier(m_fragmentIdentifierForRequest); | 219 url.setFragmentIdentifier(m_fragmentIdentifierForRequest); |
216 request.setURL(url); | 220 request.setURL(url); |
217 m_fragmentIdentifierForRequest = String(); | 221 m_fragmentIdentifierForRequest = String(); |
218 } | 222 } |
219 m_status = Pending; | 223 |
220 if (m_loader) { | 224 m_loader = ResourceLoader::create(fetcher, this); |
221 ASSERT(m_revalidatingRequest.isNull()); | 225 m_loader->start(request); |
222 RELEASE_ASSERT(m_options.synchronousPolicy == RequestSynchronously); | 226 // If the request reference is null (i.e., a synchronous revalidation will |
223 m_loader->changeToSynchronous(); | 227 // null the request), don't make the request non-null by setting the url. |
224 return; | 228 if (!request.isNull()) |
225 } | 229 request.setURL(urlWithoutFragment); |
226 m_loader = ResourceLoader::create(fetcher, this, request, options); | |
227 m_loader->start(); | |
228 } | 230 } |
229 | 231 |
230 void Resource::checkNotify() | 232 void Resource::checkNotify() |
231 { | 233 { |
232 if (isLoading()) | 234 if (isLoading()) |
233 return; | 235 return; |
234 | 236 |
235 ResourceClientWalker<ResourceClient> w(m_clients); | 237 ResourceClientWalker<ResourceClient> w(m_clients); |
236 while (ResourceClient* c = w.next()) | 238 while (ResourceClient* c = w.next()) |
237 c->notifyFinished(this); | 239 c->notifyFinished(this); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 419 |
418 const ResourceRequest& Resource::lastResourceRequest() const | 420 const ResourceRequest& Resource::lastResourceRequest() const |
419 { | 421 { |
420 if (!m_redirectChain.size()) | 422 if (!m_redirectChain.size()) |
421 return m_resourceRequest; | 423 return m_resourceRequest; |
422 return m_redirectChain.last().m_request; | 424 return m_redirectChain.last().m_request; |
423 } | 425 } |
424 | 426 |
425 void Resource::willFollowRedirect(ResourceRequest& newRequest, const ResourceRes
ponse& redirectResponse) | 427 void Resource::willFollowRedirect(ResourceRequest& newRequest, const ResourceRes
ponse& redirectResponse) |
426 { | 428 { |
| 429 newRequest.setAllowStoredCredentials(m_options.allowCredentials == AllowStor
edCredentials); |
427 m_redirectChain.append(RedirectPair(newRequest, redirectResponse)); | 430 m_redirectChain.append(RedirectPair(newRequest, redirectResponse)); |
428 m_requestedFromNetworkingLayer = true; | 431 m_requestedFromNetworkingLayer = true; |
429 } | 432 } |
430 | 433 |
431 bool Resource::unlock() | 434 bool Resource::unlock() |
432 { | 435 { |
433 if (!m_data) | 436 if (!m_data) |
434 return false; | 437 return false; |
435 | 438 |
436 if (!m_data->isLocked()) | 439 if (!m_data->isLocked()) |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 831 } |
829 | 832 |
830 m_resourceRequest = m_revalidatingRequest; | 833 m_resourceRequest = m_revalidatingRequest; |
831 m_revalidatingRequest = ResourceRequest(); | 834 m_revalidatingRequest = ResourceRequest(); |
832 } | 835 } |
833 | 836 |
834 void Resource::revalidationFailed() | 837 void Resource::revalidationFailed() |
835 { | 838 { |
836 m_resourceRequest = m_revalidatingRequest; | 839 m_resourceRequest = m_revalidatingRequest; |
837 m_revalidatingRequest = ResourceRequest(); | 840 m_revalidatingRequest = ResourceRequest(); |
| 841 m_redirectChain.clear(); |
838 m_data.clear(); | 842 m_data.clear(); |
839 m_cachedMetadata.clear(); | 843 m_cachedMetadata.clear(); |
840 destroyDecodedDataForFailedRevalidation(); | 844 destroyDecodedDataForFailedRevalidation(); |
841 } | 845 } |
842 | 846 |
843 bool Resource::canReuseRedirectChain() | 847 bool Resource::canReuseRedirectChain() |
844 { | 848 { |
845 for (auto& redirect : m_redirectChain) { | 849 for (auto& redirect : m_redirectChain) { |
846 if (!canUseResponse(redirect.m_redirectResponse, m_responseTimestamp)) | 850 if (!canUseResponse(redirect.m_redirectResponse, m_responseTimestamp)) |
847 return false; | 851 return false; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 case Resource::Media: | 1105 case Resource::Media: |
1102 return "Media"; | 1106 return "Media"; |
1103 case Resource::Manifest: | 1107 case Resource::Manifest: |
1104 return "Manifest"; | 1108 return "Manifest"; |
1105 } | 1109 } |
1106 ASSERT_NOT_REACHED(); | 1110 ASSERT_NOT_REACHED(); |
1107 return "Unknown"; | 1111 return "Unknown"; |
1108 } | 1112 } |
1109 | 1113 |
1110 } // namespace blink | 1114 } // namespace blink |
OLD | NEW |