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

Side by Side Diff: Source/platform/weborigin/SecurityOrigin.cpp

Issue 123003002: Make calls to AtomicString(const String&) explicit in loader/ and fetch/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 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
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 String SecurityOrigin::toString() const 412 String SecurityOrigin::toString() const
413 { 413 {
414 if (isUnique()) 414 if (isUnique())
415 return "null"; 415 return "null";
416 if (m_protocol == "file" && m_enforceFilePathSeparation) 416 if (m_protocol == "file" && m_enforceFilePathSeparation)
417 return "null"; 417 return "null";
418 return toRawString(); 418 return toRawString();
419 } 419 }
420 420
421 AtomicString SecurityOrigin::toAtomicString() const
422 {
423 if (isUnique())
424 return AtomicString("null", AtomicString::ConstructFromLiteral);
425 if (m_protocol == "file" && m_enforceFilePathSeparation)
426 return AtomicString("null", AtomicString::ConstructFromLiteral);
427 return toRawAtomicString();
428 }
429
421 String SecurityOrigin::toRawString() const 430 String SecurityOrigin::toRawString() const
422 { 431 {
423 if (m_protocol == "file") 432 if (m_protocol == "file")
424 return "file://"; 433 return "file://";
425 434
426 StringBuilder result; 435 StringBuilder result;
427 result.reserveCapacity(m_protocol.length() + m_host.length() + 10); 436 buildRawString(result);
428 result.append(m_protocol);
429 result.append("://");
430 result.append(m_host);
431
432 if (m_port) {
433 result.append(':');
434 result.appendNumber(m_port);
435 }
436
437 return result.toString(); 437 return result.toString();
438 } 438 }
439 439
440 AtomicString SecurityOrigin::toRawAtomicString() const
441 {
442 if (m_protocol == "file")
443 return AtomicString("file://", AtomicString::ConstructFromLiteral);
444
445 StringBuilder result;
446 buildRawString(result);
447 return result.toAtomicString();
448 }
449
450 inline void SecurityOrigin::buildRawString(StringBuilder& builder) const
451 {
452 builder.reserveCapacity(m_protocol.length() + m_host.length() + 10);
453 builder.append(m_protocol);
454 builder.appendLiteral("://");
455 builder.append(m_host);
456
457 if (m_port) {
458 builder.append(':');
459 builder.appendNumber(m_port);
460 }
461 }
462
440 PassRefPtr<SecurityOrigin> SecurityOrigin::createFromString(const String& origin String) 463 PassRefPtr<SecurityOrigin> SecurityOrigin::createFromString(const String& origin String)
441 { 464 {
442 return SecurityOrigin::create(KURL(KURL(), originString)); 465 return SecurityOrigin::create(KURL(KURL(), originString));
443 } 466 }
444 467
445 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const String& protocol, const String& host, int port) 468 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const String& protocol, const String& host, int port)
446 { 469 {
447 if (port < 0 || port > MaxAllowedPort) 470 if (port < 0 || port > MaxAllowedPort)
448 return createUnique(); 471 return createUnique();
449 String decodedHost = decodeURLEscapeSequences(host); 472 String decodedHost = decodeURLEscapeSequences(host);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 508 }
486 509
487 const String& SecurityOrigin::urlWithUniqueSecurityOrigin() 510 const String& SecurityOrigin::urlWithUniqueSecurityOrigin()
488 { 511 {
489 ASSERT(isMainThread()); 512 ASSERT(isMainThread());
490 DEFINE_STATIC_LOCAL(const String, uniqueSecurityOriginURL, ("data:,")); 513 DEFINE_STATIC_LOCAL(const String, uniqueSecurityOriginURL, ("data:,"));
491 return uniqueSecurityOriginURL; 514 return uniqueSecurityOriginURL;
492 } 515 }
493 516
494 } // namespace WebCore 517 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698