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

Unified Diff: Source/platform/weborigin/KnownPorts.cpp

Issue 895793003: Simplify protocal name and port comparison (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed one unnecessary include Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/weborigin/KnownPorts.cpp
diff --git a/Source/platform/weborigin/KnownPorts.cpp b/Source/platform/weborigin/KnownPorts.cpp
index 71499a5120c0c30971113663f74560f12173b096..9de00e98ff66120c48cfb9d0f50d434ac32afd9d 100644
--- a/Source/platform/weborigin/KnownPorts.cpp
+++ b/Source/platform/weborigin/KnownPorts.cpp
@@ -30,7 +30,6 @@
#include "platform/weborigin/KURL.h"
#include "wtf/HashMap.h"
#include "wtf/StdLibExtras.h"
-#include "wtf/Threading.h"
#include "wtf/text/StringHash.h"
namespace blink {
@@ -40,15 +39,22 @@ bool isDefaultPortForProtocol(unsigned short port, const String& protocol)
if (protocol.isEmpty())
return false;
- typedef HashMap<String, unsigned, CaseFoldingHash> DefaultPortsMap;
- AtomicallyInitializedStaticReference(DefaultPortsMap, defaultPorts, new DefaultPortsMap());
- if (defaultPorts.isEmpty()) {
- defaultPorts.set("http", 80);
- defaultPorts.set("https", 443);
- defaultPorts.set("ftp", 21);
- defaultPorts.set("ftps", 990);
+ switch (port) {
+ case 80:
+ return protocol == "http";
+ break;
+ case 443:
+ return protocol == "https";
+ break;
+ case 21:
+ return protocol == "ftp";
+ break;
+ case 990:
+ return protocol == "ftps";
+ break;
+ default:
+ return false;
}
- return defaultPorts.get(protocol) == port;
}
bool portAllowed(const KURL& url)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698