Commit 4832b03b authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

Fix StrongAlias (de)serialization in IPC messages.

It currently uses
param_type::StrongAlias(..) to construct the type, which seems wrong
as param_type = util::StrongAlias<TagType, UnderlyingType>.
Which causes following compile error:

In file included from ../../ipc/ipc_message_utils_unittest.cc:5:
../../ipc/ipc_message_utils.h:1075:10: error: missing 'typename' prior to dependent type name 'param_type::StrongAlias'
    *r = param_type::StrongAlias(value);
         ^~~~~~~~~~~~~~~~~~~~~~~
Call StrongAlias constructor directly to fix this.
Add a regression unit test to fix the regression.

Bug: None
Change-Id: If172c83abd22498117c47a8721b7d9057c18a1d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983570Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728702}
parent 6c0a46d4
...@@ -1071,7 +1071,7 @@ struct ParamTraits<util::StrongAlias<TagType, UnderlyingType>> { ...@@ -1071,7 +1071,7 @@ struct ParamTraits<util::StrongAlias<TagType, UnderlyingType>> {
UnderlyingType value; UnderlyingType value;
if (!ReadParam(m, iter, &value)) if (!ReadParam(m, iter, &value))
return false; return false;
*r = param_type::StrongAlias(value); *r = param_type(value);
return true; return true;
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
......
...@@ -216,5 +216,19 @@ TEST(IPCMessageUtilsTest, FlatMap) { ...@@ -216,5 +216,19 @@ TEST(IPCMessageUtilsTest, FlatMap) {
EXPECT_EQ(input, output); EXPECT_EQ(input, output);
} }
TEST(IPCMessageUtilsTest, StrongAlias) {
using TestType = util::StrongAlias<class Tag, int>;
TestType input(42);
base::Pickle pickle;
IPC::WriteParam(&pickle, input);
base::PickleIterator iter(pickle);
TestType output;
EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output));
EXPECT_EQ(input, output);
}
} // namespace } // namespace
} // namespace IPC } // namespace IPC
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