OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "platform/weborigin/KURL.h" | 28 #include "platform/weborigin/KURL.h" |
29 | 29 |
30 #include "platform/weborigin/KnownPorts.h" | 30 #include "platform/weborigin/KnownPorts.h" |
31 #include "url/url_util.h" | 31 #include "url/url_util.h" |
| 32 #include "wtf/PtrUtil.h" |
32 #include "wtf/StdLibExtras.h" | 33 #include "wtf/StdLibExtras.h" |
33 #include "wtf/text/CString.h" | 34 #include "wtf/text/CString.h" |
34 #include "wtf/text/StringHash.h" | 35 #include "wtf/text/StringHash.h" |
35 #include "wtf/text/StringUTF8Adaptor.h" | 36 #include "wtf/text/StringUTF8Adaptor.h" |
36 #include "wtf/text/TextEncoding.h" | 37 #include "wtf/text/TextEncoding.h" |
37 #include <algorithm> | 38 #include <algorithm> |
38 #ifndef NDEBUG | 39 #ifndef NDEBUG |
39 #include <stdio.h> | 40 #include <stdio.h> |
40 #endif | 41 #endif |
41 | 42 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 { | 268 { |
268 } | 269 } |
269 | 270 |
270 KURL::KURL(const KURL& other) | 271 KURL::KURL(const KURL& other) |
271 : m_isValid(other.m_isValid) | 272 : m_isValid(other.m_isValid) |
272 , m_protocolIsInHTTPFamily(other.m_protocolIsInHTTPFamily) | 273 , m_protocolIsInHTTPFamily(other.m_protocolIsInHTTPFamily) |
273 , m_parsed(other.m_parsed) | 274 , m_parsed(other.m_parsed) |
274 , m_string(other.m_string) | 275 , m_string(other.m_string) |
275 { | 276 { |
276 if (other.m_innerURL.get()) | 277 if (other.m_innerURL.get()) |
277 m_innerURL = adoptPtr(new KURL(other.m_innerURL->copy())); | 278 m_innerURL = wrapUnique(new KURL(other.m_innerURL->copy())); |
278 } | 279 } |
279 | 280 |
280 KURL::~KURL() | 281 KURL::~KURL() |
281 { | 282 { |
282 } | 283 } |
283 | 284 |
284 KURL& KURL::operator=(const KURL& other) | 285 KURL& KURL::operator=(const KURL& other) |
285 { | 286 { |
286 m_isValid = other.m_isValid; | 287 m_isValid = other.m_isValid; |
287 m_protocolIsInHTTPFamily = other.m_protocolIsInHTTPFamily; | 288 m_protocolIsInHTTPFamily = other.m_protocolIsInHTTPFamily; |
288 m_parsed = other.m_parsed; | 289 m_parsed = other.m_parsed; |
289 m_string = other.m_string; | 290 m_string = other.m_string; |
290 if (other.m_innerURL) | 291 if (other.m_innerURL) |
291 m_innerURL = adoptPtr(new KURL(other.m_innerURL->copy())); | 292 m_innerURL = wrapUnique(new KURL(other.m_innerURL->copy())); |
292 else | 293 else |
293 m_innerURL.reset(); | 294 m_innerURL.reset(); |
294 return *this; | 295 return *this; |
295 } | 296 } |
296 | 297 |
297 KURL KURL::copy() const | 298 KURL KURL::copy() const |
298 { | 299 { |
299 KURL result; | 300 KURL result; |
300 result.m_isValid = m_isValid; | 301 result.m_isValid = m_isValid; |
301 result.m_protocolIsInHTTPFamily = m_protocolIsInHTTPFamily; | 302 result.m_protocolIsInHTTPFamily = m_protocolIsInHTTPFamily; |
302 result.m_parsed = m_parsed; | 303 result.m_parsed = m_parsed; |
303 result.m_string = m_string.isolatedCopy(); | 304 result.m_string = m_string.isolatedCopy(); |
304 if (m_innerURL) | 305 if (m_innerURL) |
305 result.m_innerURL = adoptPtr(new KURL(m_innerURL->copy())); | 306 result.m_innerURL = wrapUnique(new KURL(m_innerURL->copy())); |
306 return result; | 307 return result; |
307 } | 308 } |
308 | 309 |
309 bool KURL::isNull() const | 310 bool KURL::isNull() const |
310 { | 311 { |
311 return m_string.isNull(); | 312 return m_string.isNull(); |
312 } | 313 } |
313 | 314 |
314 bool KURL::isEmpty() const | 315 bool KURL::isEmpty() const |
315 { | 316 { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 812 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
812 } | 813 } |
813 | 814 |
814 void KURL::initInnerURL() | 815 void KURL::initInnerURL() |
815 { | 816 { |
816 if (!m_isValid) { | 817 if (!m_isValid) { |
817 m_innerURL.reset(); | 818 m_innerURL.reset(); |
818 return; | 819 return; |
819 } | 820 } |
820 if (url::Parsed* innerParsed = m_parsed.inner_parsed()) | 821 if (url::Parsed* innerParsed = m_parsed.inner_parsed()) |
821 m_innerURL = adoptPtr(new KURL(ParsedURLString, m_string.substring(inner
Parsed->scheme.begin, innerParsed->Length() - innerParsed->scheme.begin))); | 822 m_innerURL = wrapUnique(new KURL(ParsedURLString, m_string.substring(inn
erParsed->scheme.begin, innerParsed->Length() - innerParsed->scheme.begin))); |
822 else | 823 else |
823 m_innerURL.reset(); | 824 m_innerURL.reset(); |
824 } | 825 } |
825 | 826 |
826 template<typename CHAR> | 827 template<typename CHAR> |
827 bool internalProtocolIs(const url::Component& scheme, const CHAR* spec, const ch
ar* protocol) | 828 bool internalProtocolIs(const url::Component& scheme, const CHAR* spec, const ch
ar* protocol) |
828 { | 829 { |
829 const CHAR* begin = spec + scheme.begin; | 830 const CHAR* begin = spec + scheme.begin; |
830 const CHAR* end = begin + scheme.len; | 831 const CHAR* end = begin + scheme.len; |
831 | 832 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 915 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
915 } | 916 } |
916 | 917 |
917 bool KURL::isSafeToSendToAnotherThread() const | 918 bool KURL::isSafeToSendToAnotherThread() const |
918 { | 919 { |
919 return m_string.isSafeToSendToAnotherThread() | 920 return m_string.isSafeToSendToAnotherThread() |
920 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); | 921 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); |
921 } | 922 } |
922 | 923 |
923 } // namespace blink | 924 } // namespace blink |
OLD | NEW |