Commit a9aee5fa authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Add CHECKs to KURL::Port()

Add CHECK statements to KURL::Port() to verify that it is behaving as expected,
in preparation for removing unnecessary code.

The CHECKs will be replaced with DCHECKs in a followup CL after there's been
time for any crashes to appear.

BUG=606462

Change-Id: Ib3bcc738005de27201435f2c62aa4056965d5c91
Reviewed-on: https://chromium-review.googlesource.com/1111879Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570330}
parent eee4843a
......@@ -362,15 +362,17 @@ String KURL::Host() const {
unsigned short KURL::Port() const {
if (!is_valid_ || parsed_.port.len <= 0)
return 0;
DCHECK(!string_.IsNull());
// TODO(ricea): Change this back to DCHECK.
CHECK(!string_.IsNull());
int port = string_.Is8Bit()
? url::ParsePort(AsURLChar8Subtle(string_), parsed_.port)
: url::ParsePort(string_.Characters16(), parsed_.port);
DCHECK_NE(port, url::PORT_UNSPECIFIED); // Checked port.len <= 0 before.
// TODO(ricea): Change these two to DCHECK.
CHECK_NE(port, url::PORT_UNSPECIFIED); // Checked port.len <= 0 already.
CHECK_NE(port, url::PORT_INVALID); // Checked is_valid_ already.
if (port == url::PORT_INVALID ||
port > kMaximumValidPortNumber) // Mimic KURL::port()
port = kInvalidPortNumber;
// TODO(ricea): Remove this CHECK and the constants it uses.
CHECK(port <= kMaximumValidPortNumber || port == kInvalidPortNumber);
return static_cast<unsigned short>(port);
}
......
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