OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/fetch/TextResource.h" | 5 #include "core/fetch/TextResource.h" |
6 | 6 |
7 #include "core/html/parser/TextResourceDecoder.h" | 7 #include "core/html/parser/TextResourceDecoder.h" |
8 #include "platform/SharedBuffer.h" | 8 #include "platform/SharedBuffer.h" |
9 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader); | 25 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader); |
26 } | 26 } |
27 | 27 |
28 String TextResource::encoding() const | 28 String TextResource::encoding() const |
29 { | 29 { |
30 return m_decoder->encoding().name(); | 30 return m_decoder->encoding().name(); |
31 } | 31 } |
32 | 32 |
33 String TextResource::decodedText() const | 33 String TextResource::decodedText() const |
34 { | 34 { |
35 ASSERT(m_data); | 35 DCHECK(data()); |
36 | 36 |
37 StringBuilder builder; | 37 StringBuilder builder; |
38 const char* data; | 38 const char* segment; |
39 size_t position = 0; | 39 size_t position = 0; |
40 while (size_t length = m_data->getSomeData(data, position)) { | 40 while (size_t length = data()->getSomeData(segment, position)) { |
41 builder.append(m_decoder->decode(data, length)); | 41 builder.append(m_decoder->decode(segment, length)); |
42 position += length; | 42 position += length; |
43 } | 43 } |
44 builder.append(m_decoder->flush()); | 44 builder.append(m_decoder->flush()); |
45 return builder.toString(); | 45 return builder.toString(); |
46 } | 46 } |
47 | 47 |
48 } // namespace blink | 48 } // namespace blink |
OLD | NEW |