Chromium Code Reviews| Index: ui/aura/mus/property_converter.cc |
| diff --git a/ui/aura/mus/property_converter.cc b/ui/aura/mus/property_converter.cc |
| index 15b80d13ba98cf9cec9884fe16d704a740c92ba2..2117f3716605cb55c2ea09adaec16dc870e712ab 100644 |
| --- a/ui/aura/mus/property_converter.cc |
| +++ b/ui/aura/mus/property_converter.cc |
| @@ -103,8 +103,9 @@ bool PropertyConverter::ConvertPropertyForTransport( |
| // Handle primitive property types generically. |
| DCHECK_GT(primitive_properties_.count(key), 0u); |
| + PrimitiveType default_value = primitive_properties_.at(key).default_value; |
|
sky
2017/01/18 04:03:09
primitive_properties_[key].default_value?
msw
2017/01/18 18:00:40
Done.
|
| // TODO(msw): Using the int64_t accessor is wasteful for smaller types. |
| - const PrimitiveType value = window->GetPropertyInternal(key, 0); |
| + const PrimitiveType value = window->GetPropertyInternal(key, default_value); |
| *transport_value = base::MakeUnique<std::vector<uint8_t>>( |
| mojo::ConvertTo<std::vector<uint8_t>>(value)); |
| return true; |
| @@ -112,7 +113,7 @@ bool PropertyConverter::ConvertPropertyForTransport( |
| std::string PropertyConverter::GetTransportNameForPropertyKey(const void* key) { |
| if (primitive_properties_.count(key) > 0) |
| - return primitive_properties_[key].second; |
| + return primitive_properties_.at(key).transport_name; |
|
sky
2017/01/18 04:03:09
Same comment about using [].
msw
2017/01/18 18:00:40
Done.
|
| auto image_key = static_cast<const WindowProperty<gfx::ImageSkia*>*>(key); |
| if (image_properties_.count(image_key) > 0) |
| @@ -142,7 +143,7 @@ void PropertyConverter::SetPropertyFromTransportValue( |
| const std::string& transport_name, |
| const std::vector<uint8_t>* data) { |
| for (const auto& primitive_property : primitive_properties_) { |
| - if (primitive_property.second.second == transport_name) { |
| + if (primitive_property.second.transport_name == transport_name) { |
| // aura::Window only supports property types that fit in PrimitiveType. |
| if (data->size() != 8u) { |
| DVLOG(2) << "Property size mismatch (PrimitiveType): " |
| @@ -151,9 +152,9 @@ void PropertyConverter::SetPropertyFromTransportValue( |
| } |
| const PrimitiveType value = mojo::ConvertTo<PrimitiveType>(*data); |
| // TODO(msw): Should aura::Window just store all properties by name? |
| - window->SetPropertyInternal(primitive_property.first, |
| - primitive_property.second.first, nullptr, |
| - value, 0); |
| + window->SetPropertyInternal( |
| + primitive_property.first, primitive_property.second.property_name, |
| + nullptr, value, primitive_property.second.default_value); |
| return; |
| } |
| } |
| @@ -224,7 +225,7 @@ bool PropertyConverter::GetPropertyValueFromTransportValue( |
| return false; |
| } |
| for (const auto& primitive_property : primitive_properties_) { |
| - if (primitive_property.second.second == transport_name) { |
| + if (primitive_property.second.transport_name == transport_name) { |
| *value = mojo::ConvertTo<PrimitiveType>(transport_data); |
| return true; |
| } |
| @@ -262,4 +263,12 @@ void PropertyConverter::RegisterProperty( |
| string16_properties_[property] = transport_name; |
| } |
| +PropertyConverter::PrimitiveProperty::PrimitiveProperty( |
| + const char* property_name, |
| + const char* transport_name, |
| + const PrimitiveType default_value) |
| + : property_name(property_name), |
| + transport_name(transport_name), |
| + default_value(default_value) {} |
| + |
| } // namespace aura |