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

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

Issue 2680933005: Make static KURLs thread safe
Patch Set: :/ Created 3 years, 10 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) 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 26 matching lines...) Expand all
37 #include "wtf/text/StringStatics.h" 37 #include "wtf/text/StringStatics.h"
38 #include "wtf/text/StringUTF8Adaptor.h" 38 #include "wtf/text/StringUTF8Adaptor.h"
39 #include "wtf/text/TextEncoding.h" 39 #include "wtf/text/TextEncoding.h"
40 #include <algorithm> 40 #include <algorithm>
41 #ifndef NDEBUG 41 #ifndef NDEBUG
42 #include <stdio.h> 42 #include <stdio.h>
43 #endif 43 #endif
44 44
45 namespace blink { 45 namespace blink {
46 46
47 const char kAboutBlankUrl[] = "about:blank";
48
47 static const int maximumValidPortNumber = 0xFFFE; 49 static const int maximumValidPortNumber = 0xFFFE;
48 static const int invalidPortNumber = 0xFFFF; 50 static const int invalidPortNumber = 0xFFFF;
49 51
50 #if DCHECK_IS_ON() 52 #if DCHECK_IS_ON()
51 static void assertProtocolIsGood(const StringView protocol) { 53 static void assertProtocolIsGood(const StringView protocol) {
52 DCHECK(protocol != ""); 54 DCHECK(protocol != "");
53 for (size_t i = 0; i < protocol.length(); ++i) { 55 for (size_t i = 0; i < protocol.length(); ++i) {
54 LChar c = protocol.characters8()[i]; 56 LChar c = protocol.characters8()[i];
55 DCHECK(c > ' ' && c < 0x7F && !(c >= 'A' && c <= 'Z')); 57 DCHECK(c > ' ' && c < 0x7F && !(c >= 'A' && c <= 'Z'));
56 } 58 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // read the contents of the clipboard on a drag, even without a drop. 167 // read the contents of the clipboard on a drag, even without a drop.
166 // Likewise with using the FrameLoader::shouldTreatURLAsLocal() function. 168 // Likewise with using the FrameLoader::shouldTreatURLAsLocal() function.
167 return protocolIs("file"); 169 return protocolIs("file");
168 } 170 }
169 171
170 bool protocolIsJavaScript(const String& url) { 172 bool protocolIsJavaScript(const String& url) {
171 return protocolIs(url, "javascript"); 173 return protocolIs(url, "javascript");
172 } 174 }
173 175
174 const KURL& blankURL() { 176 const KURL& blankURL() {
175 DEFINE_STATIC_LOCAL(KURL, staticBlankURL, (ParsedURLString, "about:blank")); 177 DEFINE_STATIC_LOCAL(KURL, staticBlankURL, (ParsedURLString, kAboutBlankUrl));
178 DCHECK(isMainThread());
176 return staticBlankURL; 179 return staticBlankURL;
177 } 180 }
178 181
179 bool KURL::isAboutBlankURL() const { 182 bool KURL::isAboutBlankURL() const {
180 return *this == blankURL(); 183 return getString() == kAboutBlankUrl;
181 }
182
183 const KURL& srcdocURL() {
184 DEFINE_STATIC_LOCAL(KURL, staticSrcdocURL, (ParsedURLString, "about:srcdoc"));
185 return staticSrcdocURL;
186 } 184 }
187 185
188 bool KURL::isAboutSrcdocURL() const { 186 bool KURL::isAboutSrcdocURL() const {
189 return *this == srcdocURL(); 187 return getString() == "about:srcdoc";
190 } 188 }
191 189
192 String KURL::elidedString() const { 190 String KURL::elidedString() const {
193 if (getString().length() <= 1024) 191 if (getString().length() <= 1024)
194 return getString(); 192 return getString();
195 193
196 return getString().left(511) + "..." + getString().right(510); 194 return getString().left(511) + "..." + getString().right(510);
197 } 195 }
198 196
199 KURL::KURL() : m_isValid(false), m_protocolIsInHTTPFamily(false) {} 197 KURL::KURL() : m_isValid(false), m_protocolIsInHTTPFamily(false) {}
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 m_string = AtomicString::fromUTF8(output.data(), output.length()); 871 m_string = AtomicString::fromUTF8(output.data(), output.length());
874 initProtocolMetadata(); 872 initProtocolMetadata();
875 } 873 }
876 874
877 bool KURL::isSafeToSendToAnotherThread() const { 875 bool KURL::isSafeToSendToAnotherThread() const {
878 return m_string.isSafeToSendToAnotherThread() && 876 return m_string.isSafeToSendToAnotherThread() &&
879 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); 877 (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread());
880 } 878 }
881 879
882 } // namespace blink 880 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698