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

Side by Side Diff: url/url_canon_etc.cc

Issue 1270443006: Proof-read comments in src/url/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // Canonicalizers for random bits that aren't big enough for their own files. 5 // Canonicalizers for random bits that aren't big enough for their own files.
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "url/url_canon.h" 9 #include "url/url_canon.h"
10 #include "url/url_canon_internal.h" 10 #include "url/url_canon_internal.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (scheme.len <= 0) { 88 if (scheme.len <= 0) {
89 // Scheme is unspecified or empty, convert to empty by appending a colon. 89 // Scheme is unspecified or empty, convert to empty by appending a colon.
90 *out_scheme = Component(output->length(), 0); 90 *out_scheme = Component(output->length(), 0);
91 output->push_back(':'); 91 output->push_back(':');
92 return true; 92 return true;
93 } 93 }
94 94
95 // The output scheme starts from the current position. 95 // The output scheme starts from the current position.
96 out_scheme->begin = output->length(); 96 out_scheme->begin = output->length();
97 97
98 // Danger: it's important that this code does not strip any characters: it 98 // Danger: it's important that this code does not strip any characters;
99 // only emits the canonical version (be it valid or escaped) of each of 99 // it only emits the canonical version (be it valid or escaped) for each
100 // the input characters. Stripping would put it out of sync with 100 // of the input characters. Stripping would put it out of sync with
101 // FindAndCompareScheme, which could cause some security checks on 101 // FindAndCompareScheme, which could cause some security checks on
102 // schemes to be incorrect. 102 // schemes to be incorrect.
103 bool success = true; 103 bool success = true;
104 int end = scheme.end(); 104 int end = scheme.end();
105 for (int i = scheme.begin; i < end; i++) { 105 for (int i = scheme.begin; i < end; i++) {
106 UCHAR ch = static_cast<UCHAR>(spec[i]); 106 UCHAR ch = static_cast<UCHAR>(spec[i]);
107 char replacement = 0; 107 char replacement = 0;
108 if (ch < 0x80) { 108 if (ch < 0x80) {
109 if (i == scheme.begin) { 109 if (i == scheme.begin) {
110 // Need to do a special check for the first letter of the scheme. 110 // Need to do a special check for the first letter of the scheme.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 out_port->len = output->length() - out_port->begin; 211 out_port->len = output->length() - out_port->begin;
212 return false; 212 return false;
213 } 213 }
214 214
215 // Convert port number back to an integer. Max port value is 5 digits, and 215 // Convert port number back to an integer. Max port value is 5 digits, and
216 // the Parsed::ExtractPort will have made sure the integer is in range. 216 // the Parsed::ExtractPort will have made sure the integer is in range.
217 const int buf_size = 6; 217 const int buf_size = 6;
218 char buf[buf_size]; 218 char buf[buf_size];
219 WritePortInt(buf, buf_size, port_num); 219 WritePortInt(buf, buf_size, port_num);
220 220
221 // Append the port number to the output, preceeded by a colon. 221 // Append the port number to the output, preceded by a colon.
222 output->push_back(':'); 222 output->push_back(':');
223 out_port->begin = output->length(); 223 out_port->begin = output->length();
224 for (int i = 0; i < buf_size && buf[i]; i++) 224 for (int i = 0; i < buf_size && buf[i]; i++)
225 output->push_back(buf[i]); 225 output->push_back(buf[i]);
226 226
227 out_port->len = output->length() - out_port->begin; 227 out_port->len = output->length() - out_port->begin;
228 return true; 228 return true;
229 } 229 }
230 230
231 template<typename CHAR, typename UCHAR> 231 template<typename CHAR, typename UCHAR>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 358 }
359 359
360 void CanonicalizeRef(const base::char16* spec, 360 void CanonicalizeRef(const base::char16* spec,
361 const Component& ref, 361 const Component& ref,
362 CanonOutput* output, 362 CanonOutput* output,
363 Component* out_ref) { 363 Component* out_ref) {
364 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref); 364 DoCanonicalizeRef<base::char16, base::char16>(spec, ref, output, out_ref);
365 } 365 }
366 366
367 } // namespace url 367 } // namespace url
OLDNEW
« url/gurl.h ('K') | « url/url_canon.h ('k') | url/url_canon_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698