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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "modules/fetch/FetchHeaderList.h" 5 #include "modules/fetch/FetchHeaderList.h"
6 6
7 #include "core/fetch/FetchUtils.h" 7 #include "core/fetch/FetchUtils.h"
8 #include "platform/network/HTTPParsers.h" 8 #include "platform/network/HTTPParsers.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PassOwnPtr.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 FetchHeaderList* FetchHeaderList::create() 13 FetchHeaderList* FetchHeaderList::create()
14 { 14 {
15 return new FetchHeaderList(); 15 return new FetchHeaderList();
16 } 16 }
17 17
18 FetchHeaderList* FetchHeaderList::clone() 18 FetchHeaderList* FetchHeaderList::clone()
19 { 19 {
20 FetchHeaderList* list = create(); 20 FetchHeaderList* list = create();
21 for (size_t i = 0; i < m_headerList.size(); ++i) 21 for (size_t i = 0; i < m_headerList.size(); ++i)
22 list->append(m_headerList[i]->first, m_headerList[i]->second); 22 list->append(m_headerList[i]->first, m_headerList[i]->second);
23 return list; 23 return list;
24 } 24 }
25 25
26 FetchHeaderList::FetchHeaderList() 26 FetchHeaderList::FetchHeaderList()
27 { 27 {
28 } 28 }
29 29
30 FetchHeaderList::~FetchHeaderList() 30 FetchHeaderList::~FetchHeaderList()
31 { 31 {
32 } 32 }
33 33
34 void FetchHeaderList::append(const String& name, const String& value) 34 void FetchHeaderList::append(const String& name, const String& value)
35 { 35 {
36 // "To append a name/value (|name|/|value|) pair to a header list (|list|), 36 // "To append a name/value (|name|/|value|) pair to a header list (|list|),
37 // append a new header whose name is |name|, byte lowercased, and value is 37 // append a new header whose name is |name|, byte lowercased, and value is
38 // |value|, to |list|." 38 // |value|, to |list|."
39 m_headerList.append(wrapUnique(new Header(name.lower(), value))); 39 m_headerList.append(adoptPtr(new Header(name.lower(), value)));
40 } 40 }
41 41
42 void FetchHeaderList::set(const String& name, const String& value) 42 void FetchHeaderList::set(const String& name, const String& value)
43 { 43 {
44 // "To set a name/value (|name|/|value|) pair in a header list (|list|), run 44 // "To set a name/value (|name|/|value|) pair in a header list (|list|), run
45 // these steps: 45 // these steps:
46 // 1. Byte lowercase |name|. 46 // 1. Byte lowercase |name|.
47 // 2. If there are any headers in |list| whose name is |name|, set the value 47 // 2. If there are any headers in |list| whose name is |name|, set the value
48 // of the first such header to |value| and remove the others. 48 // of the first such header to |value| and remove the others.
49 // 3. Otherwise, append a new header whose name is |name| and value is 49 // 3. Otherwise, append a new header whose name is |name| and value is
50 // |value|, to |list|." 50 // |value|, to |list|."
51 const String lowercasedName = name.lower(); 51 const String lowercasedName = name.lower();
52 for (size_t i = 0; i < m_headerList.size(); ++i) { 52 for (size_t i = 0; i < m_headerList.size(); ++i) {
53 if (m_headerList[i]->first == lowercasedName) { 53 if (m_headerList[i]->first == lowercasedName) {
54 m_headerList[i]->second = value; 54 m_headerList[i]->second = value;
55 for (size_t j = i + 1; j < m_headerList.size(); ) { 55 for (size_t j = i + 1; j < m_headerList.size(); ) {
56 if (m_headerList[j]->first == lowercasedName) 56 if (m_headerList[j]->first == lowercasedName)
57 m_headerList.remove(j); 57 m_headerList.remove(j);
58 else 58 else
59 ++j; 59 ++j;
60 } 60 }
61 return; 61 return;
62 } 62 }
63 } 63 }
64 m_headerList.append(wrapUnique(new Header(lowercasedName, value))); 64 m_headerList.append(adoptPtr(new Header(lowercasedName, value)));
65 } 65 }
66 66
67 String FetchHeaderList::extractMIMEType() const 67 String FetchHeaderList::extractMIMEType() const
68 { 68 {
69 // To extract a MIME type from a header list (headers), run these steps: 69 // To extract a MIME type from a header list (headers), run these steps:
70 // 1. Let MIMEType be the result of parsing `Content-Type` in headers. 70 // 1. Let MIMEType be the result of parsing `Content-Type` in headers.
71 String mimeType; 71 String mimeType;
72 if (!get("Content-Type", mimeType)) { 72 if (!get("Content-Type", mimeType)) {
73 // 2. If MIMEType is null or failure, return the empty byte sequence. 73 // 2. If MIMEType is null or failure, return the empty byte sequence.
74 return String(); 74 return String();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 bool FetchHeaderList::isValidHeaderValue(const String& value) 151 bool FetchHeaderList::isValidHeaderValue(const String& value)
152 { 152 {
153 // "A value is a byte sequence that matches the field-value token production 153 // "A value is a byte sequence that matches the field-value token production
154 // and contains no 0x0A or 0x0D bytes." 154 // and contains no 0x0A or 0x0D bytes."
155 return isValidHTTPHeaderValue(value); 155 return isValidHTTPHeaderValue(value);
156 } 156 }
157 157
158 } // namespace blink 158 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchHeaderList.h ('k') | third_party/WebKit/Source/modules/fetch/FetchManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698