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

Unified Diff: third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp

Issue 2800133003: Avoid duplicate functions: one AddStringToDigestor is enough (Closed)
Patch Set: New idea. Include the string type in the name. Created 3 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: third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp
diff --git a/third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp b/third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp
index c4068975bff05f68cdd253c04977897ceb3a7e2e..2172f0b4c0e63c75adbed4e1586a37e61af4f9e1 100644
--- a/third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp
+++ b/third_party/WebKit/Source/core/inspector/DOMPatchSupport.cpp
@@ -427,8 +427,8 @@ bool DOMPatchSupport::InnerPatchChildren(
return true;
}
-static void AddStringToDigestor(WebCryptoDigestor* digestor,
- const String& string) {
+static void AddUtf8StringToDigestor(WebCryptoDigestor* digestor,
+ const String& string) {
digestor->Consume(
reinterpret_cast<const unsigned char*>(string.Utf8().data()),
string.length());
alph 2017/07/10 21:26:06 The length still doesn't match the data though. Co
@@ -446,15 +446,15 @@ DOMPatchSupport::Digest* DOMPatchSupport::CreateDigest(
Node::NodeType node_type = node->getNodeType();
digestor->Consume(reinterpret_cast<const unsigned char*>(&node_type),
sizeof(node_type));
- AddStringToDigestor(digestor.get(), node->nodeName());
- AddStringToDigestor(digestor.get(), node->nodeValue());
+ AddUtf8StringToDigestor(digestor.get(), node->nodeName());
+ AddUtf8StringToDigestor(digestor.get(), node->nodeValue());
if (node->IsElementNode()) {
Element& element = ToElement(*node);
Node* child = element.firstChild();
while (child) {
Digest* child_info = CreateDigest(child, unused_nodes_map);
- AddStringToDigestor(digestor.get(), child_info->sha1_);
+ AddUtf8StringToDigestor(digestor.get(), child_info->sha1_);
child = child->nextSibling();
digest->children_.push_back(child_info);
}
@@ -464,15 +464,15 @@ DOMPatchSupport::Digest* DOMPatchSupport::CreateDigest(
std::unique_ptr<WebCryptoDigestor> attrs_digestor =
CreateDigestor(kHashAlgorithmSha1);
for (auto& attribute : attributes) {
- AddStringToDigestor(attrs_digestor.get(),
- attribute.GetName().ToString());
- AddStringToDigestor(attrs_digestor.get(),
- attribute.Value().GetString());
+ AddUtf8StringToDigestor(attrs_digestor.get(),
+ attribute.GetName().ToString());
+ AddUtf8StringToDigestor(attrs_digestor.get(),
+ attribute.Value().GetString());
}
FinishDigestor(attrs_digestor.get(), digest_result);
digest->attrs_sha1_ =
Base64Encode(reinterpret_cast<const char*>(digest_result.data()), 10);
- AddStringToDigestor(digestor.get(), digest->attrs_sha1_);
+ AddUtf8StringToDigestor(digestor.get(), digest->attrs_sha1_);
digest_result.clear();
}
}

Powered by Google App Engine
This is Rietveld 408576698