OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url())); | 533 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url())); |
534 return; | 534 return; |
535 } | 535 } |
536 | 536 |
537 if (length) | 537 if (length) |
538 m_state = DataReceived; | 538 m_state = DataReceived; |
539 | 539 |
540 m_writer->addData(bytes, length); | 540 m_writer->addData(bytes, length); |
541 } | 541 } |
542 | 542 |
543 void DocumentLoader::dataReceived(Resource* resource, const char* data, unsigned
length) | 543 void DocumentLoader::dataReceived(Resource* resource, const char* data, size_t l
ength) |
544 { | 544 { |
545 ASSERT(data); | 545 ASSERT(data); |
546 ASSERT(length); | 546 ASSERT(length); |
547 ASSERT_UNUSED(resource, resource == m_mainResource); | 547 ASSERT_UNUSED(resource, resource == m_mainResource); |
548 ASSERT(!m_response.isNull()); | 548 ASSERT(!m_response.isNull()); |
549 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); | 549 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); |
550 | 550 |
551 if (m_inDataReceived) { | 551 if (m_inDataReceived) { |
552 // If this function is reentered, defer processing of the additional | 552 // If this function is reentered, defer processing of the additional |
553 // data to the top-level invocation. Reentrant calls can occur because | 553 // data to the top-level invocation. Reentrant calls can occur because |
(...skipping 11 matching lines...) Expand all Loading... |
565 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); | 565 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); |
566 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this); | 566 RefPtrWillBeRawPtr<DocumentLoader> protectLoader(this); |
567 | 567 |
568 TemporaryChange<bool> reentrancyProtector(m_inDataReceived, true); | 568 TemporaryChange<bool> reentrancyProtector(m_inDataReceived, true); |
569 processData(data, length); | 569 processData(data, length); |
570 | 570 |
571 // Process data received in reentrant invocations. Note that the | 571 // Process data received in reentrant invocations. Note that the |
572 // invocations of processData() may queue more data in reentrant | 572 // invocations of processData() may queue more data in reentrant |
573 // invocations, so iterate until it's empty. | 573 // invocations, so iterate until it's empty. |
574 const char* segment; | 574 const char* segment; |
575 unsigned pos = 0; | 575 size_t pos = 0; |
576 while (unsigned length = m_dataBuffer->getSomeData(segment, pos)) { | 576 while (size_t length = m_dataBuffer->getSomeData(segment, pos)) { |
577 processData(segment, length); | 577 processData(segment, length); |
578 pos += length; | 578 pos += length; |
579 } | 579 } |
580 // All data has been consumed, so flush the buffer. | 580 // All data has been consumed, so flush the buffer. |
581 m_dataBuffer->clear(); | 581 m_dataBuffer->clear(); |
582 } | 582 } |
583 | 583 |
584 void DocumentLoader::processData(const char* data, unsigned length) | 584 void DocumentLoader::processData(const char* data, size_t length) |
585 { | 585 { |
586 m_applicationCacheHost->mainResourceDataReceived(data, length); | 586 m_applicationCacheHost->mainResourceDataReceived(data, length); |
587 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 587 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
588 | 588 |
589 if (isArchiveMIMEType(response().mimeType())) | 589 if (isArchiveMIMEType(response().mimeType())) |
590 return; | 590 return; |
591 commitIfReady(); | 591 commitIfReady(); |
592 if (!frameLoader()) | 592 if (!frameLoader()) |
593 return; | 593 return; |
594 commitData(data, length); | 594 commitData(data, length); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 { | 844 { |
845 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true, ForceSynchronousParsing); | 845 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true, ForceSynchronousParsing); |
846 if (!source.isNull()) | 846 if (!source.isNull()) |
847 m_writer->appendReplacingData(source); | 847 m_writer->appendReplacingData(source); |
848 endWriting(m_writer.get()); | 848 endWriting(m_writer.get()); |
849 } | 849 } |
850 | 850 |
851 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 851 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
852 | 852 |
853 } // namespace blink | 853 } // namespace blink |
OLD | NEW |