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

Side by Side Diff: content/common/push_messaging_param_traits.cc

Issue 2690203003: Convert push_messaging IPC msgs into mojo interfaces (Closed)
Patch Set: format push_messaging.mojom, less than 80 col Created 3 years, 10 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
(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
9 static_assert(content::PushRegistrationStatus::PUSH_REGISTRATION_STATUS_LAST ==
10 static_cast<content::PushRegistrationStatus>(
11 content::mojom::PushRegistrationStatus::LAST),
12 "PushRegistrationStatus enums must match");
13
14 static_assert(blink::WebPushError::ErrorType::ErrorTypeLast ==
15 static_cast<blink::WebPushError::ErrorType>(
16 content::mojom::PushErrorType::LAST),
17 "PushErrorType enums must match");
18
19 static_assert(
20 content::PushGetRegistrationStatus::PUSH_GETREGISTRATION_STATUS_LAST ==
21 static_cast<content::PushGetRegistrationStatus>(
22 content::mojom::PushGetRegistrationStatus::LAST),
23 "PushGetRegistrationStatus enums must match");
24
25 static_assert(blink::WebPushPermissionStatus::WebPushPermissionStatusLast ==
26 static_cast<blink::WebPushPermissionStatus>(
27 content::mojom::PushPermissionStatus::LAST),
28 "PushPermissionStatus enums must match");
29
30 // static
31 bool StructTraits<content::mojom::PushSubscriptionOptionsDataView,
32 content::PushSubscriptionOptions>::
33 Read(content::mojom::PushSubscriptionOptionsDataView data,
34 content::PushSubscriptionOptions* out) {
35 out->user_visible_only = data.user_visible_only();
36 if (!data.ReadSenderInfo(&out->sender_info))
37 return false;
38
39 return true;
40 }
41
42 // static
43 content::mojom::PushRegistrationStatus EnumTraits<
44 content::mojom::PushRegistrationStatus,
45 content::PushRegistrationStatus>::ToMojom(content::PushRegistrationStatus
46 input) {
47 CHECK(input >= content::PushRegistrationStatus::
Tom Sepez 2017/02/17 19:27:37 Which process calls this (and will be terminated i
Peter Beverloo 2017/02/17 19:40:43 Good point. These probably should be if-statements
ke.he 2017/02/18 01:59:57 Done.
48 PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE &&
49 input <=
50 content::PushRegistrationStatus::PUSH_REGISTRATION_STATUS_LAST);
51 return static_cast<content::mojom::PushRegistrationStatus>(input);
Tom Sepez 2017/02/17 19:27:37 Typically, there's a switch statement here explici
Peter Beverloo 2017/02/17 19:40:43 Unless you feel strongly, I highly prefer this ove
52 }
53
54 // static
55 bool EnumTraits<content::mojom::PushRegistrationStatus,
56 content::PushRegistrationStatus>::
57 FromMojom(content::mojom::PushRegistrationStatus input,
58 content::PushRegistrationStatus* output) {
59 CHECK(input >=
60 content::mojom::PushRegistrationStatus::SUCCESS_FROM_PUSH_SERVICE &&
61 input <= content::mojom::PushRegistrationStatus::LAST);
62 *output = static_cast<content::PushRegistrationStatus>(input);
63 return true;
64 }
65
66 // static
67 content::mojom::PushErrorType
68 EnumTraits<content::mojom::PushErrorType, blink::WebPushError::ErrorType>::
69 ToMojom(blink::WebPushError::ErrorType input) {
70 CHECK(input >= blink::WebPushError::ErrorType::ErrorTypeAbort &&
71 input <= blink::WebPushError::ErrorType::ErrorTypeInvalidState);
72 return static_cast<content::mojom::PushErrorType>(input);
73 }
74
75 // static
76 bool EnumTraits<content::mojom::PushErrorType, blink::WebPushError::ErrorType>::
77 FromMojom(content::mojom::PushErrorType input,
78 blink::WebPushError::ErrorType* output) {
79 CHECK(input >= content::mojom::PushErrorType::ABORT &&
80 input <= content::mojom::PushErrorType::INVALID_STATE);
81 *output = static_cast<blink::WebPushError::ErrorType>(input);
82 return true;
83 }
84
85 // static
86 content::mojom::PushGetRegistrationStatus
87 EnumTraits<content::mojom::PushGetRegistrationStatus,
88 content::PushGetRegistrationStatus>::
89 ToMojom(content::PushGetRegistrationStatus input) {
90 CHECK(
91 input >= content::PushGetRegistrationStatus::
92 PUSH_GETREGISTRATION_STATUS_SUCCESS &&
93 input <=
94 content::PushGetRegistrationStatus::PUSH_GETREGISTRATION_STATUS_LAST);
95 return static_cast<content::mojom::PushGetRegistrationStatus>(input);
96 }
97
98 // static
99 bool EnumTraits<content::mojom::PushGetRegistrationStatus,
100 content::PushGetRegistrationStatus>::
101 FromMojom(content::mojom::PushGetRegistrationStatus input,
102 content::PushGetRegistrationStatus* output) {
103 CHECK(input >= content::mojom::PushGetRegistrationStatus::SUCCESS &&
104 input <= content::mojom::PushGetRegistrationStatus::LAST);
105 *output = static_cast<content::PushGetRegistrationStatus>(input);
106 return true;
107 }
108
109 // static
110 content::mojom::PushPermissionStatus EnumTraits<
111 content::mojom::PushPermissionStatus,
112 blink::WebPushPermissionStatus>::ToMojom(blink::WebPushPermissionStatus
113 input) {
114 CHECK(input >=
115 blink::WebPushPermissionStatus::WebPushPermissionStatusGranted &&
116 input <= blink::WebPushPermissionStatus::WebPushPermissionStatusLast);
117 return static_cast<content::mojom::PushPermissionStatus>(input);
118 }
119
120 // static
121 bool EnumTraits<content::mojom::PushPermissionStatus,
122 blink::WebPushPermissionStatus>::
123 FromMojom(content::mojom::PushPermissionStatus input,
124 blink::WebPushPermissionStatus* output) {
125 CHECK(input >= content::mojom::PushPermissionStatus::GRANTED &&
126 input <= content::mojom::PushPermissionStatus::LAST);
127 *output = static_cast<blink::WebPushPermissionStatus>(input);
128 return true;
129 }
130
131 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698