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

Side by Side Diff: mojo/public/cpp/bindings/lib/validation_util.cc

Issue 2277853003: Use unions for interface control messages. (Closed)
Patch Set: Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/public/cpp/bindings/lib/validation_util.h" 5 #include "mojo/public/cpp/bindings/lib/validation_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ReportValidationError(validation_context, 96 ReportValidationError(validation_context,
97 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); 97 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS);
98 return false; 98 return false;
99 } 99 }
100 return true; 100 return true;
101 } 101 }
102 102
103 bool ValidateControlRequest(const Message* message, 103 bool ValidateControlRequest(const Message* message,
104 ValidationContext* validation_context) { 104 ValidationContext* validation_context) {
105 switch (message->header()->name) { 105 switch (message->header()->name) {
106 case kRunMessageId: 106 case interface_control::kRunMessageId:
107 return ValidateMessageIsRequestExpectingResponse(message, 107 return ValidateMessageIsRequestExpectingResponse(message,
108 validation_context) && 108 validation_context) &&
109 ValidateMessagePayload<RunMessageParams_Data>(message, 109 ValidateMessagePayload<
110 validation_context); 110 interface_control::internal::RunMessageParams_Data>(
111 case kRunOrClosePipeMessageId: 111 message, validation_context);
112 case interface_control::kRunOrClosePipeMessageId:
112 return ValidateMessageIsRequestWithoutResponse(message, 113 return ValidateMessageIsRequestWithoutResponse(message,
113 validation_context) && 114 validation_context) &&
114 ValidateMessagePayload<RunOrClosePipeMessageParams_Data>( 115 ValidateMessagePayload<
115 message, validation_context); 116 interface_control::internal::RunOrClosePipeMessageParams_Data>(
117 message, validation_context);
116 } 118 }
117 return false; 119 return false;
118 } 120 }
119 121
120 bool ValidateControlResponse(const Message* message, 122 bool ValidateControlResponse(const Message* message,
121 ValidationContext* validation_context) { 123 ValidationContext* validation_context) {
122 if (!ValidateMessageIsResponse(message, validation_context)) 124 if (!ValidateMessageIsResponse(message, validation_context))
123 return false; 125 return false;
124 switch (message->header()->name) { 126 switch (message->header()->name) {
125 case kRunMessageId: 127 case interface_control::kRunMessageId:
126 return ValidateMessagePayload<RunResponseMessageParams_Data>( 128 return ValidateMessagePayload<
129 interface_control::internal::RunResponseMessageParams_Data>(
127 message, validation_context); 130 message, validation_context);
128 } 131 }
129 return false; 132 return false;
130 } 133 }
131 134
132 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) { 135 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) {
133 return IsValidInterfaceId(input.interface_id); 136 return IsValidInterfaceId(input.interface_id);
134 } 137 }
135 138
136 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) { 139 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ValidationContext* validation_context) { 233 ValidationContext* validation_context) {
231 if (validation_context->ClaimHandle(input)) 234 if (validation_context->ClaimHandle(input))
232 return true; 235 return true;
233 236
234 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); 237 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE);
235 return false; 238 return false;
236 } 239 }
237 240
238 } // namespace internal 241 } // namespace internal
239 } // namespace mojo 242 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698