OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/common/push_messaging_param_traits.h" | |
6 | |
7 namespace mojo { | |
8 | |
Peter Beverloo
2017/02/16 16:08:33
nit: I'd also static_assert() on the sizes.
stati
ke.he
2017/02/17 08:22:39
Oh, We did discuss on this before. Sorry I forgot
| |
9 // static | |
10 bool StructTraits<content::mojom::PushSubscriptionOptionsDataView, | |
11 content::PushSubscriptionOptions>:: | |
12 Read(content::mojom::PushSubscriptionOptionsDataView data, | |
13 content::PushSubscriptionOptions* out) { | |
14 out->user_visible_only = data.user_visible_only(); | |
15 if (!data.ReadSenderInfo(&out->sender_info)) | |
16 return false; | |
17 | |
18 return true; | |
19 } | |
20 | |
21 // static | |
22 content::mojom::PushRegistrationStatus EnumTraits< | |
23 content::mojom::PushRegistrationStatus, | |
24 content::PushRegistrationStatus>::ToMojom(content::PushRegistrationStatus | |
25 input) { | |
26 CHECK(input >= content::PushRegistrationStatus:: | |
27 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE && | |
28 input <= | |
29 content::PushRegistrationStatus::PUSH_REGISTRATION_STATUS_LAST); | |
30 return static_cast<content::mojom::PushRegistrationStatus>(input); | |
31 } | |
32 | |
33 // static | |
34 bool EnumTraits<content::mojom::PushRegistrationStatus, | |
35 content::PushRegistrationStatus>:: | |
36 FromMojom(content::mojom::PushRegistrationStatus input, | |
37 content::PushRegistrationStatus* output) { | |
38 CHECK(input >= | |
39 content::mojom::PushRegistrationStatus::SUCCESS_FROM_PUSH_SERVICE && | |
40 input <= content::mojom::PushRegistrationStatus::LAST); | |
41 *output = static_cast<content::PushRegistrationStatus>(input); | |
42 return true; | |
43 } | |
44 | |
45 // static | |
46 content::mojom::PushErrorType | |
47 EnumTraits<content::mojom::PushErrorType, blink::WebPushError::ErrorType>:: | |
48 ToMojom(blink::WebPushError::ErrorType input) { | |
49 CHECK(input >= blink::WebPushError::ErrorType::ErrorTypeAbort && | |
50 input <= blink::WebPushError::ErrorType::ErrorTypeInvalidState); | |
51 return static_cast<content::mojom::PushErrorType>(input); | |
52 } | |
53 | |
54 // static | |
55 bool EnumTraits<content::mojom::PushErrorType, blink::WebPushError::ErrorType>:: | |
56 FromMojom(content::mojom::PushErrorType input, | |
57 blink::WebPushError::ErrorType* output) { | |
58 CHECK(input >= content::mojom::PushErrorType::ABORT && | |
59 input <= content::mojom::PushErrorType::INVALID_STATE); | |
60 *output = static_cast<blink::WebPushError::ErrorType>(input); | |
61 return true; | |
62 } | |
63 | |
64 // static | |
65 content::mojom::PushGetRegistrationStatus | |
66 EnumTraits<content::mojom::PushGetRegistrationStatus, | |
67 content::PushGetRegistrationStatus>:: | |
68 ToMojom(content::PushGetRegistrationStatus input) { | |
69 CHECK( | |
70 input >= content::PushGetRegistrationStatus:: | |
71 PUSH_GETREGISTRATION_STATUS_SUCCESS && | |
72 input <= | |
73 content::PushGetRegistrationStatus::PUSH_GETREGISTRATION_STATUS_LAST); | |
74 return static_cast<content::mojom::PushGetRegistrationStatus>(input); | |
75 } | |
76 | |
77 // static | |
78 bool EnumTraits<content::mojom::PushGetRegistrationStatus, | |
79 content::PushGetRegistrationStatus>:: | |
80 FromMojom(content::mojom::PushGetRegistrationStatus input, | |
81 content::PushGetRegistrationStatus* output) { | |
82 CHECK(input >= content::mojom::PushGetRegistrationStatus::SUCCESS && | |
83 input <= content::mojom::PushGetRegistrationStatus::LAST); | |
84 *output = static_cast<content::PushGetRegistrationStatus>(input); | |
85 return true; | |
86 } | |
87 | |
88 // static | |
89 content::mojom::PushPermissionStatus EnumTraits< | |
90 content::mojom::PushPermissionStatus, | |
91 blink::WebPushPermissionStatus>::ToMojom(blink::WebPushPermissionStatus | |
92 input) { | |
93 CHECK(input >= | |
94 blink::WebPushPermissionStatus::WebPushPermissionStatusGranted && | |
95 input <= blink::WebPushPermissionStatus::WebPushPermissionStatusLast); | |
96 return static_cast<content::mojom::PushPermissionStatus>(input); | |
97 } | |
98 | |
99 // static | |
100 bool EnumTraits<content::mojom::PushPermissionStatus, | |
101 blink::WebPushPermissionStatus>:: | |
102 FromMojom(content::mojom::PushPermissionStatus input, | |
103 blink::WebPushPermissionStatus* output) { | |
104 CHECK(input >= content::mojom::PushPermissionStatus::GRANTED && | |
105 input <= content::mojom::PushPermissionStatus::LAST); | |
106 *output = static_cast<blink::WebPushPermissionStatus>(input); | |
107 return true; | |
108 } | |
109 | |
110 } // namespace mojo | |
OLD | NEW |