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

Unified Diff: components/devtools_http_handler/devtools_http_handler.cc

Issue 2121513002: Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos Created 4 years, 5 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
Index: components/devtools_http_handler/devtools_http_handler.cc
diff --git a/components/devtools_http_handler/devtools_http_handler.cc b/components/devtools_http_handler/devtools_http_handler.cc
index 38f32dc1da2ebbc96522612e23e131b1edc069dd..48f58113f39bb67483a0b184aa629a91c565e184 100644
--- a/components/devtools_http_handler/devtools_http_handler.cc
+++ b/components/devtools_http_handler/devtools_http_handler.cc
@@ -395,7 +395,7 @@ void ServerWrapper::OnHttpRequest(int connection_id,
const net::HttpServerRequestInfo& info) {
server_->SetSendBufferSize(connection_id, kSendBufferSizeForDevTools);
- if (info.path.find("/json") == 0) {
+ if (base::StartsWith(info.path, "/json", base::CompareCase::SENSITIVE)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
@@ -406,7 +406,8 @@ void ServerWrapper::OnHttpRequest(int connection_id,
return;
}
- if (info.path.find(kThumbUrlPrefix) == 0) {
+ if (base::StartsWith(info.path, kThumbUrlPrefix,
+ base::CompareCase::SENSITIVE)) {
// Thumbnail request.
const std::string target_id = info.path.substr(strlen(kThumbUrlPrefix));
BrowserThread::PostTask(
@@ -430,7 +431,8 @@ void ServerWrapper::OnHttpRequest(int connection_id,
return;
}
- if (info.path.find("/devtools/") != 0) {
+ if (!base::StartsWith(info.path, "/devtools/",
+ base::CompareCase::SENSITIVE)) {
server_->Send404(connection_id);
return;
}
@@ -517,7 +519,7 @@ static bool ParseJsonPath(
return true;
}
- if (path.find("/") != 0) {
+ if (!base::StartsWith(path, "/", base::CompareCase::SENSITIVE)) {
// Malformed command.
return false;
}
@@ -696,8 +698,8 @@ void DevToolsHttpHandler::OnWebSocketRequest(
return;
std::string browser_prefix = "/devtools/browser";
- size_t browser_pos = request.path.find(browser_prefix);
- if (browser_pos == 0) {
+ if (base::StartsWith(request.path, browser_prefix,
+ base::CompareCase::SENSITIVE)) {
scoped_refptr<DevToolsAgentHost> browser_agent =
DevToolsAgentHost::CreateForBrowser(
thread_->task_runner(),
@@ -721,8 +723,8 @@ void DevToolsHttpHandler::OnWebSocketRequest(
return;
}
- size_t pos = request.path.find(kPageUrlPrefix);
- if (pos != 0) {
+ if (!base::StartsWith(request.path, kPageUrlPrefix,
+ base::CompareCase::SENSITIVE)) {
Send404(connection_id);
return;
}

Powered by Google App Engine
This is Rietveld 408576698