Index: content/public/common/common_param_traits.cc |
diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc |
index 0501683374c3fa67233cdef8a07985efd1d8f5cd..194103af472f7b17e5a5bfd63e8cb6c8328c01de 100644 |
--- a/content/public/common/common_param_traits.cc |
+++ b/content/public/common/common_param_traits.cc |
@@ -193,16 +193,15 @@ void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { |
DCHECK_GE(p.width(), 0); |
DCHECK_GE(p.height(), 0); |
int values[2] = { p.width(), p.height() }; |
- m->WriteBytes(&values, sizeof(int) * 2); |
+ m->WritePODArray<2>(values); |
} |
bool ParamTraits<gfx::Size>::Read(const Message* m, |
PickleIterator* iter, |
gfx::Size* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(int) * 2)) |
+ const int* values; |
+ if (!m->ReadPODArray<2>(iter, &values)) |
return false; |
- const int* values = reinterpret_cast<const int*>(char_values); |
if (values[0] < 0 || values[1] < 0) |
return false; |
r->set_width(values[0]); |
@@ -216,16 +215,15 @@ void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { |
void ParamTraits<gfx::SizeF>::Write(Message* m, const gfx::SizeF& p) { |
float values[2] = { p.width(), p.height() }; |
- m->WriteBytes(&values, sizeof(float) * 2); |
+ m->WritePODArray<2>(values); |
} |
bool ParamTraits<gfx::SizeF>::Read(const Message* m, |
PickleIterator* iter, |
gfx::SizeF* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(float) * 2)) |
+ const float* values; |
+ if (!m->ReadPODArray<2>(iter, &values)) |
return false; |
- const float* values = reinterpret_cast<const float*>(char_values); |
r->set_width(values[0]); |
r->set_height(values[1]); |
return true; |
@@ -237,16 +235,15 @@ void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { |
void ParamTraits<gfx::Vector2d>::Write(Message* m, const gfx::Vector2d& p) { |
int values[2] = { p.x(), p.y() }; |
- m->WriteBytes(&values, sizeof(int) * 2); |
+ m->WritePODArray<2>(values); |
} |
bool ParamTraits<gfx::Vector2d>::Read(const Message* m, |
PickleIterator* iter, |
gfx::Vector2d* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(int) * 2)) |
+ const int* values; |
+ if (!m->ReadPODArray<2>(iter, &values)) |
return false; |
- const int* values = reinterpret_cast<const int*>(char_values); |
r->set_x(values[0]); |
r->set_y(values[1]); |
return true; |
@@ -258,16 +255,15 @@ void ParamTraits<gfx::Vector2d>::Log(const gfx::Vector2d& v, std::string* l) { |
void ParamTraits<gfx::Vector2dF>::Write(Message* m, const gfx::Vector2dF& p) { |
float values[2] = { p.x(), p.y() }; |
- m->WriteBytes(&values, sizeof(float) * 2); |
+ m->WritePODArray<2>(values); |
} |
bool ParamTraits<gfx::Vector2dF>::Read(const Message* m, |
PickleIterator* iter, |
gfx::Vector2dF* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(float) * 2)) |
+ const float* values; |
+ if (!m->ReadPODArray<2>(iter, &values)) |
return false; |
- const float* values = reinterpret_cast<const float*>(char_values); |
r->set_x(values[0]); |
r->set_y(values[1]); |
return true; |
@@ -279,16 +275,15 @@ void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) { |
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { |
int values[4] = { p.x(), p.y(), p.width(), p.height() }; |
- m->WriteBytes(&values, sizeof(int) * 4); |
+ m->WritePODArray<4>(values); |
} |
bool ParamTraits<gfx::Rect>::Read(const Message* m, |
PickleIterator* iter, |
gfx::Rect* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(int) * 4)) |
+ const int* values; |
+ if (!m->ReadPODArray<4>(iter, &values)) |
return false; |
- const int* values = reinterpret_cast<const int*>(char_values); |
if (values[2] < 0 || values[3] < 0) |
return false; |
r->SetRect(values[0], values[1], values[2], values[3]); |
@@ -302,16 +297,15 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { |
void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) { |
float values[4] = { p.x(), p.y(), p.width(), p.height() }; |
- m->WriteBytes(&values, sizeof(float) * 4); |
+ m->WritePODArray<4>(values); |
} |
bool ParamTraits<gfx::RectF>::Read(const Message* m, |
PickleIterator* iter, |
gfx::RectF* r) { |
- const char* char_values; |
- if (!m->ReadBytes(iter, &char_values, sizeof(float) * 4)) |
+ const float* values; |
+ if (!m->ReadPODArray<4>(iter, &values)) |
return false; |
- const float* values = reinterpret_cast<const float*>(char_values); |
r->SetRect(values[0], values[1], values[2], values[3]); |
return true; |
} |