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

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

Issue 206223005: Forbid setting responseType on all sync XHRs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests that set responseType on sync XHRs. Created 6 years, 9 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) 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const 441 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const
442 { 442 {
443 return m_host->isLoadedBy(loader); 443 return m_host->isLoadedBy(loader);
444 } 444 }
445 445
446 void ResourceLoader::requestSynchronously() 446 void ResourceLoader::requestSynchronously()
447 { 447 {
448 OwnPtr<blink::WebURLLoader> loader = adoptPtr(blink::Platform::current()->cr eateURLLoader()); 448 OwnPtr<blink::WebURLLoader> loader = adoptPtr(blink::Platform::current()->cr eateURLLoader());
449 ASSERT(loader); 449 ASSERT(loader);
450 450
451 // downloadToFile is not supported for synchronous requests.
452 ASSERT(!m_request.downloadToFile());
453
451 RefPtr<ResourceLoader> protect(this); 454 RefPtr<ResourceLoader> protect(this);
452 RefPtr<ResourceLoaderHost> protectHost(m_host); 455 RefPtr<ResourceLoaderHost> protectHost(m_host);
453 ResourcePtr<Resource> protectResource(m_resource); 456 ResourcePtr<Resource> protectResource(m_resource);
454 457
455 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); 458 RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
456 m_connectionState = ConnectionStateStarted; 459 m_connectionState = ConnectionStateStarted;
457 460
458 blink::WrappedResourceRequest requestIn(m_request); 461 blink::WrappedResourceRequest requestIn(m_request);
459 requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStore dCredentials); 462 requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStore dCredentials);
460 blink::WebURLResponse responseOut; 463 blink::WebURLResponse responseOut;
461 responseOut.initialize(); 464 responseOut.initialize();
462 blink::WebURLError errorOut; 465 blink::WebURLError errorOut;
463 blink::WebData dataOut; 466 blink::WebData dataOut;
464 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); 467 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
465 if (errorOut.reason) { 468 if (errorOut.reason) {
466 didFail(0, errorOut); 469 didFail(0, errorOut);
467 return; 470 return;
468 } 471 }
469 didReceiveResponse(0, responseOut); 472 didReceiveResponse(0, responseOut);
470 if (m_state == Terminated) 473 if (m_state == Terminated)
471 return; 474 return;
472 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 475 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
473 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength; 476 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength;
474 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength); 477 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength);
475 m_resource->setResourceBuffer(dataOut); 478 m_resource->setResourceBuffer(dataOut);
476 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 479 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
477 } 480 }
478 481
479 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698