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

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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ReportValidationError(validation_context, 99 ReportValidationError(validation_context,
100 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); 100 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS);
101 return false; 101 return false;
102 } 102 }
103 return true; 103 return true;
104 } 104 }
105 105
106 bool ValidateControlRequest(const Message* message, 106 bool ValidateControlRequest(const Message* message,
107 ValidationContext* validation_context) { 107 ValidationContext* validation_context) {
108 switch (message->header()->name) { 108 switch (message->header()->name) {
109 case kRunMessageId: 109 case interface_control::kRunMessageId:
110 return ValidateMessageIsRequestExpectingResponse(message, 110 return ValidateMessageIsRequestExpectingResponse(message,
111 validation_context) && 111 validation_context) &&
112 ValidateMessagePayload<RunMessageParams_Data>(message, 112 ValidateMessagePayload<
113 validation_context); 113 interface_control::internal::RunMessageParams_Data>(
114 case kRunOrClosePipeMessageId: 114 message, validation_context);
115 case interface_control::kRunOrClosePipeMessageId:
115 return ValidateMessageIsRequestWithoutResponse(message, 116 return ValidateMessageIsRequestWithoutResponse(message,
116 validation_context) && 117 validation_context) &&
117 ValidateMessagePayload<RunOrClosePipeMessageParams_Data>( 118 ValidateMessagePayload<
118 message, validation_context); 119 interface_control::internal::RunOrClosePipeMessageParams_Data>(
120 message, validation_context);
119 } 121 }
120 return false; 122 return false;
121 } 123 }
122 124
123 bool ValidateControlResponse(const Message* message, 125 bool ValidateControlResponse(const Message* message,
124 ValidationContext* validation_context) { 126 ValidationContext* validation_context) {
125 if (!ValidateMessageIsResponse(message, validation_context)) 127 if (!ValidateMessageIsResponse(message, validation_context))
126 return false; 128 return false;
127 switch (message->header()->name) { 129 switch (message->header()->name) {
128 case kRunMessageId: 130 case interface_control::kRunMessageId:
129 return ValidateMessagePayload<RunResponseMessageParams_Data>( 131 return ValidateMessagePayload<
132 interface_control::internal::RunResponseMessageParams_Data>(
130 message, validation_context); 133 message, validation_context);
131 } 134 }
132 return false; 135 return false;
133 } 136 }
134 137
135 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) { 138 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) {
136 return IsValidInterfaceId(input.interface_id); 139 return IsValidInterfaceId(input.interface_id);
137 } 140 }
138 141
139 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) { 142 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ValidationContext* validation_context) { 236 ValidationContext* validation_context) {
234 if (validation_context->ClaimHandle(input)) 237 if (validation_context->ClaimHandle(input))
235 return true; 238 return true;
236 239
237 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); 240 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE);
238 return false; 241 return false;
239 } 242 }
240 243
241 } // namespace internal 244 } // namespace internal
242 } // namespace mojo 245 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698