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

Side by Side Diff: Source/core/fetch/ResourceLoader.cpp

Issue 1115553002: Removing blink::prefix (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 7 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
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 m_deferredRequest = m_request; 137 m_deferredRequest = m_request;
138 return; 138 return;
139 } 139 }
140 140
141 if (m_state == Terminated) 141 if (m_state == Terminated)
142 return; 142 return;
143 143
144 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); 144 RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
145 m_connectionState = ConnectionStateStarted; 145 m_connectionState = ConnectionStateStarted;
146 146
147 m_loader = adoptPtr(blink::Platform::current()->createURLLoader()); 147 m_loader = adoptPtr(Platform::current()->createURLLoader());
148 ASSERT(m_loader); 148 ASSERT(m_loader);
149 blink::WrappedResourceRequest wrappedRequest(m_request); 149 WrappedResourceRequest wrappedRequest(m_request);
150 m_loader->loadAsynchronously(wrappedRequest, this); 150 m_loader->loadAsynchronously(wrappedRequest, this);
151 } 151 }
152 152
153 void ResourceLoader::changeToSynchronous() 153 void ResourceLoader::changeToSynchronous()
154 { 154 {
155 ASSERT(m_options.synchronousPolicy == RequestAsynchronously); 155 ASSERT(m_options.synchronousPolicy == RequestAsynchronously);
156 ASSERT(m_loader); 156 ASSERT(m_loader);
157 m_loader->cancel(); 157 m_loader->cancel();
158 m_loader.clear(); 158 m_loader.clear();
159 m_request.setPriority(ResourceLoadPriorityHighest); 159 m_request.setPriority(ResourceLoadPriorityHighest);
(...skipping 18 matching lines...) Expand all
178 if (m_loader) { 178 if (m_loader) {
179 // The implementor of the WebURLLoader assumes ownership of the 179 // The implementor of the WebURLLoader assumes ownership of the
180 // threaded data receiver if it signals that it got successfully 180 // threaded data receiver if it signals that it got successfully
181 // attached. 181 // attached.
182 WebThreadedDataReceiver* webDataReceiver = new WebThreadedDataReceiver(t hreadedDataReceiver); 182 WebThreadedDataReceiver* webDataReceiver = new WebThreadedDataReceiver(t hreadedDataReceiver);
183 if (!m_loader->attachThreadedDataReceiver(webDataReceiver)) 183 if (!m_loader->attachThreadedDataReceiver(webDataReceiver))
184 delete webDataReceiver; 184 delete webDataReceiver;
185 } 185 }
186 } 186 }
187 187
188 void ResourceLoader::didDownloadData(blink::WebURLLoader*, int length, int encod edDataLength) 188 void ResourceLoader::didDownloadData(WebURLLoader*, int length, int encodedDataL ength)
189 { 189 {
190 ASSERT(m_state != Terminated); 190 ASSERT(m_state != Terminated);
191 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 191 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
192 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse); 192 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse);
193 m_host->didDownloadData(m_resource, length, encodedDataLength); 193 m_host->didDownloadData(m_resource, length, encodedDataLength);
194 if (m_state == Terminated) 194 if (m_state == Terminated)
195 return; 195 return;
196 m_resource->didDownloadData(length); 196 m_resource->didDownloadData(length);
197 } 197 }
198 198
199 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64_t encodedD ataLength) 199 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64_t encodedD ataLength)
200 { 200 {
201 // If load has been cancelled after finishing (which could happen with a 201 // If load has been cancelled after finishing (which could happen with a
202 // JavaScript that changes the window location), do nothing. 202 // JavaScript that changes the window location), do nothing.
203 if (m_state == Terminated) 203 if (m_state == Terminated)
204 return; 204 return;
205 205
206 if (m_notifiedLoadComplete) 206 if (m_notifiedLoadComplete)
207 return; 207 return;
208 m_notifiedLoadComplete = true; 208 m_notifiedLoadComplete = true;
209 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); 209 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength);
210 } 210 }
211 211
212 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in traPriorityValue) 212 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in traPriorityValue)
213 { 213 {
214 if (m_loader) { 214 if (m_loader) {
215 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority Value); 215 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority Value);
216 ASSERT(m_state != Terminated); 216 ASSERT(m_state != Terminated);
217 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>( loadPriority), intraPriorityValue); 217 m_loader->didChangePriority(static_cast<WebURLRequest::Priority>(loadPri ority), intraPriorityValue);
218 } 218 }
219 } 219 }
220 220
221 void ResourceLoader::cancelIfNotFinishing() 221 void ResourceLoader::cancelIfNotFinishing()
222 { 222 {
223 if (m_state != Initialized) 223 if (m_state != Initialized)
224 return; 224 return;
225 cancel(); 225 cancel();
226 } 226 }
227 227
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 m_notifiedLoadComplete = true; 261 m_notifiedLoadComplete = true;
262 m_host->didFailLoading(m_resource, nonNullError); 262 m_host->didFailLoading(m_resource, nonNullError);
263 } 263 }
264 264
265 if (m_state == Finishing) 265 if (m_state == Finishing)
266 m_resource->error(Resource::LoadError); 266 m_resource->error(Resource::LoadError);
267 if (m_state != Terminated) 267 if (m_state != Terminated)
268 releaseResources(); 268 releaseResources();
269 } 269 }
270 270
271 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedNewRequest, const blink::WebURLResponse& passedRedirectResponse) 271 void ResourceLoader::willSendRequest(WebURLLoader*, WebURLRequest& passedNewRequ est, const WebURLResponse& passedRedirectResponse)
272 { 272 {
273 ASSERT(m_state != Terminated); 273 ASSERT(m_state != Terminated);
274 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 274 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
275 275
276 ResourceRequest& newRequest(applyOptions(passedNewRequest.toMutableResourceR equest())); 276 ResourceRequest& newRequest(applyOptions(passedNewRequest.toMutableResourceR equest()));
277 277
278 ASSERT(!newRequest.isNull()); 278 ASSERT(!newRequest.isNull());
279 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse()); 279 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse());
280 ASSERT(!redirectResponse.isNull()); 280 ASSERT(!redirectResponse.isNull());
281 newRequest.setFollowedRedirect(true); 281 newRequest.setFollowedRedirect(true);
(...skipping 10 matching lines...) Expand all
292 if (newRequest.isNull() || m_state == Terminated) 292 if (newRequest.isNull() || m_state == Terminated)
293 return; 293 return;
294 294
295 m_host->willSendRequest(m_resource->identifier(), newRequest, redirectRespon se, m_options.initiatorInfo); 295 m_host->willSendRequest(m_resource->identifier(), newRequest, redirectRespon se, m_options.initiatorInfo);
296 ASSERT(m_state != Terminated); 296 ASSERT(m_state != Terminated);
297 ASSERT(!newRequest.isNull()); 297 ASSERT(!newRequest.isNull());
298 m_resource->updateRequest(newRequest); 298 m_resource->updateRequest(newRequest);
299 m_request = newRequest; 299 m_request = newRequest;
300 } 300 }
301 301
302 void ResourceLoader::didReceiveCachedMetadata(blink::WebURLLoader*, const char* data, int length) 302 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length)
303 { 303 {
304 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 304 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
305 ASSERT(m_state == Initialized); 305 ASSERT(m_state == Initialized);
306 m_resource->setSerializedCachedMetadata(data, length); 306 m_resource->setSerializedCachedMetadata(data, length);
307 } 307 }
308 308
309 void ResourceLoader::didSendData(blink::WebURLLoader*, unsigned long long bytesS ent, unsigned long long totalBytesToBeSent) 309 void ResourceLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, un signed long long totalBytesToBeSent)
310 { 310 {
311 ASSERT(m_state == Initialized); 311 ASSERT(m_state == Initialized);
312 m_resource->didSendData(bytesSent, totalBytesToBeSent); 312 m_resource->didSendData(bytesSent, totalBytesToBeSent);
313 } 313 }
314 314
315 bool ResourceLoader::responseNeedsAccessControlCheck() const 315 bool ResourceLoader::responseNeedsAccessControlCheck() const
316 { 316 {
317 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required. 317 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required.
318 return m_options.corsEnabled == IsCORSEnabled; 318 return m_options.corsEnabled == IsCORSEnabled;
319 } 319 }
320 320
321 void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR LResponse& response, WebDataConsumerHandle* rawHandle) 321 void ResourceLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& res ponse, WebDataConsumerHandle* rawHandle)
322 { 322 {
323 ASSERT(!response.isNull()); 323 ASSERT(!response.isNull());
324 ASSERT(m_state == Initialized); 324 ASSERT(m_state == Initialized);
325 // |rawHandle|'s ownership is transferred to the callee. 325 // |rawHandle|'s ownership is transferred to the callee.
326 OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle); 326 OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle);
327 327
328 bool isMultipartPayload = response.isMultipartPayload(); 328 bool isMultipartPayload = response.isMultipartPayload();
329 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse); 329 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse);
330 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved. 330 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved.
331 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition); 331 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition);
332 m_connectionState = ConnectionStateReceivedResponse; 332 m_connectionState = ConnectionStateReceivedResponse;
333 333
334 const ResourceResponse& resourceResponse = response.toResourceResponse(); 334 const ResourceResponse& resourceResponse = response.toResourceResponse();
335 335
336 if (responseNeedsAccessControlCheck()) { 336 if (responseNeedsAccessControlCheck()) {
337 if (response.wasFetchedViaServiceWorker()) { 337 if (response.wasFetchedViaServiceWorker()) {
338 if (response.wasFallbackRequiredByServiceWorker()) { 338 if (response.wasFallbackRequiredByServiceWorker()) {
339 ASSERT(m_fallbackRequestForServiceWorker); 339 ASSERT(m_fallbackRequestForServiceWorker);
340 m_loader->cancel(); 340 m_loader->cancel();
341 m_loader.clear(); 341 m_loader.clear();
342 m_connectionState = ConnectionStateStarted; 342 m_connectionState = ConnectionStateStarted;
343 m_request = *m_fallbackRequestForServiceWorker; 343 m_request = *m_fallbackRequestForServiceWorker;
344 m_loader = adoptPtr(blink::Platform::current()->createURLLoader( )); 344 m_loader = adoptPtr(Platform::current()->createURLLoader());
345 ASSERT(m_loader); 345 ASSERT(m_loader);
346 blink::WrappedResourceRequest wrappedRequest(m_request); 346 WrappedResourceRequest wrappedRequest(m_request);
347 m_loader->loadAsynchronously(wrappedRequest, this); 347 m_loader->loadAsynchronously(wrappedRequest, this);
348 return; 348 return;
349 } 349 }
350 } else { 350 } else {
351 // If the response successfully validated a cached resource, perform 351 // If the response successfully validated a cached resource, perform
352 // the access control with respect to it. Need to do this right here 352 // the access control with respect to it. Need to do this right here
353 // before the resource switches clients over to that validated resou rce. 353 // before the resource switches clients over to that validated resou rce.
354 Resource* resource = m_resource; 354 Resource* resource = m_resource;
355 if (resource->isCacheValidator() && resourceResponse.httpStatusCode( ) == 304) 355 if (resource->isCacheValidator() && resourceResponse.httpStatusCode( ) == 304)
356 resource = m_resource->resourceToRevalidate(); 356 resource = m_resource->resourceToRevalidate();
(...skipping 20 matching lines...) Expand all
377 377
378 if (response.toResourceResponse().isMultipart()) { 378 if (response.toResourceResponse().isMultipart()) {
379 if (!m_resource->isImage()) { 379 if (!m_resource->isImage()) {
380 cancel(); 380 cancel();
381 return; 381 return;
382 } 382 }
383 } else if (isMultipartPayload) { 383 } else if (isMultipartPayload) {
384 // Since a subresource loader does not load multipart sections progressi vely, data was delivered to the loader all at once. 384 // Since a subresource loader does not load multipart sections progressi vely, data was delivered to the loader all at once.
385 // After the first multipart section is complete, signal to delegates th at this load is "finished" 385 // After the first multipart section is complete, signal to delegates th at this load is "finished"
386 m_host->subresourceLoaderFinishedLoadingOnePart(this); 386 m_host->subresourceLoaderFinishedLoadingOnePart(this);
387 didFinishLoadingOnePart(0, blink::WebURLLoaderClient::kUnknownEncodedDat aLength); 387 didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEncodedDataLength );
388 } 388 }
389 if (m_state == Terminated) 389 if (m_state == Terminated)
390 return; 390 return;
391 391
392 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) 392 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors())
393 return; 393 return;
394 m_state = Finishing; 394 m_state = Finishing;
395 395
396 if (!m_notifiedLoadComplete) { 396 if (!m_notifiedLoadComplete) {
397 m_notifiedLoadComplete = true; 397 m_notifiedLoadComplete = true;
398 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url())); 398 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url()));
399 } 399 }
400 400
401 ASSERT(m_state != Terminated); 401 ASSERT(m_state != Terminated);
402 m_resource->error(Resource::LoadError); 402 m_resource->error(Resource::LoadError);
403 cancel(); 403 cancel();
404 } 404 }
405 405
406 void ResourceLoader::didReceiveResponse(blink::WebURLLoader* loader, const blink ::WebURLResponse& response) 406 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response)
407 { 407 {
408 didReceiveResponse(loader, response, nullptr); 408 didReceiveResponse(loader, response, nullptr);
409 } 409 }
410 410
411 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength) 411 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength)
412 { 412 {
413 ASSERT(m_state != Terminated); 413 ASSERT(m_state != Terminated);
414 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 414 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
415 m_connectionState = ConnectionStateReceivingData; 415 m_connectionState = ConnectionStateReceivingData;
416 416
417 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message 417 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message
418 // loop. When this occurs, ignoring the data is the correct action. 418 // loop. When this occurs, ignoring the data is the correct action.
419 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors()) 419 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors())
420 return; 420 return;
421 ASSERT(m_state == Initialized); 421 ASSERT(m_state == Initialized);
422 422
423 // Reference the object in this method since the additional processing can d o 423 // Reference the object in this method since the additional processing can d o
424 // anything including removing the last reference to this object. 424 // anything including removing the last reference to this object.
425 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 425 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
426 426
427 // FIXME: If we get a resource with more than 2B bytes, this code won't do t he right thing. 427 // FIXME: If we get a resource with more than 2B bytes, this code won't do t he right thing.
428 // However, with today's computers and networking speeds, this won't happen in practice. 428 // However, with today's computers and networking speeds, this won't happen in practice.
429 // Could be an issue with a giant local file. 429 // Could be an issue with a giant local file.
430 m_host->didReceiveData(m_resource, data, length, encodedDataLength); 430 m_host->didReceiveData(m_resource, data, length, encodedDataLength);
431 if (m_state == Terminated) 431 if (m_state == Terminated)
432 return; 432 return;
433 RELEASE_ASSERT(length >= 0); 433 RELEASE_ASSERT(length >= 0);
434 m_resource->appendData(data, length); 434 m_resource->appendData(data, length);
435 } 435 }
436 436
437 void ResourceLoader::didFinishLoading(blink::WebURLLoader*, double finishTime, i nt64_t encodedDataLength) 437 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength)
438 { 438 {
439 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 439 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
440 m_connectionState = ConnectionStateFinishedLoading; 440 m_connectionState = ConnectionStateFinishedLoading;
441 if (m_state != Initialized) 441 if (m_state != Initialized)
442 return; 442 return;
443 ASSERT(m_state != Terminated); 443 ASSERT(m_state != Terminated);
444 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data()); 444 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data());
445 445
446 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 446 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
447 ResourcePtr<Resource> protectResource(m_resource); 447 ResourcePtr<Resource> protectResource(m_resource);
448 m_state = Finishing; 448 m_state = Finishing;
449 m_resource->setLoadFinishTime(finishTime); 449 m_resource->setLoadFinishTime(finishTime);
450 didFinishLoadingOnePart(finishTime, encodedDataLength); 450 didFinishLoadingOnePart(finishTime, encodedDataLength);
451 if (m_state == Terminated) 451 if (m_state == Terminated)
452 return; 452 return;
453 m_resource->finish(); 453 m_resource->finish();
454 454
455 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release 455 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release
456 // the resources a second time, they have been released by cancel. 456 // the resources a second time, they have been released by cancel.
457 if (m_state == Terminated) 457 if (m_state == Terminated)
458 return; 458 return;
459 releaseResources(); 459 releaseResources();
460 } 460 }
461 461
462 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err or) 462 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error)
463 { 463 {
464 m_connectionState = ConnectionStateFailed; 464 m_connectionState = ConnectionStateFailed;
465 ASSERT(m_state != Terminated); 465 ASSERT(m_state != Terminated);
466 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data()); 466 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data());
467 467
468 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 468 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
469 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); 469 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get());
470 ResourcePtr<Resource> protectResource(m_resource); 470 ResourcePtr<Resource> protectResource(m_resource);
471 m_state = Finishing; 471 m_state = Finishing;
472 m_resource->setResourceError(error); 472 m_resource->setResourceError(error);
(...skipping 13 matching lines...) Expand all
486 releaseResources(); 486 releaseResources();
487 } 487 }
488 488
489 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const 489 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const
490 { 490 {
491 return m_host->isLoadedBy(loader); 491 return m_host->isLoadedBy(loader);
492 } 492 }
493 493
494 void ResourceLoader::requestSynchronously() 494 void ResourceLoader::requestSynchronously()
495 { 495 {
496 OwnPtr<blink::WebURLLoader> loader = adoptPtr(blink::Platform::current()->cr eateURLLoader()); 496 OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader( ));
497 ASSERT(loader); 497 ASSERT(loader);
498 498
499 // downloadToFile is not supported for synchronous requests. 499 // downloadToFile is not supported for synchronous requests.
500 ASSERT(!m_request.downloadToFile()); 500 ASSERT(!m_request.downloadToFile());
501 501
502 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 502 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
503 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); 503 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get());
504 ResourcePtr<Resource> protectResource(m_resource); 504 ResourcePtr<Resource> protectResource(m_resource);
505 505
506 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); 506 RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
507 m_connectionState = ConnectionStateStarted; 507 m_connectionState = ConnectionStateStarted;
508 508
509 blink::WrappedResourceRequest requestIn(m_request); 509 WrappedResourceRequest requestIn(m_request);
510 blink::WebURLResponse responseOut; 510 WebURLResponse responseOut;
511 responseOut.initialize(); 511 responseOut.initialize();
512 blink::WebURLError errorOut; 512 WebURLError errorOut;
513 blink::WebData dataOut; 513 WebData dataOut;
514 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); 514 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
515 if (errorOut.reason) { 515 if (errorOut.reason) {
516 didFail(0, errorOut); 516 didFail(0, errorOut);
517 return; 517 return;
518 } 518 }
519 didReceiveResponse(0, responseOut); 519 didReceiveResponse(0, responseOut);
520 if (m_state == Terminated) 520 if (m_state == Terminated)
521 return; 521 return;
522 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 522 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
523 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : blink::WebURLLoaderClient::kUnknownEncodedDataLength; 523 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength;
524 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength); 524 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength);
525 m_resource->setResourceBuffer(dataOut); 525 m_resource->setResourceBuffer(dataOut);
526 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 526 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
527 } 527 }
528 528
529 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const 529 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
530 { 530 {
531 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 531 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
532 return request; 532 return request;
533 } 533 }
534 534
535 } 535 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698