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

Side by Side Diff: third_party/WebKit/Source/platform/network/LinkHeader.h

Issue 1811163002: Share link header parsing code between blink and content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base-optional
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef LinkHeader_h 5 #ifndef LinkHeader_h
6 #define LinkHeader_h 6 #define LinkHeader_h
7 7
8 #include "core/CoreExport.h" 8 #include "platform/PlatformExport.h"
9 #include "core/html/CrossOriginAttribute.h"
10 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
11 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
12 11
13 namespace blink { 12 namespace blink {
14 13
15 class LinkHeader { 14 class LinkHeader {
16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 15 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
16
17 public: 17 public:
18 template <typename CharType> 18 template <typename Iterator>
19 LinkHeader(CharType*& position, CharType* end); 19 LinkHeader(Iterator begin, Iterator end);
20 20
21 const String& url() const { return m_url; } 21 const String& url() const { return m_url; }
22 const String& rel() const { return m_rel; } 22 const String& rel() const { return m_rel; }
23 const String& as() const { return m_as; } 23 const String& as() const { return m_as; }
24 const String& mimeType() const { return m_mimeType; } 24 const String& mimeType() const { return m_mimeType; }
25 const String& media() const { return m_media; } 25 const String& media() const { return m_media; }
26 CrossOriginAttributeValue crossOrigin() const { return m_crossOrigin; } 26 const String& crossOrigin() const { return m_crossOrigin; }
27 bool valid() const { return m_isValid; } 27 bool valid() const { return m_isValid; }
28 28
29 enum LinkParameterName { 29 enum LinkParameterName {
30 LinkParameterRel, 30 LinkParameterRel,
31 LinkParameterAnchor, 31 LinkParameterAnchor,
32 LinkParameterTitle, 32 LinkParameterTitle,
33 LinkParameterMedia, 33 LinkParameterMedia,
34 LinkParameterType, 34 LinkParameterType,
35 LinkParameterRev, 35 LinkParameterRev,
36 LinkParameterHreflang, 36 LinkParameterHreflang,
37 // Beyond this point, only link-extension parameters 37 // Beyond this point, only link-extension parameters
38 LinkParameterUnknown, 38 LinkParameterUnknown,
39 LinkParameterCrossOrigin, 39 LinkParameterCrossOrigin,
40 LinkParameterAs, 40 LinkParameterAs,
41 }; 41 };
42 42
43 private: 43 private:
44 void setValue(LinkParameterName, String value); 44 void setValue(LinkParameterName, String value);
45 45
46 String m_url; 46 String m_url;
47 String m_rel; 47 String m_rel;
48 String m_as; 48 String m_as;
49 String m_mimeType; 49 String m_mimeType;
50 String m_media; 50 String m_media;
51 CrossOriginAttributeValue m_crossOrigin; 51 String m_crossOrigin;
52 bool m_isValid; 52 bool m_isValid;
53 }; 53 };
54 54
55 class CORE_EXPORT LinkHeaderSet { 55 class PLATFORM_EXPORT LinkHeaderSet {
56 STACK_ALLOCATED(); 56 STACK_ALLOCATED();
57
57 public: 58 public:
58 LinkHeaderSet(const String& header); 59 LinkHeaderSet(const String& header);
59 60
60 Vector<LinkHeader>::const_iterator begin() const { return m_headerSet.begin( ); } 61 Vector<LinkHeader>::const_iterator begin() const { return m_headerSet.begin( ); }
61 Vector<LinkHeader>::const_iterator end() const { return m_headerSet.end(); } 62 Vector<LinkHeader>::const_iterator end() const { return m_headerSet.end(); }
62 LinkHeader& operator[](size_t i) { return m_headerSet[i]; } 63 LinkHeader& operator[](size_t i) { return m_headerSet[i]; }
63 size_t size() { return m_headerSet.size(); } 64 size_t size() { return m_headerSet.size(); }
64 65
65 private: 66 private:
66 template <typename CharType>
67 void init(CharType* headerValue, unsigned len);
68
69 Vector<LinkHeader> m_headerSet; 67 Vector<LinkHeader> m_headerSet;
70 }; 68 };
71 69
72 } // namespace blink 70 } // namespace blink
73 71
74 #endif 72 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698