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

Side by Side Diff: components/mus/public/cpp/window_property.h

Issue 1832133002: mus: Remove unnecessary const from property TypeConverter templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 4 years, 9 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
« no previous file with comments | « components/mus/public/cpp/tests/window_unittest.cc ('k') | mash/login/login.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 // This header should be included by code that defines WindowProperties. It 10 // This header should be included by code that defines WindowProperties. It
(...skipping 29 matching lines...) Expand all
40 // 40 //
41 // If a property type is not exported, use 41 // If a property type is not exported, use
42 // MUS_DECLARE_WINDOW_PROPERTY_TYPE(MyType) which is a shorthand for 42 // MUS_DECLARE_WINDOW_PROPERTY_TYPE(MyType) which is a shorthand for
43 // MUS_DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, MyType). 43 // MUS_DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, MyType).
44 44
45 namespace mus { 45 namespace mus {
46 46
47 template <typename T> 47 template <typename T>
48 void Window::SetSharedProperty(const std::string& name, const T& data) { 48 void Window::SetSharedProperty(const std::string& name, const T& data) {
49 const std::vector<uint8_t> bytes = 49 const std::vector<uint8_t> bytes =
50 mojo::TypeConverter<const std::vector<uint8_t>, T>::Convert(data); 50 mojo::TypeConverter<std::vector<uint8_t>, T>::Convert(data);
51 SetSharedPropertyInternal(name, &bytes); 51 SetSharedPropertyInternal(name, &bytes);
52 } 52 }
53 53
54 template <typename T> 54 template <typename T>
55 T Window::GetSharedProperty(const std::string& name) const { 55 T Window::GetSharedProperty(const std::string& name) const {
56 DCHECK(HasSharedProperty(name)); 56 DCHECK(HasSharedProperty(name));
57 auto it = properties_.find(name); 57 auto it = properties_.find(name);
58 return mojo::TypeConverter<T, const std::vector<uint8_t>>::Convert( 58 return mojo::TypeConverter<T, std::vector<uint8_t>>::Convert(it->second);
59 it->second);
60 } 59 }
61 60
62 namespace { 61 namespace {
63 62
64 // No single new-style cast works for every conversion to/from int64_t, so we 63 // No single new-style cast works for every conversion to/from int64_t, so we
65 // need this helper class. A third specialization is needed for bool because 64 // need this helper class. A third specialization is needed for bool because
66 // MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit 65 // MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit
67 // cast (!). 66 // cast (!).
68 template <typename T> 67 template <typename T>
69 class WindowPropertyCaster { 68 class WindowPropertyCaster {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void Deallocator##NAME(int64_t p) { \ 150 void Deallocator##NAME(int64_t p) { \
152 enum { type_must_be_complete = sizeof(TYPE) }; \ 151 enum { type_must_be_complete = sizeof(TYPE) }; \
153 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \ 152 delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \
154 } \ 153 } \
155 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ 154 const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \
156 &Deallocator##NAME}; \ 155 &Deallocator##NAME}; \
157 } \ 156 } \
158 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value; 157 const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value;
159 158
160 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_ 159 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
OLDNEW
« no previous file with comments | « components/mus/public/cpp/tests/window_unittest.cc ('k') | mash/login/login.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698