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

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

Issue 2510613002: Loading: move TextResource to core/loader/resource (Closed)
Patch Set: fix rebase error Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/fetch/TextResource.h"
6
7 #include "core/html/parser/TextResourceDecoder.h"
8 #include "platform/SharedBuffer.h"
9 #include "wtf/text/StringBuilder.h"
10
11 namespace blink {
12
13 TextResource::TextResource(const ResourceRequest& resourceRequest,
14 Resource::Type type,
15 const ResourceLoaderOptions& options,
16 const String& mimeType,
17 const String& charset)
18 : Resource(resourceRequest, type, options),
19 m_decoder(TextResourceDecoder::create(mimeType, charset)) {}
20
21 TextResource::~TextResource() {}
22
23 void TextResource::setEncoding(const String& chs) {
24 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
25 }
26
27 String TextResource::encoding() const {
28 return m_decoder->encoding().name();
29 }
30
31 String TextResource::decodedText() const {
32 DCHECK(data());
33
34 StringBuilder builder;
35 const char* segment;
36 size_t position = 0;
37 while (size_t length = data()->getSomeData(segment, position)) {
38 builder.append(m_decoder->decode(segment, length));
39 position += length;
40 }
41 builder.append(m_decoder->flush());
42 return builder.toString();
43 }
44
45 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/TextResource.h ('k') | third_party/WebKit/Source/core/loader/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698