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

Side by Side Diff: Source/core/loader/DocumentWriter.cpp

Issue 74493002: Removed refcounting from TextResourceDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step2
Patch Set: Compile fix Created 7 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2010. Adam Barth. All rights reserved. 2 * Copyright (C) 2010. Adam Barth. 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // passing ownership of the source string. 79 // passing ownership of the source string.
80 parser->append(source.impl()); 80 parser->append(source.impl());
81 parser->setHasAppendedData(); 81 parser->setHasAppendedData();
82 } 82 }
83 } 83 }
84 84
85 void DocumentWriter::addData(const char* bytes, size_t length) 85 void DocumentWriter::addData(const char* bytes, size_t length)
86 { 86 {
87 ASSERT(m_parser); 87 ASSERT(m_parser);
88 if (m_parser->needsDecoder() && 0 < length) { 88 if (m_parser->needsDecoder() && 0 < length) {
89 RefPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt); 89 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt);
90 m_parser->setDecoder(decoder); 90 m_parser->setDecoder(decoder.release());
91 } 91 }
92 // appendBytes() can result replacing DocumentLoader::m_writer. 92 // appendBytes() can result replacing DocumentLoader::m_writer.
93 RefPtr<DocumentWriter> protectingThis(this); 93 RefPtr<DocumentWriter> protectingThis(this);
94 m_parser->appendBytes(bytes, length); 94 m_parser->appendBytes(bytes, length);
95 } 95 }
96 96
97 void DocumentWriter::end() 97 void DocumentWriter::end()
98 { 98 {
99 ASSERT(m_document); 99 ASSERT(m_document);
100 100
101 // http://bugs.webkit.org/show_bug.cgi?id=10854 101 // http://bugs.webkit.org/show_bug.cgi?id=10854
102 // The frame's last ref may be removed and it can be deleted by checkComplet ed(), 102 // The frame's last ref may be removed and it can be deleted by checkComplet ed(),
103 // so we'll add a protective refcount 103 // so we'll add a protective refcount
104 RefPtr<Frame> protector(m_document->frame()); 104 RefPtr<Frame> protector(m_document->frame());
105 105
106 if (!m_parser) 106 if (!m_parser)
107 return; 107 return;
108 108
109 if (m_parser->needsDecoder()) { 109 if (m_parser->needsDecoder()) {
110 RefPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt); 110 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt);
111 m_parser->setDecoder(decoder); 111 m_parser->setDecoder(decoder.release());
112 } 112 }
113 // flush() can result replacing DocumentLoader::m_writer. 113 // flush() can result replacing DocumentLoader::m_writer.
114 RefPtr<DocumentWriter> protectingThis(this); 114 RefPtr<DocumentWriter> protectingThis(this);
115 m_parser->flush(); 115 m_parser->flush();
116 116
117 if (!m_parser) 117 if (!m_parser)
118 return; 118 return;
119 119
120 m_parser->finish(); 120 m_parser->finish();
121 m_parser = 0; 121 m_parser = 0;
122 m_document = 0; 122 m_document = 0;
123 } 123 }
124 124
125 void DocumentWriter::setUserChosenEncoding(const String& charset) 125 void DocumentWriter::setUserChosenEncoding(const String& charset)
126 { 126 {
127 RefPtr<TextResourceDecoder> decoder = m_parser->decoder(); 127 TextResourceDecoder* decoder = m_parser->decoder();
128 if (decoder) 128 if (decoder)
129 decoder->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); 129 decoder->setEncoding(charset, TextResourceDecoder::UserChosenEncoding);
130 } 130 }
131 131
132 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() 132 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation()
133 { 133 {
134 ASSERT(m_parser && !m_parser->isStopped()); 134 ASSERT(m_parser && !m_parser->isStopped());
135 m_parser->setDocumentWasLoadedAsPartOfNavigation(); 135 m_parser->setDocumentWasLoadedAsPartOfNavigation();
136 } 136 }
137 137
138 } // namespace WebCore 138 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/NetworkResourcesData.cpp ('k') | Source/core/loader/TextResourceDecoderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698