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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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
OLDNEW
1 /* 1 /*
2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 3 Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
4 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 4 Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. 19 Boston, MA 02110-1301, USA.
20 20
21 */ 21 */
22 22
23 #ifndef TextResourceDecoder_h 23 #ifndef TextResourceDecoder_h
24 #define TextResourceDecoder_h 24 #define TextResourceDecoder_h
25 25
26 #include "core/CoreExport.h" 26 #include "core/CoreExport.h"
27 #include "wtf/PtrUtil.h"
27 #include "wtf/text/TextEncoding.h" 28 #include "wtf/text/TextEncoding.h"
29 #include <memory>
28 30
29 namespace blink { 31 namespace blink {
30 32
31 class HTMLMetaCharsetParser; 33 class HTMLMetaCharsetParser;
32 34
33 class CORE_EXPORT TextResourceDecoder { 35 class CORE_EXPORT TextResourceDecoder {
34 USING_FAST_MALLOC(TextResourceDecoder); 36 USING_FAST_MALLOC(TextResourceDecoder);
35 WTF_MAKE_NONCOPYABLE(TextResourceDecoder); 37 WTF_MAKE_NONCOPYABLE(TextResourceDecoder);
36 public: 38 public:
37 enum EncodingSource { 39 enum EncodingSource {
38 DefaultEncoding, 40 DefaultEncoding,
39 AutoDetectedEncoding, 41 AutoDetectedEncoding,
40 EncodingFromContentSniffing, 42 EncodingFromContentSniffing,
41 EncodingFromXMLHeader, 43 EncodingFromXMLHeader,
42 EncodingFromMetaTag, 44 EncodingFromMetaTag,
43 EncodingFromCSSCharset, 45 EncodingFromCSSCharset,
44 EncodingFromHTTPHeader, 46 EncodingFromHTTPHeader,
45 EncodingFromParentFrame 47 EncodingFromParentFrame
46 }; 48 };
47 49
48 static PassOwnPtr<TextResourceDecoder> create(const String& mimeType, const WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncodingDetec tor = false) 50 static std::unique_ptr<TextResourceDecoder> create(const String& mimeType, c onst WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncoding Detector = false)
49 { 51 {
50 return adoptPtr(new TextResourceDecoder(mimeType, defaultEncoding, usesE ncodingDetector ? UseAllAutoDetection : UseContentAndBOMBasedDetection)); 52 return wrapUnique(new TextResourceDecoder(mimeType, defaultEncoding, use sEncodingDetector ? UseAllAutoDetection : UseContentAndBOMBasedDetection));
51 } 53 }
52 // Corresponds to utf-8 decode in Encoding spec: 54 // Corresponds to utf-8 decode in Encoding spec:
53 // https://encoding.spec.whatwg.org/#utf-8-decode. 55 // https://encoding.spec.whatwg.org/#utf-8-decode.
54 static PassOwnPtr<TextResourceDecoder> createAlwaysUseUTF8ForText() 56 static std::unique_ptr<TextResourceDecoder> createAlwaysUseUTF8ForText()
55 { 57 {
56 return adoptPtr(new TextResourceDecoder("plain/text", UTF8Encoding(), Al waysUseUTF8ForText)); 58 return wrapUnique(new TextResourceDecoder("plain/text", UTF8Encoding(), AlwaysUseUTF8ForText));
57 } 59 }
58 ~TextResourceDecoder(); 60 ~TextResourceDecoder();
59 61
60 void setEncoding(const WTF::TextEncoding&, EncodingSource); 62 void setEncoding(const WTF::TextEncoding&, EncodingSource);
61 const WTF::TextEncoding& encoding() const { return m_encoding; } 63 const WTF::TextEncoding& encoding() const { return m_encoding; }
62 bool encodingWasDetectedHeuristically() const 64 bool encodingWasDetectedHeuristically() const
63 { 65 {
64 return m_source == AutoDetectedEncoding 66 return m_source == AutoDetectedEncoding
65 || m_source == EncodingFromContentSniffing; 67 || m_source == EncodingFromContentSniffing;
66 } 68 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 static ContentType determineContentType(const String& mimeType); 107 static ContentType determineContentType(const String& mimeType);
106 static const WTF::TextEncoding& defaultEncoding(ContentType, const WTF::Text Encoding& defaultEncoding); 108 static const WTF::TextEncoding& defaultEncoding(ContentType, const WTF::Text Encoding& defaultEncoding);
107 109
108 bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer); 110 bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer);
109 bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer); 111 bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer);
110 void checkForMetaCharset(const char*, size_t); 112 void checkForMetaCharset(const char*, size_t);
111 bool shouldAutoDetect() const; 113 bool shouldAutoDetect() const;
112 114
113 ContentType m_contentType; 115 ContentType m_contentType;
114 WTF::TextEncoding m_encoding; 116 WTF::TextEncoding m_encoding;
115 OwnPtr<TextCodec> m_codec; 117 std::unique_ptr<TextCodec> m_codec;
116 EncodingSource m_source; 118 EncodingSource m_source;
117 const char* m_hintEncoding; 119 const char* m_hintEncoding;
118 Vector<char> m_buffer; 120 Vector<char> m_buffer;
119 bool m_checkedForBOM; 121 bool m_checkedForBOM;
120 bool m_checkedForCSSCharset; 122 bool m_checkedForCSSCharset;
121 bool m_checkedForXMLCharset; 123 bool m_checkedForXMLCharset;
122 bool m_checkedForMetaCharset; 124 bool m_checkedForMetaCharset;
123 bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors. 125 bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors.
124 bool m_sawError; 126 bool m_sawError;
125 EncodingDetectionOption m_encodingDetectionOption; 127 EncodingDetectionOption m_encodingDetectionOption;
126 128
127 OwnPtr<HTMLMetaCharsetParser> m_charsetParser; 129 std::unique_ptr<HTMLMetaCharsetParser> m_charsetParser;
128 }; 130 };
129 131
130 } // namespace blink 132 } // namespace blink
131 133
132 #endif 134 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698