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

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

Issue 1729963002: WIP/proof-of-concept to make blink::LinkHeader reuse net:: parsing code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string-tokenizer-brackets
Patch Set: Created 4 years, 9 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
12 #include <string>
13
13 namespace blink { 14 namespace blink {
14 15
15 class LinkHeader { 16 class LinkHeader {
16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 17 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
17 public: 18 public:
18 template <typename CharType> 19 LinkHeader(std::string::const_iterator begin, std::string::const_iterator en d);
19 LinkHeader(CharType*& position, CharType* 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 CrossOriginAttributeValue crossOrigin() const { return m_crossOrigin; } 24 const String& crossOrigin() const { return m_crossOrigin; }
25 bool valid() const { return m_isValid; } 25 bool valid() const { return m_isValid; }
26 26
27 enum LinkParameterName { 27 enum LinkParameterName {
28 LinkParameterRel, 28 LinkParameterRel,
29 LinkParameterAnchor, 29 LinkParameterAnchor,
30 LinkParameterTitle, 30 LinkParameterTitle,
31 LinkParameterMedia, 31 LinkParameterMedia,
32 LinkParameterType, 32 LinkParameterType,
33 LinkParameterRev, 33 LinkParameterRev,
34 LinkParameterHreflang, 34 LinkParameterHreflang,
35 // Beyond this point, only link-extension parameters 35 // Beyond this point, only link-extension parameters
36 LinkParameterUnknown, 36 LinkParameterUnknown,
37 LinkParameterCrossOrigin, 37 LinkParameterCrossOrigin,
38 LinkParameterAs, 38 LinkParameterAs,
39 }; 39 };
40 40
41 private: 41 private:
42 void setValue(LinkParameterName, String value); 42 void setValue(LinkParameterName, String value);
43 43
44 String m_url; 44 String m_url;
45 String m_rel; 45 String m_rel;
46 String m_as; 46 String m_as;
47 CrossOriginAttributeValue m_crossOrigin; 47 String m_crossOrigin;
48 bool m_isValid; 48 bool m_isValid;
49 }; 49 };
50 50
51 class CORE_EXPORT LinkHeaderSet { 51 class PLATFORM_EXPORT LinkHeaderSet {
52 STACK_ALLOCATED(); 52 STACK_ALLOCATED();
53 public: 53 public:
54 LinkHeaderSet(const String& header); 54 LinkHeaderSet(const String& header);
55 55
56 Vector<LinkHeader>::const_iterator begin() const { return m_headerSet.begin( ); } 56 Vector<LinkHeader>::const_iterator begin() const { return m_headerSet.begin( ); }
57 Vector<LinkHeader>::const_iterator end() const { return m_headerSet.end(); } 57 Vector<LinkHeader>::const_iterator end() const { return m_headerSet.end(); }
58 LinkHeader& operator[](size_t i) { return m_headerSet[i]; } 58 LinkHeader& operator[](size_t i) { return m_headerSet[i]; }
59 size_t size() { return m_headerSet.size(); } 59 size_t size() { return m_headerSet.size(); }
60 60
61 private: 61 private:
62 template <typename CharType>
63 void init(CharType* headerValue, unsigned len);
64
65 Vector<LinkHeader> m_headerSet; 62 Vector<LinkHeader> m_headerSet;
66 }; 63 };
67 64
68 } // namespace blink 65 } // namespace blink
69 66
70 #endif 67 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/DEPS ('k') | third_party/WebKit/Source/platform/network/LinkHeader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698