OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); | 74 VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); |
75 return false; | 75 return false; |
76 } | 76 } |
77 | 77 |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 bool ValidateMessageIsRequestWithoutResponse( | 81 bool ValidateMessageIsRequestWithoutResponse( |
82 const Message* message, | 82 const Message* message, |
83 ValidationContext* validation_context) { | 83 ValidationContext* validation_context) { |
84 if (message->has_flag(kMessageIsResponse) || | 84 if (message->has_flag(Message::kFlagIsResponse) || |
85 message->has_flag(kMessageExpectsResponse)) { | 85 message->has_flag(Message::kFlagExpectsResponse)) { |
86 ReportValidationError(validation_context, | 86 ReportValidationError(validation_context, |
87 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); | 87 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); |
88 return false; | 88 return false; |
89 } | 89 } |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 bool ValidateMessageIsRequestExpectingResponse( | 93 bool ValidateMessageIsRequestExpectingResponse( |
94 const Message* message, | 94 const Message* message, |
95 ValidationContext* validation_context) { | 95 ValidationContext* validation_context) { |
96 if (message->has_flag(kMessageIsResponse) || | 96 if (message->has_flag(Message::kFlagIsResponse) || |
97 !message->has_flag(kMessageExpectsResponse)) { | 97 !message->has_flag(Message::kFlagExpectsResponse)) { |
98 ReportValidationError(validation_context, | 98 ReportValidationError(validation_context, |
99 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); | 99 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); |
100 return false; | 100 return false; |
101 } | 101 } |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 bool ValidateMessageIsResponse(const Message* message, | 105 bool ValidateMessageIsResponse(const Message* message, |
106 ValidationContext* validation_context) { | 106 ValidationContext* validation_context) { |
107 if (message->has_flag(kMessageExpectsResponse) || | 107 if (message->has_flag(Message::kFlagExpectsResponse) || |
108 !message->has_flag(kMessageIsResponse)) { | 108 !message->has_flag(Message::kFlagIsResponse)) { |
109 ReportValidationError(validation_context, | 109 ReportValidationError(validation_context, |
110 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); | 110 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); |
111 return false; | 111 return false; |
112 } | 112 } |
113 return true; | 113 return true; |
114 } | 114 } |
115 | 115 |
116 bool ValidateControlRequest(const Message* message, | 116 bool ValidateControlRequest(const Message* message, |
117 ValidationContext* validation_context) { | 117 ValidationContext* validation_context) { |
118 switch (message->header()->name) { | 118 switch (message->header()->name) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 ValidationContext* validation_context) { | 243 ValidationContext* validation_context) { |
244 if (validation_context->ClaimHandle(input)) | 244 if (validation_context->ClaimHandle(input)) |
245 return true; | 245 return true; |
246 | 246 |
247 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); | 247 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); |
248 return false; | 248 return false; |
249 } | 249 } |
250 | 250 |
251 } // namespace internal | 251 } // namespace internal |
252 } // namespace mojo | 252 } // namespace mojo |
OLD | NEW |