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

Side by Side Diff: third_party/WebKit/Source/core/fetch/TextResource.cpp

Issue 1819593002: Preload scan external css for @import (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yoav review Created 4 years, 8 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
OLDNEW
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
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 size_t position = 0;
36 return streamDecodedText(&position);
37 }
38
39 String TextResource::streamDecodedText(size_t* position) const
40 {
41 ASSERT(position);
35 ASSERT(m_data); 42 ASSERT(m_data);
36 43
37 StringBuilder builder; 44 StringBuilder builder;
38 const char* data; 45 const char* data;
39 size_t position = 0; 46 while (size_t length = m_data->getSomeData(data, *position)) {
40 while (size_t length = m_data->getSomeData(data, position)) {
41 builder.append(m_decoder->decode(data, length)); 47 builder.append(m_decoder->decode(data, length));
42 position += length; 48 *position += length;
43 } 49 }
44 builder.append(m_decoder->flush()); 50 builder.append(m_decoder->flush());
51
45 return builder.toString(); 52 return builder.toString();
46 } 53 }
47 54
48 } // namespace blink 55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698