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

Side by Side Diff: ui/aura/mus/property_converter.h

Issue 2889443002: mash: Add type names to PropertyConverter::Register*Property. (Closed)
Patch Set: Rename to RegisterImageSkiaProperty, update test identifiers. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_MUS_PROPERTY_CONVERTER_H_ 5 #ifndef UI_AURA_MUS_PROPERTY_CONVERTER_H_
6 #define UI_AURA_MUS_PROPERTY_CONVERTER_H_ 6 #define UI_AURA_MUS_PROPERTY_CONVERTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // value of false indicates the value isn't known or the property type isn't 71 // value of false indicates the value isn't known or the property type isn't
72 // primitive. 72 // primitive.
73 bool GetPropertyValueFromTransportValue( 73 bool GetPropertyValueFromTransportValue(
74 const std::string& transport_name, 74 const std::string& transport_name,
75 const std::vector<uint8_t>& transport_data, 75 const std::vector<uint8_t>& transport_data,
76 PrimitiveType* value); 76 PrimitiveType* value);
77 77
78 // Register a property to support conversion between mus and aura. 78 // Register a property to support conversion between mus and aura.
79 // |validator| is a callback used to validate incoming values from 79 // |validator| is a callback used to validate incoming values from
80 // transport_data; if it returns false, the value is rejected. 80 // transport_data; if it returns false, the value is rejected.
81 // TODO(msw): Include type names in RegisterProperty function names.
82 template <typename T> 81 template <typename T>
83 void RegisterProperty( 82 void RegisterPrimitiveProperty(
84 const WindowProperty<T>* property, 83 const WindowProperty<T>* property,
85 const char* transport_name, 84 const char* transport_name,
86 const base::RepeatingCallback<bool(int64_t)>& validator) { 85 const base::RepeatingCallback<bool(int64_t)>& validator) {
87 PrimitiveProperty primitive_property; 86 PrimitiveProperty primitive_property;
88 primitive_property.property_name = property->name; 87 primitive_property.property_name = property->name;
89 primitive_property.transport_name = transport_name; 88 primitive_property.transport_name = transport_name;
90 primitive_property.default_value = 89 primitive_property.default_value =
91 ui::ClassPropertyCaster<T>::ToInt64(property->default_value); 90 ui::ClassPropertyCaster<T>::ToInt64(property->default_value);
92 primitive_property.validator = validator; 91 primitive_property.validator = validator;
93 primitive_properties_[property] = primitive_property; 92 primitive_properties_[property] = primitive_property;
94 transport_names_.insert(transport_name); 93 transport_names_.insert(transport_name);
95 } 94 }
96 95
97 // Register owned properties to support conversion between mus and aura. 96 // Register owned properties to support conversion between mus and aura.
98 // TODO(msw): Include type names in RegisterProperty function names. 97 void RegisterImageSkiaProperty(
99 void RegisterProperty(const WindowProperty<gfx::ImageSkia*>* property, 98 const WindowProperty<gfx::ImageSkia*>* property,
100 const char* transport_name); 99 const char* transport_name);
101 void RegisterProperty(const WindowProperty<gfx::Rect*>* property, 100 void RegisterRectProperty(const WindowProperty<gfx::Rect*>* property,
102 const char* transport_name); 101 const char* transport_name);
103 void RegisterProperty(const WindowProperty<gfx::Size*>* property, 102 void RegisterSizeProperty(const WindowProperty<gfx::Size*>* property,
104 const char* transport_name); 103 const char* transport_name);
105 void RegisterProperty(const WindowProperty<std::string*>* property, 104 void RegisterStringProperty(const WindowProperty<std::string*>* property,
106 const char* transport_name); 105 const char* transport_name);
107 void RegisterProperty(const WindowProperty<base::string16*>* property, 106 void RegisterString16Property(const WindowProperty<base::string16*>* property,
108 const char* transport_name); 107 const char* transport_name);
109 108
110 private: 109 private:
111 // Contains data needed to store and convert primitive-type properties. 110 // Contains data needed to store and convert primitive-type properties.
112 struct AURA_EXPORT PrimitiveProperty { 111 struct AURA_EXPORT PrimitiveProperty {
113 PrimitiveProperty(); 112 PrimitiveProperty();
114 PrimitiveProperty(const PrimitiveProperty& property); 113 PrimitiveProperty(const PrimitiveProperty& property);
115 ~PrimitiveProperty(); 114 ~PrimitiveProperty();
116 115
117 // The aura::WindowProperty::name used for storage. 116 // The aura::WindowProperty::name used for storage.
118 const char* property_name = nullptr; 117 const char* property_name = nullptr;
(...skipping 21 matching lines...) Expand all
140 139
141 // Set of transport names supplied to RegisterProperty(). 140 // Set of transport names supplied to RegisterProperty().
142 std::set<std::string> transport_names_; 141 std::set<std::string> transport_names_;
143 142
144 DISALLOW_COPY_AND_ASSIGN(PropertyConverter); 143 DISALLOW_COPY_AND_ASSIGN(PropertyConverter);
145 }; 144 };
146 145
147 } // namespace aura 146 } // namespace aura
148 147
149 #endif // UI_AURA_MUS_PROPERTY_CONVERTER_H_ 148 #endif // UI_AURA_MUS_PROPERTY_CONVERTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc ('k') | ui/aura/mus/property_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698