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

Side by Side Diff: third_party/WebKit/Source/wtf/text/Base64.cpp

Issue 2373983006: reflow comments in wtf/text (Closed)
Patch Set: Created 4 years, 2 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) 2000-2001 Dawit Alemayehu <adawit@kde.org> 2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
3 Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 3 Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
4 Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 4 Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
5 Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 5 Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License (LGPL) 8 it under the terms of the GNU Lesser General Public License (LGPL)
9 version 2 as published by the Free Software Foundation. 9 version 2 as published by the Free Software Foundation.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program 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 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public 16 You should have received a copy of the GNU Library General Public
17 License along with this program; if not, write to the Free Software 17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US A. 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 USA.
19 20
20 This code is based on the java implementation in HTTPClient 21 This code is based on the java implementation in HTTPClient
21 package by Ronald Tschalaer Copyright (C) 1996-1999. 22 package by Ronald Tschalaer Copyright (C) 1996-1999.
22 */ 23 */
23 24
24 #include "wtf/text/Base64.h" 25 #include "wtf/text/Base64.h"
25 26
26 #include "wtf/StringExtras.h" 27 #include "wtf/StringExtras.h"
27 #include <limits.h> 28 #include <limits.h>
28 29
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (outLength < out.size()) 179 if (outLength < out.size())
179 out.shrink(outLength); 180 out.shrink(outLength);
180 181
181 if (hadError) 182 if (hadError)
182 return false; 183 return false;
183 184
184 if (!outLength) 185 if (!outLength)
185 return !equalsSignCount; 186 return !equalsSignCount;
186 187
187 // There should be no padding if length is a multiple of 4. 188 // There should be no padding if length is a multiple of 4.
188 // We use (outLength + equalsSignCount) instead of length because we don't wan t to account for ignored characters. 189 // We use (outLength + equalsSignCount) instead of length because we don't
190 // want to account for ignored characters.
189 if (policy == Base64ValidatePadding && equalsSignCount && 191 if (policy == Base64ValidatePadding && equalsSignCount &&
190 (outLength + equalsSignCount) % 4) 192 (outLength + equalsSignCount) % 4)
191 return false; 193 return false;
192 194
193 // Valid data is (n * 4 + [0,2,3]) characters long. 195 // Valid data is (n * 4 + [0,2,3]) characters long.
194 if ((outLength % 4) == 1) 196 if ((outLength % 4) == 1)
195 return false; 197 return false;
196 198
197 // 4-byte to 3-byte conversion 199 // 4-byte to 3-byte conversion
198 outLength -= (outLength + 3) / 4; 200 outLength -= (outLength + 3) / 4;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 unsigned length, 263 unsigned length,
262 Base64EncodePolicy policy) { 264 Base64EncodePolicy policy) {
263 return base64Encode(data, length, policy).replace('+', '-').replace('/', '_'); 265 return base64Encode(data, length, policy).replace('+', '-').replace('/', '_');
264 } 266 }
265 267
266 String normalizeToBase64(const String& encoding) { 268 String normalizeToBase64(const String& encoding) {
267 return String(encoding).replace('-', '+').replace('_', '/'); 269 return String(encoding).replace('-', '+').replace('_', '/');
268 } 270 }
269 271
270 } // namespace WTF 272 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698