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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/KURL.cpp

Issue 2450083002: hackity hack. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | 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 /* 1 /*
2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 if (url.is8Bit()) 710 if (url.is8Bit())
711 return url::FindAndCompareScheme(asURLChar8Subtle(url), url.length(), 711 return url::FindAndCompareScheme(asURLChar8Subtle(url), url.length(),
712 protocol, 0); 712 protocol, 0);
713 return url::FindAndCompareScheme(url.characters16(), url.length(), protocol, 713 return url::FindAndCompareScheme(url.characters16(), url.length(), protocol,
714 0); 714 0);
715 } 715 }
716 716
717 void KURL::init(const KURL& base, 717 void KURL::init(const KURL& base,
718 const String& relative, 718 const String& relative,
719 const WTF::TextEncoding* queryEncoding) { 719 const WTF::TextEncoding* queryEncoding) {
720 if (!relative.isNull() && relative.is8Bit()) {
721 StringUTF8Adaptor relativeUTF8(relative);
722 init(base, relativeUTF8.data(), relativeUTF8.length(), queryEncoding);
723 } else
724 init(base, relative.characters16(), relative.length(), queryEncoding);
725 initProtocolIsInHTTPFamily();
726 initInnerURL();
727 }
728
729 template <typename CHAR>
730 void KURL::init(const KURL& base,
731 const CHAR* relative,
732 int relativeLength,
733 const WTF::TextEncoding* queryEncoding) {
734 // As a performance optimization, we do not use the charset converter 720 // As a performance optimization, we do not use the charset converter
735 // if encoding is UTF-8 or other Unicode encodings. Note that this is 721 // if encoding is UTF-8 or other Unicode encodings. Note that this is
736 // per HTML5 2.5.3 (resolving URL). The URL canonicalizer will be more 722 // per HTML5 2.5.3 (resolving URL). The URL canonicalizer will be more
737 // efficient with no charset converter object because it can do UTF-8 723 // efficient with no charset converter object because it can do UTF-8
738 // internally with no extra copies. 724 // internally with no extra copies.
739 725
740 // We feel free to make the charset converter object every time since it's 726 // We feel free to make the charset converter object every time since it's
741 // just a wrapper around a reference. 727 // just a wrapper around a reference.
742 KURLCharsetConverter charsetConverterObject(queryEncoding); 728 KURLCharsetConverter charsetConverterObject(queryEncoding);
743 KURLCharsetConverter* charsetConverter = 729 KURLCharsetConverter* charsetConverter =
744 (!queryEncoding || isUnicodeEncoding(queryEncoding)) 730 (!queryEncoding || isUnicodeEncoding(queryEncoding))
745 ? 0 731 ? 0
746 : &charsetConverterObject; 732 : &charsetConverterObject;
747 733
748 StringUTF8Adaptor baseUTF8(base.getString()); 734 StringUTF8Adaptor baseUTF8(base.getString());
735 url::RawCanonOutputT<char> output;
749 736
750 url::RawCanonOutputT<char> output; 737 if (!relative.isNull() && relative.is8Bit()) {
751 m_isValid = url::ResolveRelative(baseUTF8.data(), baseUTF8.length(), 738 StringUTF8Adaptor relativeUTF8(relative);
752 base.m_parsed, relative, relativeLength, 739 m_isValid = url::ResolveRelative(baseUTF8.data(), baseUTF8.length(),
753 charsetConverter, &output, &m_parsed); 740 base.m_parsed, relative, relativeLength,
741 charsetConverter, &output, &m_parsed);
742 } else {
743 m_isValid = url::ResolveRelative(baseUTF8.data(), baseUTF8.length(),
744 base.m_parsed, relative.characters16(),
745 static_cast<int>(relative.length()),
746 charsetConverter, &output, &m_parsed);
747 }
754 748
755 // See FIXME in KURLPrivate in the header. If canonicalization has not 749 if (StringView(output.data(), static_cast<unsigned>(output.length())) ==
756 // changed the string, we can avoid an extra allocation by using assignment. 750 relative)
757 m_string = AtomicString::fromUTF8(output.data(), output.length()); 751 m_string = AtomicString(relative);
752 else
753 m_string = AtomicString::fromUTF8(output.data(), output.length());
754
755 initProtocolIsInHTTPFamily();
756 initInnerURL();
758 } 757 }
759 758
760 void KURL::initInnerURL() { 759 void KURL::initInnerURL() {
761 if (!m_isValid) { 760 if (!m_isValid) {
762 m_innerURL.reset(); 761 m_innerURL.reset();
763 return; 762 return;
764 } 763 }
765 if (url::Parsed* innerParsed = m_parsed.inner_parsed()) 764 if (url::Parsed* innerParsed = m_parsed.inner_parsed())
766 m_innerURL = wrapUnique(new KURL( 765 m_innerURL = wrapUnique(new KURL(
767 ParsedURLString, 766 ParsedURLString,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 m_parsed = newParsed; 867 m_parsed = newParsed;
869 m_string = AtomicString::fromUTF8(output.data(), output.length()); 868 m_string = AtomicString::fromUTF8(output.data(), output.length());
870 } 869 }
871 870
872 bool KURL::isSafeToSendToAnotherThread() const { 871 bool KURL::isSafeToSendToAnotherThread() const {
873 return m_string.isSafeToSendToAnotherThread() && 872 return m_string.isSafeToSendToAnotherThread() &&
874 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); 873 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread());
875 } 874 }
876 875
877 } // namespace blink 876 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698