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

Side by Side Diff: Source/core/fetch/DocumentResource.cpp

Issue 1167583003: Move Resource subclasses out of fetch/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/DocumentResource.h ('k') | Source/core/fetch/DocumentResourceReference.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com>
3 Copyright (C) 2011 Cosmin Truta <ctruta@gmail.com>
4 Copyright (C) 2012 University of Szeged
5 Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21 */
22
23 #include "config.h"
24
25 #include "core/fetch/DocumentResource.h"
26
27 #include "core/dom/XMLDocument.h"
28 #include "core/fetch/FetchRequest.h"
29 #include "core/fetch/ResourceFetcher.h"
30 #include "platform/SharedBuffer.h"
31 #include "wtf/text/StringBuilder.h"
32
33 namespace blink {
34
35 ResourcePtr<DocumentResource> DocumentResource::fetchSVGDocument(FetchRequest& r equest, ResourceFetcher* fetcher)
36 {
37 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
38 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textImage);
39 return toDocumentResource(fetcher->requestResource(request, SVGDocumentResou rceFactory()));
40 }
41
42 DocumentResource::DocumentResource(const ResourceRequest& request, Type type)
43 : Resource(request, type)
44 , m_decoder(TextResourceDecoder::create("application/xml"))
45 {
46 // FIXME: We'll support more types to support HTMLImports.
47 ASSERT(type == SVGDocument);
48 }
49
50 DocumentResource::~DocumentResource()
51 {
52 }
53
54 DEFINE_TRACE(DocumentResource)
55 {
56 visitor->trace(m_document);
57 Resource::trace(visitor);
58 }
59
60 void DocumentResource::setEncoding(const String& chs)
61 {
62 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
63 }
64
65 String DocumentResource::encoding() const
66 {
67 return m_decoder->encoding().name();
68 }
69
70 void DocumentResource::checkNotify()
71 {
72 if (m_data) {
73 StringBuilder decodedText;
74 decodedText.append(m_decoder->decode(m_data->data(), m_data->size()));
75 decodedText.append(m_decoder->flush());
76 // We don't need to create a new frame because the new document belongs to the parent UseElement.
77 m_document = createDocument(response().url());
78 m_document->setContent(decodedText.toString());
79 }
80 Resource::checkNotify();
81 }
82
83 PassRefPtrWillBeRawPtr<Document> DocumentResource::createDocument(const KURL& ur l)
84 {
85 switch (type()) {
86 case SVGDocument:
87 return XMLDocument::createSVG(DocumentInit(url));
88 default:
89 // FIXME: We'll add more types to support HTMLImports.
90 ASSERT_NOT_REACHED();
91 return nullptr;
92 }
93 }
94
95 }
OLDNEW
« no previous file with comments | « Source/core/fetch/DocumentResource.h ('k') | Source/core/fetch/DocumentResourceReference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698