OLD | NEW |
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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 } | 640 } |
641 | 641 |
642 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) | 642 void DocumentThreadableLoader::setSerializedCachedMetadata(Resource*, const char
* data, size_t size) |
643 { | 643 { |
644 if (!m_actualRequest.isNull()) | 644 if (!m_actualRequest.isNull()) |
645 return; | 645 return; |
646 m_client->didReceiveCachedMetadata(data, size); | 646 m_client->didReceiveCachedMetadata(data, size); |
647 // |this| may be dead here. | 647 // |this| may be dead here. |
648 } | 648 } |
649 | 649 |
650 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, unsigned dataLength) | 650 void DocumentThreadableLoader::dataReceived(Resource* resource, const char* data
, size_t dataLength) |
651 { | 651 { |
652 ASSERT_UNUSED(resource, resource == this->resource()); | 652 ASSERT_UNUSED(resource, resource == this->resource()); |
653 ASSERT(m_async); | 653 ASSERT(m_async); |
654 | 654 |
655 if (m_isUsingDataConsumerHandle) | 655 if (m_isUsingDataConsumerHandle) |
656 return; | 656 return; |
657 | 657 |
658 handleReceivedData(data, dataLength); | 658 // TODO(junov): Fix the ThreadableLoader ecosystem to use size_t. |
| 659 // Until then, we use safeCast to trap potential overflows. |
| 660 handleReceivedData(data, safeCast<unsigned>(dataLength)); |
659 // |this| may be dead here. | 661 // |this| may be dead here. |
660 } | 662 } |
661 | 663 |
662 void DocumentThreadableLoader::handleReceivedData(const char* data, unsigned dat
aLength) | 664 void DocumentThreadableLoader::handleReceivedData(const char* data, size_t dataL
ength) |
663 { | 665 { |
664 ASSERT(m_client); | 666 ASSERT(m_client); |
665 | 667 |
666 // Preflight data should be invisible to clients. | 668 // Preflight data should be invisible to clients. |
667 if (!m_actualRequest.isNull()) | 669 if (!m_actualRequest.isNull()) |
668 return; | 670 return; |
669 | 671 |
670 ASSERT(m_fallbackRequestForServiceWorker.isNull()); | 672 ASSERT(m_fallbackRequestForServiceWorker.isNull()); |
671 | 673 |
672 m_client->didReceiveData(data, dataLength); | 674 m_client->didReceiveData(data, dataLength); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); | 892 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); |
891 } | 893 } |
892 | 894 |
893 Document& DocumentThreadableLoader::document() const | 895 Document& DocumentThreadableLoader::document() const |
894 { | 896 { |
895 ASSERT(m_document); | 897 ASSERT(m_document); |
896 return *m_document; | 898 return *m_document; |
897 } | 899 } |
898 | 900 |
899 } // namespace blink | 901 } // namespace blink |
OLD | NEW |