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

Side by Side Diff: ui/display/mojo/display_constants_struct_traits.cc

Issue 2732093006: Write mojom and EnumTraits for display::HDCPState. (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "ui/display/mojo/display_constants_struct_traits.h" 5 #include "ui/display/mojo/display_constants_struct_traits.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 display::mojom::DisplayConnectionType EnumTraits< 9 display::mojom::DisplayConnectionType EnumTraits<
10 display::mojom::DisplayConnectionType, 10 display::mojom::DisplayConnectionType,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 *out = display::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_NETWORK; 89 *out = display::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_NETWORK;
90 return true; 90 return true;
91 91
92 case display::mojom::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_VIRTUAL: 92 case display::mojom::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_VIRTUAL:
93 *out = display::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_VIRTUAL; 93 *out = display::DisplayConnectionType::DISPLAY_CONNECTION_TYPE_VIRTUAL;
94 return true; 94 return true;
95 } 95 }
96 return false; 96 return false;
97 } 97 }
98 98
99 // static
100 display::mojom::HDCPState
101 EnumTraits<display::mojom::HDCPState, display::HDCPState>::ToMojom(
102 display::HDCPState type) {
103 switch (type) {
104 case display::HDCPState::HDCP_STATE_UNDESIRED:
105 return display::mojom::HDCPState::HDCP_STATE_UNDESIRED;
106
Daniel Erat 2017/03/09 14:46:32 i know you're just being consistent with the exist
thanhph 2017/03/09 15:33:11 Done, I remove new lines between 2 switch cases in
107 case display::HDCPState::HDCP_STATE_DESIRED:
108 return display::mojom::HDCPState::HDCP_STATE_DESIRED;
109
110 case display::HDCPState::HDCP_STATE_ENABLED:
111 return display::mojom::HDCPState::HDCP_STATE_ENABLED;
112 }
113 NOTREACHED();
114 return display::mojom::HDCPState::HDCP_STATE_UNDESIRED;
115 }
116
117 // static
118 bool EnumTraits<display::mojom::HDCPState, display::HDCPState>::FromMojom(
119 display::mojom::HDCPState type,
120 display::HDCPState* out) {
121 switch (type) {
122 case display::mojom::HDCPState::HDCP_STATE_UNDESIRED:
123 *out = display::HDCPState::HDCP_STATE_UNDESIRED;
124 return true;
125
126 case display::mojom::HDCPState::HDCP_STATE_DESIRED:
127 *out = display::HDCPState::HDCP_STATE_DESIRED;
128 return true;
129
130 case display::mojom::HDCPState::HDCP_STATE_ENABLED:
131 *out = display::HDCPState::HDCP_STATE_ENABLED;
132 return true;
133 }
Daniel Erat 2017/03/09 14:46:32 nit: should this have a NOTREACHED() too?
thanhph 2017/03/09 15:33:12 The deserialization should fail if the code reache
134 return false;
135 }
136
99 } // namespace mojo 137 } // namespace mojo
OLDNEW
« no previous file with comments | « ui/display/mojo/display_constants_struct_traits.h ('k') | ui/display/mojo/display_struct_traits_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698