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

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

Issue 2889443002: mash: Add type names to PropertyConverter::Register*Property. (Closed)
Patch Set: Alphabetize calls by function name. 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 RegisterImageProperty(const WindowProperty<gfx::ImageSkia*>* property,
sky 2017/05/16 12:21:34 We also have a gfx::Image class, so I'm inclined t
msw 2017/05/16 16:10:00 Done.
99 void RegisterProperty(const WindowProperty<gfx::ImageSkia*>* property, 98 const char* transport_name);
100 const char* transport_name); 99 void RegisterRectProperty(const WindowProperty<gfx::Rect*>* property,
101 void RegisterProperty(const WindowProperty<gfx::Rect*>* property, 100 const char* transport_name);
102 const char* transport_name); 101 void RegisterSizeProperty(const WindowProperty<gfx::Size*>* property,
103 void RegisterProperty(const WindowProperty<gfx::Size*>* property, 102 const char* transport_name);
104 const char* transport_name); 103 void RegisterStringProperty(const WindowProperty<std::string*>* property,
105 void RegisterProperty(const WindowProperty<std::string*>* property, 104 const char* transport_name);
106 const char* transport_name); 105 void RegisterString16Property(const WindowProperty<base::string16*>* property,
107 void RegisterProperty(const WindowProperty<base::string16*>* property, 106 const char* transport_name);
108 const char* transport_name);
109 107
110 private: 108 private:
111 // Contains data needed to store and convert primitive-type properties. 109 // Contains data needed to store and convert primitive-type properties.
112 struct AURA_EXPORT PrimitiveProperty { 110 struct AURA_EXPORT PrimitiveProperty {
113 PrimitiveProperty(); 111 PrimitiveProperty();
114 PrimitiveProperty(const PrimitiveProperty& property); 112 PrimitiveProperty(const PrimitiveProperty& property);
115 ~PrimitiveProperty(); 113 ~PrimitiveProperty();
116 114
117 // The aura::WindowProperty::name used for storage. 115 // The aura::WindowProperty::name used for storage.
118 const char* property_name = nullptr; 116 const char* property_name = nullptr;
(...skipping 21 matching lines...) Expand all
140 138
141 // Set of transport names supplied to RegisterProperty(). 139 // Set of transport names supplied to RegisterProperty().
142 std::set<std::string> transport_names_; 140 std::set<std::string> transport_names_;
143 141
144 DISALLOW_COPY_AND_ASSIGN(PropertyConverter); 142 DISALLOW_COPY_AND_ASSIGN(PropertyConverter);
145 }; 143 };
146 144
147 } // namespace aura 145 } // namespace aura
148 146
149 #endif // UI_AURA_MUS_PROPERTY_CONVERTER_H_ 147 #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