Commit 89dbb21a authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Rename DevToolsListener EncodedURL to EncodeURIComponent

The helper URI encodes a url or any component of a url, so it is a URI
string sequence, identical to the web method encodeURIComponent. Let's
use |component| arg in its definition and adopt the name for clarity.

No change in behavior, no new tests.

Tbr: benreich
Bug: 1113941
Change-Id: I4c46377656182bc97c04ea91997bbc3b36bfcc5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469920Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816906}
parent f5d7355f
...@@ -29,10 +29,10 @@ base::span<const uint8_t> StringToSpan(const std::string& str) { ...@@ -29,10 +29,10 @@ base::span<const uint8_t> StringToSpan(const std::string& str) {
return base::as_bytes(base::make_span(str)); return base::as_bytes(base::make_span(str));
} }
std::string EncodedURL(const std::string& url) { std::string EncodeURIComponent(const std::string& component) {
url::RawCanonOutputT<char> canonical_url; url::RawCanonOutputT<char> encoded;
url::EncodeURIComponent(url.c_str(), url.size(), &canonical_url); url::EncodeURIComponent(component.c_str(), component.size(), &encoded);
return std::string(canonical_url.data(), canonical_url.length()); return std::string(encoded.data(), encoded.length());
} }
} // namespace } // namespace
...@@ -151,7 +151,7 @@ void DevToolsListener::StopAndStoreJSCoverage(content::DevToolsAgentHost* host, ...@@ -151,7 +151,7 @@ void DevToolsListener::StopAndStoreJSCoverage(content::DevToolsAgentHost* host,
} }
const std::string url = host->GetURL().spec(); const std::string url = host->GetURL().spec();
CHECK(result->SetString("encodedHostURL", EncodedURL(url))); CHECK(result->SetString("encodedHostURL", EncodeURIComponent(url)));
CHECK(result->SetString("hostTitle", host->GetTitle())); CHECK(result->SetString("hostTitle", host->GetTitle()));
CHECK(result->SetString("hostType", host->GetType())); CHECK(result->SetString("hostType", host->GetType()));
CHECK(result->SetString("hostTest", test)); CHECK(result->SetString("hostTest", test));
...@@ -213,7 +213,7 @@ void DevToolsListener::StoreScripts(content::DevToolsAgentHost* host, ...@@ -213,7 +213,7 @@ void DevToolsListener::StoreScripts(content::DevToolsAgentHost* host,
base::DictionaryValue* script = nullptr; base::DictionaryValue* script = nullptr;
CHECK(script_[i]->GetDictionary("params", &script)); CHECK(script_[i]->GetDictionary("params", &script));
CHECK(script->SetString("encodedURL", EncodedURL(url))); CHECK(script->SetString("encodedURL", EncodeURIComponent(url)));
CHECK(script->SetString("hash", hash)); CHECK(script->SetString("hash", hash));
CHECK(script->SetString("text", text)); CHECK(script->SetString("text", text));
CHECK(script->SetString("url", url)); CHECK(script->SetString("url", url));
......
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