OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Max number of CORS redirects handled in DocumentThreadableLoader. | 100 // Max number of CORS redirects handled in DocumentThreadableLoader. |
101 // Same number as net/url_request/url_request.cc, and | 101 // Same number as net/url_request/url_request.cc, and |
102 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. | 102 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. |
103 // FIXME: currently the number of redirects is counted and limited here and in | 103 // FIXME: currently the number of redirects is counted and limited here and in |
104 // net/url_request/url_request.cc separately. | 104 // net/url_request/url_request.cc separately. |
105 static const int kMaxCORSRedirects = 20; | 105 static const int kMaxCORSRedirects = 20; |
106 | 106 |
107 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, con
st ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoa
derOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) | 107 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, con
st ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoa
derOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) |
108 { | 108 { |
109 // The loader will be deleted as soon as this function exits. | 109 // The loader will be deleted as soon as this function exits. |
110 RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoa
der(document, &client, LoadSynchronously, request, options, resourceLoaderOption
s)); | 110 RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoa
der(document, &client, LoadSynchronously, options, resourceLoaderOptions)); |
| 111 loader->start(request); |
111 ASSERT(loader->hasOneRef()); | 112 ASSERT(loader->hasOneRef()); |
112 } | 113 } |
113 | 114 |
114 PassRefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document&
document, ThreadableLoaderClient* client, const ResourceRequest& request, const
ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOpt
ions) | 115 PassRefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document&
document, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options
, const ResourceLoaderOptions& resourceLoaderOptions) |
115 { | 116 { |
116 RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoa
der(document, client, LoadAsynchronously, request, options, resourceLoaderOption
s)); | 117 return adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchron
ously, options, resourceLoaderOptions)); |
117 if (!loader->resource()) | |
118 loader = nullptr; | |
119 return loader.release(); | |
120 } | 118 } |
121 | 119 |
122 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
eLoaderClient* client, BlockingBehavior blockingBehavior, const ResourceRequest&
request, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& r
esourceLoaderOptions) | 120 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
eLoaderClient* client, BlockingBehavior blockingBehavior, const ThreadableLoader
Options& options, const ResourceLoaderOptions& resourceLoaderOptions) |
123 : m_client(client) | 121 : m_client(client) |
124 , m_document(&document) | 122 , m_document(&document) |
125 , m_options(options) | 123 , m_options(options) |
126 , m_resourceLoaderOptions(resourceLoaderOptions) | 124 , m_resourceLoaderOptions(resourceLoaderOptions) |
127 , m_forceDoNotAllowStoredCredentials(false) | 125 , m_forceDoNotAllowStoredCredentials(false) |
128 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin) | 126 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin) |
129 , m_sameOriginRequest(securityOrigin()->canRequestNoSuborigin(request.url())
) | 127 , m_sameOriginRequest(false) |
130 , m_crossOriginNonSimpleRequest(false) | 128 , m_crossOriginNonSimpleRequest(false) |
131 , m_isUsingDataConsumerHandle(false) | 129 , m_isUsingDataConsumerHandle(false) |
132 , m_async(blockingBehavior == LoadAsynchronously) | 130 , m_async(blockingBehavior == LoadAsynchronously) |
133 , m_requestContext(request.requestContext()) | 131 , m_requestContext(WebURLRequest::RequestContextUnspecified) |
134 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) | 132 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) |
135 , m_requestStartedSeconds(0.0) | 133 , m_requestStartedSeconds(0.0) |
136 , m_corsRedirectLimit(kMaxCORSRedirects) | 134 , m_corsRedirectLimit(kMaxCORSRedirects) |
137 , m_redirectMode(request.fetchRedirectMode()) | 135 , m_redirectMode(WebURLRequest::FetchRedirectModeFollow) |
138 { | 136 { |
139 ASSERT(client); | 137 ASSERT(client); |
| 138 } |
| 139 |
| 140 void DocumentThreadableLoader::start(const ResourceRequest& request) |
| 141 { |
140 // Setting an outgoing referer is only supported in the async code path. | 142 // Setting an outgoing referer is only supported in the async code path. |
141 ASSERT(m_async || request.httpReferrer().isEmpty()); | 143 ASSERT(m_async || request.httpReferrer().isEmpty()); |
142 | 144 |
| 145 m_sameOriginRequest = securityOrigin()->canRequestNoSuborigin(request.url())
; |
| 146 m_requestContext = request.requestContext(); |
| 147 m_redirectMode = request.fetchRedirectMode(); |
| 148 |
143 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == DenyCrossO
riginRequests) { | 149 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == DenyCrossO
riginRequests) { |
144 ThreadableLoaderClient* client = m_client; | 150 ThreadableLoaderClient* client = m_client; |
145 clear(); | 151 clear(); |
146 client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url()
.string(), "Cross origin requests are not supported.")); | 152 client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url()
.string(), "Cross origin requests are not supported.")); |
147 // |this| may be dead here. | 153 // |this| may be dead here. |
148 return; | 154 return; |
149 } | 155 } |
150 | 156 |
151 m_requestStartedSeconds = monotonicallyIncreasingTime(); | 157 m_requestStartedSeconds = monotonicallyIncreasingTime(); |
152 | 158 |
(...skipping 17 matching lines...) Expand all Loading... |
170 // - ThreadableLoader is used as backend for all javascript initiated networ
k | 176 // - ThreadableLoader is used as backend for all javascript initiated networ
k |
171 // fetches. | 177 // fetches. |
172 // - Note that ThreadableLoader is also used for non-network fetch such as | 178 // - Note that ThreadableLoader is also used for non-network fetch such as |
173 // FileReaderLoader. However it emulates GET method so signal is not | 179 // FileReaderLoader. However it emulates GET method so signal is not |
174 // recorded here. | 180 // recorded here. |
175 // - ThreadableLoader w/ non-GET request is only created from javascript | 181 // - ThreadableLoader w/ non-GET request is only created from javascript |
176 // initiated fetch. | 182 // initiated fetch. |
177 // - Some non-script initiated fetches such as WorkerScriptLoader also use | 183 // - Some non-script initiated fetches such as WorkerScriptLoader also use |
178 // ThreadableLoader, but they are guaranteed to use GET method. | 184 // ThreadableLoader, but they are guaranteed to use GET method. |
179 if (request.httpMethod() != HTTPNames::GET) { | 185 if (request.httpMethod() != HTTPNames::GET) { |
180 if (Page* page = document.page()) | 186 if (Page* page = m_document->page()) |
181 page->chromeClient().didObserveNonGetFetchFromScript(); | 187 page->chromeClient().didObserveNonGetFetchFromScript(); |
182 } | 188 } |
183 | 189 |
184 // If the fetch request will be handled by the ServiceWorker, the | 190 // If the fetch request will be handled by the ServiceWorker, the |
185 // FetchRequestMode of the request must be FetchRequestModeCORS or | 191 // FetchRequestMode of the request must be FetchRequestModeCORS or |
186 // FetchRequestModeCORSWithForcedPreflight. Otherwise the ServiceWorker can | 192 // FetchRequestModeCORSWithForcedPreflight. Otherwise the ServiceWorker can |
187 // return a opaque response which is from the other origin site and the | 193 // return a opaque response which is from the other origin site and the |
188 // script in the page can read the content. | 194 // script in the page can read the content. |
189 // | 195 // |
190 // We assume that ServiceWorker is skipped for sync requests and unsupported | 196 // We assume that ServiceWorker is skipped for sync requests and unsupported |
191 // protocol requests by content/ code. | 197 // protocol requests by content/ code. |
192 if (m_async && !request.skipServiceWorker() && SchemeRegistry::shouldTreatUR
LSchemeAsAllowingServiceWorkers(request.url().protocol()) && document.fetcher()-
>isControlledByServiceWorker()) { | 198 if (m_async && !request.skipServiceWorker() && SchemeRegistry::shouldTreatUR
LSchemeAsAllowingServiceWorkers(request.url().protocol()) && m_document->fetcher
()->isControlledByServiceWorker()) { |
193 ResourceRequest newRequest(request); | 199 ResourceRequest newRequest(request); |
194 // FetchRequestMode should be set by the caller. But the expected value | 200 // FetchRequestMode should be set by the caller. But the expected value |
195 // of FetchRequestMode is not speced yet except for XHR. So we set here. | 201 // of FetchRequestMode is not speced yet except for XHR. So we set here. |
196 // FIXME: When we support fetch API in document, this value should not | 202 // FIXME: When we support fetch API in document, this value should not |
197 // be overridden here. | 203 // be overridden here. |
198 if (options.preflightPolicy == ForcePreflight) | 204 if (m_options.preflightPolicy == ForcePreflight) |
199 newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORSWi
thForcedPreflight); | 205 newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORSWi
thForcedPreflight); |
200 else | 206 else |
201 newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); | 207 newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); |
202 | 208 |
203 m_fallbackRequestForServiceWorker = ResourceRequest(request); | 209 m_fallbackRequestForServiceWorker = ResourceRequest(request); |
204 m_fallbackRequestForServiceWorker.setSkipServiceWorker(true); | 210 m_fallbackRequestForServiceWorker.setSkipServiceWorker(true); |
205 | 211 |
206 loadRequest(newRequest, m_resourceLoaderOptions); | 212 loadRequest(newRequest, m_resourceLoaderOptions); |
| 213 // |this| may be dead here. |
207 return; | 214 return; |
208 } | 215 } |
209 | 216 |
210 dispatchInitialRequest(request); | 217 dispatchInitialRequest(request); |
211 // |this| may be dead here in async mode. | 218 // |this| may be dead here in async mode. |
212 } | 219 } |
213 | 220 |
214 void DocumentThreadableLoader::dispatchInitialRequest(const ResourceRequest& req
uest) | 221 void DocumentThreadableLoader::dispatchInitialRequest(const ResourceRequest& req
uest) |
215 { | 222 { |
216 if (m_sameOriginRequest || m_options.crossOriginRequestPolicy == AllowCrossO
riginRequests) { | 223 if (m_sameOriginRequest || m_options.crossOriginRequestPolicy == AllowCrossO
riginRequests) { |
217 loadRequest(request, m_resourceLoaderOptions); | 224 loadRequest(request, m_resourceLoaderOptions); |
| 225 // |this| may be dead here in async mode. |
218 return; | 226 return; |
219 } | 227 } |
220 | 228 |
221 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); | 229 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); |
222 | 230 |
223 makeCrossOriginAccessRequest(request); | 231 makeCrossOriginAccessRequest(request); |
224 // |this| may be dead here in async mode. | 232 // |this| may be dead here in async mode. |
225 } | 233 } |
226 | 234 |
227 void DocumentThreadableLoader::makeCrossOriginAccessRequest(const ResourceReques
t& request) | 235 void DocumentThreadableLoader::makeCrossOriginAccessRequest(const ResourceReques
t& request) |
(...skipping 19 matching lines...) Expand all Loading... |
247 // example, referrer. We need to accept them. For security, we must reject | 255 // example, referrer. We need to accept them. For security, we must reject |
248 // forbidden headers/methods at the point we accept user's input. Not here. | 256 // forbidden headers/methods at the point we accept user's input. Not here. |
249 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO
rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option
s.preflightPolicy == PreventPreflight) { | 257 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO
rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option
s.preflightPolicy == PreventPreflight) { |
250 ResourceRequest crossOriginRequest(request); | 258 ResourceRequest crossOriginRequest(request); |
251 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); | 259 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); |
252 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe
ctiveAllowCredentials()); | 260 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe
ctiveAllowCredentials()); |
253 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. | 261 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. |
254 // FIXME: We should set it in the caller of DocumentThreadableLoader. | 262 // FIXME: We should set it in the caller of DocumentThreadableLoader. |
255 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); | 263 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); |
256 loadRequest(crossOriginRequest, crossOriginOptions); | 264 loadRequest(crossOriginRequest, crossOriginOptions); |
| 265 // |this| may be dead here in async mode. |
257 } else { | 266 } else { |
258 m_crossOriginNonSimpleRequest = true; | 267 m_crossOriginNonSimpleRequest = true; |
259 | 268 |
260 ResourceRequest crossOriginRequest(request); | 269 ResourceRequest crossOriginRequest(request); |
261 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); | 270 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); |
262 // Do not set the Origin header for preflight requests. | 271 // Do not set the Origin header for preflight requests. |
263 updateRequestForAccessControl(crossOriginRequest, 0, effectiveAllowCrede
ntials()); | 272 updateRequestForAccessControl(crossOriginRequest, 0, effectiveAllowCrede
ntials()); |
264 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. | 273 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. |
265 // FIXME: We should set it in the caller of DocumentThreadableLoader. | 274 // FIXME: We should set it in the caller of DocumentThreadableLoader. |
266 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); | 275 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); |
267 m_actualRequest = crossOriginRequest; | 276 m_actualRequest = crossOriginRequest; |
268 m_actualOptions = crossOriginOptions; | 277 m_actualOptions = crossOriginOptions; |
269 | 278 |
270 bool shouldForcePreflight = InspectorInstrumentation::shouldForceCORSPre
flight(m_document); | 279 bool shouldForcePreflight = InspectorInstrumentation::shouldForceCORSPre
flight(m_document); |
271 bool canSkipPreflight = CrossOriginPreflightResultCache::shared().canSki
pPreflight(securityOrigin()->toString(), m_actualRequest.url(), effectiveAllowCr
edentials(), m_actualRequest.httpMethod(), m_actualRequest.httpHeaderFields()); | 280 bool canSkipPreflight = CrossOriginPreflightResultCache::shared().canSki
pPreflight(securityOrigin()->toString(), m_actualRequest.url(), effectiveAllowCr
edentials(), m_actualRequest.httpMethod(), m_actualRequest.httpHeaderFields()); |
272 if (canSkipPreflight && !shouldForcePreflight) { | 281 if (canSkipPreflight && !shouldForcePreflight) { |
273 loadActualRequest(); | 282 loadActualRequest(); |
| 283 // |this| may be dead here in async mode. |
274 } else { | 284 } else { |
275 ResourceRequest preflightRequest = createAccessControlPreflightReque
st(m_actualRequest, securityOrigin()); | 285 ResourceRequest preflightRequest = createAccessControlPreflightReque
st(m_actualRequest, securityOrigin()); |
276 // Create a ResourceLoaderOptions for preflight. | 286 // Create a ResourceLoaderOptions for preflight. |
277 ResourceLoaderOptions preflightOptions = m_actualOptions; | 287 ResourceLoaderOptions preflightOptions = m_actualOptions; |
278 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; | 288 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; |
279 loadRequest(preflightRequest, preflightOptions); | 289 loadRequest(preflightRequest, preflightOptions); |
| 290 // |this| may be dead here in async mode. |
280 } | 291 } |
281 } | 292 } |
282 } | 293 } |
283 | 294 |
284 DocumentThreadableLoader::~DocumentThreadableLoader() | 295 DocumentThreadableLoader::~DocumentThreadableLoader() |
285 { | 296 { |
286 // TODO(oilpan): Remove this once DocumentThreadableLoader is once again a R
esourceOwner. | 297 // TODO(oilpan): Remove this once DocumentThreadableLoader is once again a R
esourceOwner. |
287 clearResource(); | 298 clearResource(); |
288 } | 299 } |
289 | 300 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 { | 707 { |
697 ASSERT(m_fallbackRequestForServiceWorker.isNull()); | 708 ASSERT(m_fallbackRequestForServiceWorker.isNull()); |
698 | 709 |
699 if (!m_actualRequest.isNull()) { | 710 if (!m_actualRequest.isNull()) { |
700 // FIXME: Timeout should be applied to whole fetch, not for each of | 711 // FIXME: Timeout should be applied to whole fetch, not for each of |
701 // preflight and actual request. | 712 // preflight and actual request. |
702 m_timeoutTimer.stop(); | 713 m_timeoutTimer.stop(); |
703 ASSERT(!m_sameOriginRequest); | 714 ASSERT(!m_sameOriginRequest); |
704 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); | 715 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); |
705 loadActualRequest(); | 716 loadActualRequest(); |
| 717 // |this| may be dead here in async mode. |
706 return; | 718 return; |
707 } | 719 } |
708 | 720 |
709 ThreadableLoaderClient* client = m_client; | 721 ThreadableLoaderClient* client = m_client; |
710 m_client = 0; | 722 m_client = 0; |
711 // Don't clear the resource as the client may need to access the downloaded | 723 // Don't clear the resource as the client may need to access the downloaded |
712 // file which will be released when the resource is destoryed. | 724 // file which will be released when the resource is destoryed. |
713 if (m_async) { | 725 if (m_async) { |
714 m_timeoutTimer.stop(); | 726 m_timeoutTimer.stop(); |
715 m_requestStartedSeconds = 0.0; | 727 m_requestStartedSeconds = 0.0; |
(...skipping 29 matching lines...) Expand all Loading... |
745 ResourceRequest actualRequest = m_actualRequest; | 757 ResourceRequest actualRequest = m_actualRequest; |
746 ResourceLoaderOptions actualOptions = m_actualOptions; | 758 ResourceLoaderOptions actualOptions = m_actualOptions; |
747 m_actualRequest = ResourceRequest(); | 759 m_actualRequest = ResourceRequest(); |
748 m_actualOptions = ResourceLoaderOptions(); | 760 m_actualOptions = ResourceLoaderOptions(); |
749 | 761 |
750 actualRequest.setHTTPOrigin(securityOrigin()); | 762 actualRequest.setHTTPOrigin(securityOrigin()); |
751 | 763 |
752 clearResource(); | 764 clearResource(); |
753 | 765 |
754 loadRequest(actualRequest, actualOptions); | 766 loadRequest(actualRequest, actualOptions); |
| 767 // |this| may be dead here in async mode. |
755 } | 768 } |
756 | 769 |
757 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S
tring& errorDescription) | 770 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S
tring& errorDescription) |
758 { | 771 { |
759 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); | 772 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); |
760 | 773 |
761 // Prevent handleSuccessfulFinish() from bypassing access check. | 774 // Prevent handleSuccessfulFinish() from bypassing access check. |
762 m_actualRequest = ResourceRequest(); | 775 m_actualRequest = ResourceRequest(); |
763 | 776 |
764 ThreadableLoaderClient* client = m_client; | 777 ThreadableLoaderClient* client = m_client; |
(...skipping 30 matching lines...) Expand all Loading... |
795 if (!m_actualRequest.isNull()) | 808 if (!m_actualRequest.isNull()) |
796 resourceLoaderOptions.dataBufferingPolicy = BufferData; | 809 resourceLoaderOptions.dataBufferingPolicy = BufferData; |
797 | 810 |
798 if (m_options.timeoutMilliseconds > 0) | 811 if (m_options.timeoutMilliseconds > 0) |
799 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0,
BLINK_FROM_HERE); | 812 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0,
BLINK_FROM_HERE); |
800 | 813 |
801 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti
ons); | 814 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti
ons); |
802 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) | 815 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) |
803 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); | 816 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); |
804 ASSERT(!resource()); | 817 ASSERT(!resource()); |
| 818 |
805 if (request.requestContext() == WebURLRequest::RequestContextVideo || re
quest.requestContext() == WebURLRequest::RequestContextAudio) | 819 if (request.requestContext() == WebURLRequest::RequestContextVideo || re
quest.requestContext() == WebURLRequest::RequestContextAudio) |
806 setResource(RawResource::fetchMedia(newRequest, document().fetcher()
)); | 820 setResource(RawResource::fetchMedia(newRequest, document().fetcher()
)); |
807 else if (request.requestContext() == WebURLRequest::RequestContextManife
st) | 821 else if (request.requestContext() == WebURLRequest::RequestContextManife
st) |
808 setResource(RawResource::fetchManifest(newRequest, document().fetche
r())); | 822 setResource(RawResource::fetchManifest(newRequest, document().fetche
r())); |
809 else | 823 else |
810 setResource(RawResource::fetch(newRequest, document().fetcher())); | 824 setResource(RawResource::fetch(newRequest, document().fetcher())); |
811 if (resource() && resource()->loader()) { | 825 |
| 826 if (!resource()) { |
| 827 ThreadableLoaderClient* client = m_client; |
| 828 clear(); |
| 829 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR
L.string(), "Failed to start loading.")); |
| 830 // |this| may be dead here. |
| 831 return; |
| 832 } |
| 833 |
| 834 if (resource()->loader()) { |
812 unsigned long identifier = resource()->identifier(); | 835 unsigned long identifier = resource()->identifier(); |
813 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC
lient(m_document, identifier, m_client); | 836 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC
lient(m_document, identifier, m_client); |
814 } | 837 } |
815 return; | 838 return; |
816 } | 839 } |
817 | 840 |
818 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption
s); | 841 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption
s); |
819 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) | 842 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) |
820 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); | 843 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); |
821 ResourcePtr<Resource> resource = RawResource::fetchSynchronously(fetchReques
t, document().fetcher()); | 844 ResourcePtr<Resource> resource = RawResource::fetchSynchronously(fetchReques
t, document().fetcher()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); | 917 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); |
895 } | 918 } |
896 | 919 |
897 Document& DocumentThreadableLoader::document() const | 920 Document& DocumentThreadableLoader::document() const |
898 { | 921 { |
899 ASSERT(m_document); | 922 ASSERT(m_document); |
900 return *m_document; | 923 return *m_document; |
901 } | 924 } |
902 | 925 |
903 } // namespace blink | 926 } // namespace blink |
OLD | NEW |