OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "core/dom/DecodedDataDocumentParser.h" | 26 #include "core/dom/DecodedDataDocumentParser.h" |
27 | 27 |
28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
29 #include "core/dom/DocumentEncodingData.h" | 29 #include "core/dom/DocumentEncodingData.h" |
30 #include "core/html/parser/TextResourceDecoder.h" | 30 #include "core/html/parser/TextResourceDecoder.h" |
| 31 #include <memory> |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 DecodedDataDocumentParser::DecodedDataDocumentParser(Document& document) | 35 DecodedDataDocumentParser::DecodedDataDocumentParser(Document& document) |
35 : DocumentParser(&document) | 36 : DocumentParser(&document) |
36 , m_needsDecoder(true) | 37 , m_needsDecoder(true) |
37 { | 38 { |
38 } | 39 } |
39 | 40 |
40 DecodedDataDocumentParser::~DecodedDataDocumentParser() | 41 DecodedDataDocumentParser::~DecodedDataDocumentParser() |
41 { | 42 { |
42 } | 43 } |
43 | 44 |
44 void DecodedDataDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decod
er) | 45 void DecodedDataDocumentParser::setDecoder(std::unique_ptr<TextResourceDecoder>
decoder) |
45 { | 46 { |
46 // If the decoder is explicitly unset rather than having ownership | 47 // If the decoder is explicitly unset rather than having ownership |
47 // transferred away by takeDecoder(), we need to make sure it's recreated | 48 // transferred away by takeDecoder(), we need to make sure it's recreated |
48 // next time data is appended. | 49 // next time data is appended. |
49 m_needsDecoder = !decoder; | 50 m_needsDecoder = !decoder; |
50 m_decoder = std::move(decoder); | 51 m_decoder = std::move(decoder); |
51 } | 52 } |
52 | 53 |
53 TextResourceDecoder* DecodedDataDocumentParser::decoder() | 54 TextResourceDecoder* DecodedDataDocumentParser::decoder() |
54 { | 55 { |
55 return m_decoder.get(); | 56 return m_decoder.get(); |
56 } | 57 } |
57 | 58 |
58 PassOwnPtr<TextResourceDecoder> DecodedDataDocumentParser::takeDecoder() | 59 std::unique_ptr<TextResourceDecoder> DecodedDataDocumentParser::takeDecoder() |
59 { | 60 { |
60 return std::move(m_decoder); | 61 return std::move(m_decoder); |
61 } | 62 } |
62 | 63 |
63 void DecodedDataDocumentParser::appendBytes(const char* data, size_t length) | 64 void DecodedDataDocumentParser::appendBytes(const char* data, size_t length) |
64 { | 65 { |
65 if (!length) | 66 if (!length) |
66 return; | 67 return; |
67 | 68 |
68 // This should be checking isStopped(), but XMLDocumentParser prematurely | 69 // This should be checking isStopped(), but XMLDocumentParser prematurely |
(...skipping 25 matching lines...) Expand all Loading... |
94 | 95 |
95 void DecodedDataDocumentParser::updateDocument(String& decodedData) | 96 void DecodedDataDocumentParser::updateDocument(String& decodedData) |
96 { | 97 { |
97 document()->setEncodingData(DocumentEncodingData(*m_decoder.get())); | 98 document()->setEncodingData(DocumentEncodingData(*m_decoder.get())); |
98 | 99 |
99 if (!decodedData.isEmpty()) | 100 if (!decodedData.isEmpty()) |
100 append(decodedData); | 101 append(decodedData); |
101 } | 102 } |
102 | 103 |
103 } // namespace blink | 104 } // namespace blink |
OLD | NEW |