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

Side by Side Diff: url/third_party/mozilla/url_parse.cc

Issue 23549039: Preparing to support fragment resolution against non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Not updating the net tests Created 7 years, 3 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 | Annotate | Revision Log
« url/gurl.h ('K') | « url/third_party/mozilla/url_parse.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Based on nsURLParsers.cc from Mozilla 1 /* Based on nsURLParsers.cc from Mozilla
2 * ------------------------------------- 2 * -------------------------------------
3 * The contents of this file are subject to the Mozilla Public License Version 3 * The contents of this file are subject to the Mozilla Public License Version
4 * 1.1 (the "License"); you may not use this file except in compliance with 4 * 1.1 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at 5 * the License. You may obtain a copy of the License at
6 * http://www.mozilla.org/MPL/ 6 * http://www.mozilla.org/MPL/
7 * 7 *
8 * Software distributed under the License is distributed on an "AS IS" basis, 8 * Software distributed under the License is distributed on an "AS IS" basis,
9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10 * for the specific language governing rights and limitations under the 10 * for the specific language governing rights and limitations under the
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 parsed->scheme.reset(); 474 parsed->scheme.reset();
475 parsed->path.reset(); 475 parsed->path.reset();
476 return; 476 return;
477 } 477 }
478 478
479 // Extract the scheme, with the path being everything following. We also 479 // Extract the scheme, with the path being everything following. We also
480 // handle the case where there is no scheme. 480 // handle the case where there is no scheme.
481 if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { 481 if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) {
482 // Offset the results since we gave ExtractScheme a substring. 482 // Offset the results since we gave ExtractScheme a substring.
483 parsed->scheme.begin += begin; 483 parsed->scheme.begin += begin;
484
joth 2013/09/19 22:50:02 unneeded edit
Kristian Monsen 2013/09/20 05:57:31 Done.
485 // For compatability with the standard URL parser, we treat no path as 484 // For compatability with the standard URL parser, we treat no path as
486 // -1, rather than having a length of 0 (we normally wouldn't care so 485 // -1, rather than having a length of 0 (we normally wouldn't care so
487 // much for these non-standard URLs). 486 // much for these non-standard URLs).
488 if (parsed->scheme.end() == spec_len - 1) 487 if (parsed->scheme.end() == spec_len - 1)
489 parsed->path.reset(); 488 parsed->path.reset();
490 else 489 else
491 parsed->path = MakeRange(parsed->scheme.end() + 1, spec_len); 490 parsed->path = MakeRange(parsed->scheme.end() + 1, spec_len);
492 } else { 491 } else {
493 // No scheme found, just path. 492 // No scheme found, just path.
494 parsed->scheme.reset(); 493 parsed->scheme.reset();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 return ref.begin; // Back over delimiter. 784 return ref.begin; // Back over delimiter.
786 785
787 // When there is a ref and we get here, the component we wanted was before 786 // When there is a ref and we get here, the component we wanted was before
788 // this and not found, so we always know the beginning of the ref is right. 787 // this and not found, so we always know the beginning of the ref is right.
789 return ref.begin - 1; // Don't want delimiter counted. 788 return ref.begin - 1; // Don't want delimiter counted.
790 } 789 }
791 790
792 return cur; 791 return cur;
793 } 792 }
794 793
794 Component Parsed::GetContent() const {
795 const int begin = CountCharactersBefore(USERNAME, false);
796 const int len = Length() - begin;
797 // For compatability with the standard URL parser, we treat no content as
798 // -1, rather than having a length of 0 (we normally wouldn't care so
799 // much for these non-standard URLs).
800 return len ? Component(begin, len) : Component();
801 }
802
795 bool ExtractScheme(const char* url, int url_len, Component* scheme) { 803 bool ExtractScheme(const char* url, int url_len, Component* scheme) {
796 return DoExtractScheme(url, url_len, scheme); 804 return DoExtractScheme(url, url_len, scheme);
797 } 805 }
798 806
799 bool ExtractScheme(const base::char16* url, int url_len, Component* scheme) { 807 bool ExtractScheme(const base::char16* url, int url_len, Component* scheme) {
800 return DoExtractScheme(url, url_len, scheme); 808 return DoExtractScheme(url, url_len, scheme);
801 } 809 }
802 810
803 // This handles everything that may be an authority terminator, including 811 // This handles everything that may be an authority terminator, including
804 // backslash. For special backslash handling see DoParseAfterScheme. 812 // backslash. For special backslash handling see DoParseAfterScheme.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 } 922 }
915 923
916 void ParseAfterScheme(const base::char16* spec, 924 void ParseAfterScheme(const base::char16* spec,
917 int spec_len, 925 int spec_len,
918 int after_scheme, 926 int after_scheme,
919 Parsed* parsed) { 927 Parsed* parsed) {
920 DoParseAfterScheme(spec, spec_len, after_scheme, parsed); 928 DoParseAfterScheme(spec, spec_len, after_scheme, parsed);
921 } 929 }
922 930
923 } // namespace url_parse 931 } // namespace url_parse
OLDNEW
« url/gurl.h ('K') | « url/third_party/mozilla/url_parse.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698