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

Side by Side Diff: Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 1161323007: Use nullptr instead of 0 in xml and xmlhttprequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comment & modified in other files which assigned "0" to ptr. Created 5 years, 6 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/xml/XSLTUnicodeSort.cpp ('k') | no next file » | 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) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
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 Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // FIXME: Set Last-Modified. 429 // FIXME: Set Last-Modified.
430 m_responseDocument->setSecurityOrigin(securityOrigin()); 430 m_responseDocument->setSecurityOrigin(securityOrigin());
431 m_responseDocument->setContextFeatures(document()->contextFeatures()); 431 m_responseDocument->setContextFeatures(document()->contextFeatures());
432 m_responseDocument->setMimeType(finalResponseMIMETypeWithFallback()); 432 m_responseDocument->setMimeType(finalResponseMIMETypeWithFallback());
433 } 433 }
434 434
435 Document* XMLHttpRequest::responseXML(ExceptionState& exceptionState) 435 Document* XMLHttpRequest::responseXML(ExceptionState& exceptionState)
436 { 436 {
437 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo nseTypeDocument) { 437 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo nseTypeDocument) {
438 exceptionState.throwDOMException(InvalidStateError, "The value is only a ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT ype() + "')."); 438 exceptionState.throwDOMException(InvalidStateError, "The value is only a ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT ype() + "').");
439 return 0; 439 return nullptr;
440 } 440 }
441 441
442 if (m_error || m_state != DONE) 442 if (m_error || m_state != DONE)
443 return 0; 443 return nullptr;
444 444
445 if (!m_parsedResponse) { 445 if (!m_parsedResponse) {
446 initResponseDocument(); 446 initResponseDocument();
447 if (!m_responseDocument) 447 if (!m_responseDocument)
448 return nullptr; 448 return nullptr;
449 449
450 m_responseDocument->setContent(m_responseText.flattenToString()); 450 m_responseDocument->setContent(m_responseText.flattenToString());
451 if (!m_responseDocument->wellFormed()) 451 if (!m_responseDocument->wellFormed())
452 m_responseDocument = nullptr; 452 m_responseDocument = nullptr;
453 453
454 m_parsedResponse = true; 454 m_parsedResponse = true;
455 } 455 }
456 456
457 return m_responseDocument.get(); 457 return m_responseDocument.get();
458 } 458 }
459 459
460 Blob* XMLHttpRequest::responseBlob() 460 Blob* XMLHttpRequest::responseBlob()
461 { 461 {
462 ASSERT(m_responseTypeCode == ResponseTypeBlob); 462 ASSERT(m_responseTypeCode == ResponseTypeBlob);
463 463
464 // We always return null before DONE. 464 // We always return null before DONE.
465 if (m_error || m_state != DONE) 465 if (m_error || m_state != DONE)
466 return 0; 466 return nullptr;
467 467
468 if (!m_responseBlob) { 468 if (!m_responseBlob) {
469 if (m_downloadingToFile) { 469 if (m_downloadingToFile) {
470 ASSERT(!m_binaryResponseBuilder); 470 ASSERT(!m_binaryResponseBuilder);
471 471
472 // When responseType is set to "blob", we redirect the downloaded 472 // When responseType is set to "blob", we redirect the downloaded
473 // data to a file-handle directly in the browser process. We get 473 // data to a file-handle directly in the browser process. We get
474 // the file-path from the ResourceResponse directly instead of 474 // the file-path from the ResourceResponse directly instead of
475 // copying the bytes between the browser and the renderer. 475 // copying the bytes between the browser and the renderer.
476 m_responseBlob = Blob::create(createBlobDataHandleFromResponse()); 476 m_responseBlob = Blob::create(createBlobDataHandleFromResponse());
477 } else { 477 } else {
478 OwnPtr<BlobData> blobData = BlobData::create(); 478 OwnPtr<BlobData> blobData = BlobData::create();
479 size_t size = 0; 479 size_t size = 0;
480 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { 480 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) {
481 size = m_binaryResponseBuilder->size(); 481 size = m_binaryResponseBuilder->size();
482 blobData->appendBytes(m_binaryResponseBuilder->data(), size); 482 blobData->appendBytes(m_binaryResponseBuilder->data(), size);
483 blobData->setContentType(finalResponseMIMETypeWithFallback().low er()); 483 blobData->setContentType(finalResponseMIMETypeWithFallback().low er());
484 m_binaryResponseBuilder.clear(); 484 m_binaryResponseBuilder.clear();
485 } 485 }
486 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas e(), size)); 486 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas e(), size));
487 } 487 }
488 } 488 }
489 489
490 return m_responseBlob.get(); 490 return m_responseBlob;
491 } 491 }
492 492
493 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() 493 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer()
494 { 494 {
495 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer); 495 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer);
496 496
497 if (m_error || m_state != DONE) 497 if (m_error || m_state != DONE)
498 return 0; 498 return nullptr;
499 499
500 if (!m_responseArrayBuffer) { 500 if (!m_responseArrayBuffer) {
501 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { 501 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) {
502 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitialized( m_binaryResponseBuilder->size(), 1); 502 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitialized( m_binaryResponseBuilder->size(), 1);
503 if (!m_binaryResponseBuilder->getAsBytes(buffer->data(), buffer->byt eLength())) { 503 if (!m_binaryResponseBuilder->getAsBytes(buffer->data(), buffer->byt eLength())) {
504 // m_binaryResponseBuilder failed to allocate an ArrayBuffer. 504 // m_binaryResponseBuilder failed to allocate an ArrayBuffer.
505 // We need to crash the renderer since there's no way defined in 505 // We need to crash the renderer since there's no way defined in
506 // the spec to tell this to the user. 506 // the spec to tell this to the user.
507 CRASH(); 507 CRASH();
508 } 508 }
509 m_responseArrayBuffer = buffer.release(); 509 m_responseArrayBuffer = buffer.release();
510 m_binaryResponseBuilder.clear(); 510 m_binaryResponseBuilder.clear();
511 } else { 511 } else {
512 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); 512 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0);
513 } 513 }
514 } 514 }
515 515
516 return m_responseArrayBuffer.get(); 516 return m_responseArrayBuffer.get();
517 } 517 }
518 518
519 Stream* XMLHttpRequest::responseLegacyStream() 519 Stream* XMLHttpRequest::responseLegacyStream()
520 { 520 {
521 ASSERT(m_responseTypeCode == ResponseTypeLegacyStream); 521 ASSERT(m_responseTypeCode == ResponseTypeLegacyStream);
522 522
523 if (m_error || (m_state != LOADING && m_state != DONE)) 523 if (m_error || (m_state != LOADING && m_state != DONE))
524 return 0; 524 return nullptr;
525 525
526 return m_responseLegacyStream.get(); 526 return m_responseLegacyStream;
527 } 527 }
528 528
529 ReadableStream* XMLHttpRequest::responseStream() 529 ReadableStream* XMLHttpRequest::responseStream()
530 { 530 {
531 ASSERT(m_responseTypeCode == ResponseTypeStream); 531 ASSERT(m_responseTypeCode == ResponseTypeStream);
532 if (m_error || (m_state != LOADING && m_state != DONE)) 532 if (m_error || (m_state != LOADING && m_state != DONE))
533 return 0; 533 return nullptr;
534 534
535 return m_responseStream; 535 return m_responseStream;
536 } 536 }
537 537
538 void XMLHttpRequest::setTimeout(unsigned timeout, ExceptionState& exceptionState ) 538 void XMLHttpRequest::setTimeout(unsigned timeout, ExceptionState& exceptionState )
539 { 539 {
540 // FIXME: Need to trigger or update the timeout Timer here, if needed. http: //webkit.org/b/98156 540 // FIXME: Need to trigger or update the timeout Timer here, if needed. http: //webkit.org/b/98156
541 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set whi le fetching is in progress. If that occurs it will still be measured relative to the start of fetching." 541 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set whi le fetching is in progress. If that occurs it will still be measured relative to the start of fetching."
542 if (executionContext()->isDocument() && !m_async) { 542 if (executionContext()->isDocument() && !m_async) {
543 exceptionState.throwDOMException(InvalidAccessError, "Timeouts cannot be set for synchronous requests made from a document."); 543 exceptionState.throwDOMException(InvalidAccessError, "Timeouts cannot be set for synchronous requests made from a document.");
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 visitor->trace(m_responseDocumentParser); 1864 visitor->trace(m_responseDocumentParser);
1865 visitor->trace(m_progressEventThrottle); 1865 visitor->trace(m_progressEventThrottle);
1866 visitor->trace(m_upload); 1866 visitor->trace(m_upload);
1867 visitor->trace(m_blobLoader); 1867 visitor->trace(m_blobLoader);
1868 XMLHttpRequestEventTarget::trace(visitor); 1868 XMLHttpRequestEventTarget::trace(visitor);
1869 DocumentParserClient::trace(visitor); 1869 DocumentParserClient::trace(visitor);
1870 ActiveDOMObject::trace(visitor); 1870 ActiveDOMObject::trace(visitor);
1871 } 1871 }
1872 1872
1873 } // namespace blink 1873 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xml/XSLTUnicodeSort.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698