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

Unified Diff: ui/aura/mus/property_converter.h

Issue 2499933003: Expand aura::PropertyConverter support. (Closed)
Patch Set: Fix the other new unit test. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/client/aura_constants.cc ('k') | ui/aura/mus/property_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/property_converter.h
diff --git a/ui/aura/mus/property_converter.h b/ui/aura/mus/property_converter.h
index 4fd2512dca5e5f44b0551ded7e3b195350fc934f..93187951142fb7eea5bc25761395470b15adc36e 100644
--- a/ui/aura/mus/property_converter.h
+++ b/ui/aura/mus/property_converter.h
@@ -7,16 +7,20 @@
#include <stdint.h>
+#include <map>
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/window.h"
-namespace aura {
+namespace gfx {
+class Rect;
+}
-class Window;
+namespace aura {
// PropertyConverter is used to convert Window properties for transport to the
// mus window server and back. Any time a property changes from one side it is
@@ -26,29 +30,54 @@ class Window;
class AURA_EXPORT PropertyConverter {
public:
PropertyConverter();
- virtual ~PropertyConverter();
+ ~PropertyConverter();
// Maps a property on the Window to a property pushed to the server. Return
// true if the property should be sent to the server, false if the property
// is only used locally.
- virtual bool ConvertPropertyForTransport(
+ bool ConvertPropertyForTransport(
Window* window,
const void* key,
std::string* transport_name,
std::unique_ptr<std::vector<uint8_t>>* transport_value);
// Returns the transport name for a Window property.
- virtual std::string GetTransportNameForPropertyKey(const void* key);
+ std::string GetTransportNameForPropertyKey(const void* key);
// Applies a value from the server to |window|. |transport_name| is the
// name of the property and |transport_data| the value. |transport_data| may
// be null.
- virtual void SetPropertyFromTransportValue(
+ void SetPropertyFromTransportValue(
Window* window,
const std::string& transport_name,
const std::vector<uint8_t>* transport_data);
+ // Register a property to support conversion between mus and aura.
+ template<typename T>
+ void RegisterProperty(const WindowProperty<T>* property,
+ const char* transport_name) {
+ primitive_properties_[property] =
+ PropertyNames(property->name, transport_name);
+ }
+
+ // Specializations for properties to pointer types supporting mojo conversion.
+ void RegisterProperty(const WindowProperty<gfx::Rect*>* property,
+ const char* transport_name);
+ void RegisterProperty(const WindowProperty<std::string*>* property,
+ const char* transport_name);
+
private:
+ // A pair with the aura::WindowProperty::name and the mus property name.
+ using PropertyNames = std::pair<const char*, const char*>;
+ // A map of aura::WindowProperty<T> to its aura and mus property names.
+ // This supports the internal codepaths for primitive types, eg. T=bool.
+ std::map<const void*, PropertyNames> primitive_properties_;
+
+ // Maps of aura::WindowProperty<T> to their mus property names.
+ // This supports types that can be serialized for Mojo, eg. T=std::string*.
+ std::map<const WindowProperty<gfx::Rect*>*, const char*> rect_properties_;
+ std::map<const WindowProperty<std::string*>*, const char*> string_properties_;
+
DISALLOW_COPY_AND_ASSIGN(PropertyConverter);
};
« no previous file with comments | « ui/aura/client/aura_constants.cc ('k') | ui/aura/mus/property_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698