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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added comments Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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
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
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
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 { 702 {
692 ASSERT(m_fallbackRequestForServiceWorker.isNull()); 703 ASSERT(m_fallbackRequestForServiceWorker.isNull());
693 704
694 if (!m_actualRequest.isNull()) { 705 if (!m_actualRequest.isNull()) {
695 // FIXME: Timeout should be applied to whole fetch, not for each of 706 // FIXME: Timeout should be applied to whole fetch, not for each of
696 // preflight and actual request. 707 // preflight and actual request.
697 m_timeoutTimer.stop(); 708 m_timeoutTimer.stop();
698 ASSERT(!m_sameOriginRequest); 709 ASSERT(!m_sameOriginRequest);
699 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); 710 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
700 loadActualRequest(); 711 loadActualRequest();
712 // |this| may be dead here in async mode.
701 return; 713 return;
702 } 714 }
703 715
704 ThreadableLoaderClient* client = m_client; 716 ThreadableLoaderClient* client = m_client;
705 m_client = 0; 717 m_client = 0;
706 // Don't clear the resource as the client may need to access the downloaded 718 // Don't clear the resource as the client may need to access the downloaded
707 // file which will be released when the resource is destoryed. 719 // file which will be released when the resource is destoryed.
708 if (m_async) { 720 if (m_async) {
709 m_timeoutTimer.stop(); 721 m_timeoutTimer.stop();
710 m_requestStartedSeconds = 0.0; 722 m_requestStartedSeconds = 0.0;
(...skipping 29 matching lines...) Expand all
740 ResourceRequest actualRequest = m_actualRequest; 752 ResourceRequest actualRequest = m_actualRequest;
741 ResourceLoaderOptions actualOptions = m_actualOptions; 753 ResourceLoaderOptions actualOptions = m_actualOptions;
742 m_actualRequest = ResourceRequest(); 754 m_actualRequest = ResourceRequest();
743 m_actualOptions = ResourceLoaderOptions(); 755 m_actualOptions = ResourceLoaderOptions();
744 756
745 actualRequest.setHTTPOrigin(securityOrigin()); 757 actualRequest.setHTTPOrigin(securityOrigin());
746 758
747 clearResource(); 759 clearResource();
748 760
749 loadRequest(actualRequest, actualOptions); 761 loadRequest(actualRequest, actualOptions);
762 // |this| may be dead here in async mode.
750 } 763 }
751 764
752 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription) 765 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription)
753 { 766 {
754 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); 767 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription);
755 768
756 // Prevent handleSuccessfulFinish() from bypassing access check. 769 // Prevent handleSuccessfulFinish() from bypassing access check.
757 m_actualRequest = ResourceRequest(); 770 m_actualRequest = ResourceRequest();
758 771
759 ThreadableLoaderClient* client = m_client; 772 ThreadableLoaderClient* client = m_client;
(...skipping 30 matching lines...) Expand all
790 if (!m_actualRequest.isNull()) 803 if (!m_actualRequest.isNull())
791 resourceLoaderOptions.dataBufferingPolicy = BufferData; 804 resourceLoaderOptions.dataBufferingPolicy = BufferData;
792 805
793 if (m_options.timeoutMilliseconds > 0) 806 if (m_options.timeoutMilliseconds > 0)
794 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE); 807 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE);
795 808
796 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons); 809 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons);
797 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 810 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
798 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); 811 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
799 ASSERT(!resource()); 812 ASSERT(!resource());
813
800 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio) 814 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio)
801 setResource(RawResource::fetchMedia(newRequest, document().fetcher() )); 815 setResource(RawResource::fetchMedia(newRequest, document().fetcher() ));
802 else if (request.requestContext() == WebURLRequest::RequestContextManife st) 816 else if (request.requestContext() == WebURLRequest::RequestContextManife st)
803 setResource(RawResource::fetchManifest(newRequest, document().fetche r())); 817 setResource(RawResource::fetchManifest(newRequest, document().fetche r()));
804 else 818 else
805 setResource(RawResource::fetch(newRequest, document().fetcher())); 819 setResource(RawResource::fetch(newRequest, document().fetcher()));
806 if (resource() && resource()->loader()) { 820
821 if (!resource()) {
822 ThreadableLoaderClient* client = m_client;
823 clear();
824 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR L.string(), "Failed to start loading."));
825 // |this| may be dead here.
826 return;
827 }
828
829 if (resource()->loader()) {
807 unsigned long identifier = resource()->identifier(); 830 unsigned long identifier = resource()->identifier();
808 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client); 831 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client);
809 } 832 }
810 return; 833 return;
811 } 834 }
812 835
813 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption s); 836 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption s);
814 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 837 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
815 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); 838 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
816 ResourcePtr<Resource> resource = RawResource::fetchSynchronously(fetchReques t, document().fetcher()); 839 ResourcePtr<Resource> resource = RawResource::fetchSynchronously(fetchReques t, document().fetcher());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin (); 912 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin ();
890 } 913 }
891 914
892 Document& DocumentThreadableLoader::document() const 915 Document& DocumentThreadableLoader::document() const
893 { 916 {
894 ASSERT(m_document); 917 ASSERT(m_document);
895 return *m_document; 918 return *m_document;
896 } 919 }
897 920
898 } // namespace blink 921 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698