Commit 7ae68cab authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Refactor: unsigned short/int -> uint16_t in third_party/blink/renderer/platform/weborigin

- unsigned short/int -> uint16_t.
- No logic changes.
- Reference: https://google.github.io/styleguide/cppguide.html#Integer_Types

Bug: 929986
Change-Id: I82c389e5865267daef3bbf25c5098aa584e17c76
Reviewed-on: https://chromium-review.googlesource.com/c/1488481Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635474}
parent 0e284dfa
......@@ -70,12 +70,12 @@ class WebSecurityOrigin {
BLINK_PLATFORM_EXPORT WebString Protocol() const;
BLINK_PLATFORM_EXPORT WebString Host() const;
BLINK_PLATFORM_EXPORT unsigned short Port() const;
BLINK_PLATFORM_EXPORT uint16_t Port() const;
// |Port()| will return 0 if the port is the default for an origin. This
// method instead returns the effective port, even if it is the default port
// (e.g. "http" => 80).
BLINK_PLATFORM_EXPORT unsigned short EffectivePort() const;
BLINK_PLATFORM_EXPORT uint16_t EffectivePort() const;
// A unique WebSecurityOrigin is the least privileged WebSecurityOrigin.
BLINK_PLATFORM_EXPORT bool IsOpaque() const;
......
......@@ -67,12 +67,12 @@ WebString WebSecurityOrigin::Host() const {
return private_->Host();
}
unsigned short WebSecurityOrigin::Port() const {
uint16_t WebSecurityOrigin::Port() const {
DCHECK(private_);
return private_->Port();
}
unsigned short WebSecurityOrigin::EffectivePort() const {
uint16_t WebSecurityOrigin::EffectivePort() const {
DCHECK(private_);
return private_->EffectivePort();
}
......
......@@ -33,8 +33,7 @@
namespace blink {
bool IsDefaultPortForProtocol(unsigned short port,
const WTF::String& protocol) {
bool IsDefaultPortForProtocol(uint16_t port, const WTF::String& protocol) {
if (protocol.IsEmpty())
return false;
......@@ -53,7 +52,7 @@ bool IsDefaultPortForProtocol(unsigned short port,
return false;
}
unsigned short DefaultPortForProtocol(const WTF::String& protocol) {
uint16_t DefaultPortForProtocol(const WTF::String& protocol) {
if (protocol == "http" || protocol == "ws")
return 80;
if (protocol == "https" || protocol == "wss")
......@@ -76,7 +75,7 @@ bool IsPortAllowedForScheme(const KURL& url) {
String protocol = url.Protocol();
if (protocol.IsNull())
protocol = g_empty_string;
unsigned short effective_port = url.Port();
uint16_t effective_port = url.Port();
if (!effective_port)
effective_port = DefaultPortForProtocol(protocol);
StringUTF8Adaptor utf8(protocol);
......
......@@ -36,12 +36,11 @@ class KURL;
// Returns true if |port| is known to be the default for |protocol|. |protocol|
// must be lower case.
PLATFORM_EXPORT bool IsDefaultPortForProtocol(unsigned short port,
PLATFORM_EXPORT bool IsDefaultPortForProtocol(uint16_t port,
const WTF::String& protocol);
// Returns 0 for unknown protocols. |protocol| must be lower case.
PLATFORM_EXPORT unsigned short DefaultPortForProtocol(
const WTF::String& protocol);
PLATFORM_EXPORT uint16_t DefaultPortForProtocol(const WTF::String& protocol);
// Returns true if the port of the |url| is allowed for the scheme of the |url|.
PLATFORM_EXPORT bool IsPortAllowedForScheme(const KURL&);
......
......@@ -11,7 +11,7 @@ namespace blink {
TEST(KnownPortsTest, IsDefaultPortForProtocol) {
struct TestCase {
const unsigned short port;
const uint16_t port;
const char* protocol;
const bool is_known;
} inputs[] = {
......@@ -43,7 +43,7 @@ TEST(KnownPortsTest, IsDefaultPortForProtocol) {
TEST(KnownPortsTest, DefaultPortForProtocol) {
struct TestCase {
const unsigned short port;
const uint16_t port;
const char* protocol;
} inputs[] = {
// Known ones.
......
......@@ -356,7 +356,7 @@ String KURL::Host() const {
return ComponentString(parsed_.host);
}
unsigned short KURL::Port() const {
uint16_t KURL::Port() const {
if (!is_valid_ || parsed_.port.len <= 0)
return 0;
DCHECK(!string_.IsNull());
......@@ -366,7 +366,7 @@ unsigned short KURL::Port() const {
DCHECK_NE(port, url::PORT_UNSPECIFIED); // Checked port.len <= 0 already.
DCHECK_NE(port, url::PORT_INVALID); // Checked is_valid_ already.
return static_cast<unsigned short>(port);
return static_cast<uint16_t>(port);
}
// TODO(csharrison): Migrate pass() and user() to return a StringView. Most
......@@ -517,7 +517,7 @@ void KURL::SetPort(const String& port) {
SetPort(parsed_port.ToUInt());
}
void KURL::SetPort(unsigned short port) {
void KURL::SetPort(uint16_t port) {
if (IsDefaultPortForProtocol(port, Protocol())) {
RemovePort();
return;
......
......@@ -161,7 +161,7 @@ class PLATFORM_EXPORT KURL {
//
// We treat URLs with out-of-range port numbers as invalid URLs, and they
// will be rejected by the canonicalizer.
unsigned short Port() const;
uint16_t Port() const;
bool HasPort() const;
String User() const;
String Pass() const;
......@@ -190,7 +190,7 @@ class PLATFORM_EXPORT KURL {
void SetHost(const String&);
void RemovePort();
void SetPort(unsigned short);
void SetPort(uint16_t);
void SetPort(const String&);
// Input is like "foo.com" or "foo.com:8000".
......
......@@ -302,7 +302,7 @@ class PLATFORM_EXPORT SecurityOrigin : public RefCounted<SecurityOrigin> {
static String CanonicalizeHost(const String& host, bool* success);
private:
constexpr static const int kInvalidPort = 0;
constexpr static const uint16_t kInvalidPort = 0;
friend struct mojo::UrlOriginAdapter;
friend struct blink::SecurityOriginHash;
......
......@@ -460,8 +460,8 @@ TEST_F(SecurityOriginTest, PunycodeNotUnicode) {
TEST_F(SecurityOriginTest, PortAndEffectivePortMethod) {
struct TestCase {
unsigned short port;
unsigned short effective_port;
uint16_t port;
uint16_t effective_port;
const char* origin;
} cases[] = {
{0, 80, "http://example.com"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment