OLD | NEW |
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 #ifndef CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ | 5 #ifndef CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ |
6 #define CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ | 6 #define CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/optional.h" | 12 #include "base/optional.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "content/public/common/presentation_connection_message.h" | 14 #include "content/public/common/presentation_connection_message.h" |
15 #include "content/public/common/presentation_session.h" | 15 #include "content/public/common/presentation_info.h" |
16 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m
ojom.h" | 16 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m
ojom.h" |
17 #include "url/mojo/url.mojom.h" | 17 #include "url/mojo/url.mojom.h" |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 | 20 |
21 template <> | 21 template <> |
22 struct EnumTraits<blink::mojom::PresentationErrorType, | 22 struct EnumTraits<blink::mojom::PresentationErrorType, |
23 content::PresentationErrorType> { | 23 content::PresentationErrorType> { |
24 static blink::mojom::PresentationErrorType ToMojom( | 24 static blink::mojom::PresentationErrorType ToMojom( |
25 content::PresentationErrorType input) { | 25 content::PresentationErrorType input) { |
26 switch (input) { | 26 switch (input) { |
27 case content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS: | 27 case content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS: |
28 return blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS; | 28 return blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS; |
29 case content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED: | 29 case content::PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED: |
30 return blink::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED; | 30 return blink::mojom::PresentationErrorType:: |
| 31 PRESENTATION_REQUEST_CANCELLED; |
31 case content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND: | 32 case content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND: |
32 return blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND; | 33 return blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND; |
33 case content::PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS: | 34 case content::PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS: |
34 return blink::mojom::PresentationErrorType::PREVIOUS_START_IN_PROGRESS; | 35 return blink::mojom::PresentationErrorType::PREVIOUS_START_IN_PROGRESS; |
35 case content::PRESENTATION_ERROR_UNKNOWN: | 36 case content::PRESENTATION_ERROR_UNKNOWN: |
36 return blink::mojom::PresentationErrorType::UNKNOWN; | 37 return blink::mojom::PresentationErrorType::UNKNOWN; |
37 } | 38 } |
38 NOTREACHED() << "Unknown content::PresentationErrorType " | 39 NOTREACHED() << "Unknown content::PresentationErrorType " |
39 << static_cast<int>(input); | 40 << static_cast<int>(input); |
40 return blink::mojom::PresentationErrorType::UNKNOWN; | 41 return blink::mojom::PresentationErrorType::UNKNOWN; |
41 } | 42 } |
42 | 43 |
43 static bool FromMojom(blink::mojom::PresentationErrorType input, | 44 static bool FromMojom(blink::mojom::PresentationErrorType input, |
44 content::PresentationErrorType* output) { | 45 content::PresentationErrorType* output) { |
45 switch (input) { | 46 switch (input) { |
46 case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS: | 47 case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS: |
47 *output = content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS; | 48 *output = content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS; |
48 return true; | 49 return true; |
49 case blink::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED: | 50 case blink::mojom::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED: |
50 *output = content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED; | 51 *output = content::PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED; |
51 return true; | 52 return true; |
52 case blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND: | 53 case blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND: |
53 *output = content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND; | 54 *output = content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND; |
54 return true; | 55 return true; |
55 case blink::mojom::PresentationErrorType::PREVIOUS_START_IN_PROGRESS: | 56 case blink::mojom::PresentationErrorType::PREVIOUS_START_IN_PROGRESS: |
56 *output = content::PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS; | 57 *output = content::PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS; |
57 return true; | 58 return true; |
58 case blink::mojom::PresentationErrorType::UNKNOWN: | 59 case blink::mojom::PresentationErrorType::UNKNOWN: |
59 *output = content::PRESENTATION_ERROR_UNKNOWN; | 60 *output = content::PRESENTATION_ERROR_UNKNOWN; |
60 return true; | 61 return true; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return true; | 135 return true; |
135 case blink::mojom::PresentationConnectionCloseReason::WENT_AWAY: | 136 case blink::mojom::PresentationConnectionCloseReason::WENT_AWAY: |
136 *output = content::PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; | 137 *output = content::PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; |
137 return true; | 138 return true; |
138 } | 139 } |
139 return false; | 140 return false; |
140 } | 141 } |
141 }; | 142 }; |
142 | 143 |
143 template <> | 144 template <> |
144 struct StructTraits<blink::mojom::PresentationSessionInfoDataView, | 145 struct StructTraits<blink::mojom::PresentationInfoDataView, |
145 content::PresentationSessionInfo> { | 146 content::PresentationInfo> { |
146 static const GURL& url(const content::PresentationSessionInfo& session_info) { | 147 static const GURL& url(const content::PresentationInfo& presentation_info) { |
147 return session_info.presentation_url; | 148 return presentation_info.presentation_url; |
148 } | 149 } |
149 | 150 |
150 static const std::string& id( | 151 static const std::string& id( |
151 const content::PresentationSessionInfo& session_info) { | 152 const content::PresentationInfo& presentation_info) { |
152 return session_info.presentation_id; | 153 return presentation_info.presentation_id; |
153 } | 154 } |
154 | 155 |
155 static bool Read(blink::mojom::PresentationSessionInfoDataView data, | 156 static bool Read(blink::mojom::PresentationInfoDataView data, |
156 content::PresentationSessionInfo* out); | 157 content::PresentationInfo* out); |
157 }; | 158 }; |
158 | 159 |
159 template <> | 160 template <> |
160 struct StructTraits<blink::mojom::PresentationErrorDataView, | 161 struct StructTraits<blink::mojom::PresentationErrorDataView, |
161 content::PresentationError> { | 162 content::PresentationError> { |
162 static content::PresentationErrorType error_type( | 163 static content::PresentationErrorType error_type( |
163 const content::PresentationError& error) { | 164 const content::PresentationError& error) { |
164 return error.error_type; | 165 return error.error_type; |
165 } | 166 } |
166 | 167 |
(...skipping 28 matching lines...) Expand all Loading... |
195 return message.data.value(); | 196 return message.data.value(); |
196 } | 197 } |
197 | 198 |
198 static bool Read(blink::mojom::PresentationConnectionMessageDataView data, | 199 static bool Read(blink::mojom::PresentationConnectionMessageDataView data, |
199 content::PresentationConnectionMessage* out); | 200 content::PresentationConnectionMessage* out); |
200 }; | 201 }; |
201 | 202 |
202 } // namespace mojo | 203 } // namespace mojo |
203 | 204 |
204 #endif // CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ | 205 #endif // CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_ |
OLD | NEW |