| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_header_validator.h" | 5 #include "mojo/public/cpp/bindings/message_header_validator.h" |
| 6 | 6 |
| 7 #include "mojo/public/cpp/bindings/lib/validation_context.h" | 7 #include "mojo/public/cpp/bindings/lib/validation_context.h" |
| 8 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 8 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| 9 #include "mojo/public/cpp/bindings/lib/validation_util.h" | 9 #include "mojo/public/cpp/bindings/lib/validation_util.h" |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 validation_context, | 58 validation_context, |
| 59 internal::VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); | 59 internal::VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 MessageHeaderValidator::MessageHeaderValidator(MessageReceiver* sink) | 68 MessageHeaderValidator::MessageHeaderValidator() |
| 69 : MessageHeaderValidator("MessageHeaderValidator", sink) {} | 69 : MessageHeaderValidator("MessageHeaderValidator") {} |
| 70 | 70 |
| 71 MessageHeaderValidator::MessageHeaderValidator(const std::string& description, | 71 MessageHeaderValidator::MessageHeaderValidator(const std::string& description) |
| 72 MessageReceiver* sink) | 72 : description_(description) { |
| 73 : MessageFilter(sink), description_(description) { | |
| 74 } | 73 } |
| 75 | 74 |
| 76 void MessageHeaderValidator::SetDescription(const std::string& description) { | 75 void MessageHeaderValidator::SetDescription(const std::string& description) { |
| 77 description_ = description; | 76 description_ = description; |
| 78 } | 77 } |
| 79 | 78 |
| 80 bool MessageHeaderValidator::Accept(Message* message) { | 79 bool MessageHeaderValidator::Accept(Message* message) { |
| 81 // Pass 0 as number of handles because we don't expect any in the header, even | 80 // Pass 0 as number of handles because we don't expect any in the header, even |
| 82 // if |message| contains handles. | 81 // if |message| contains handles. |
| 83 internal::ValidationContext validation_context( | 82 internal::ValidationContext validation_context( |
| 84 message->data(), message->data_num_bytes(), 0, message, description_); | 83 message->data(), message->data_num_bytes(), 0, message, description_); |
| 85 | 84 |
| 86 if (!internal::ValidateStructHeaderAndClaimMemory(message->data(), | 85 if (!internal::ValidateStructHeaderAndClaimMemory(message->data(), |
| 87 &validation_context)) | 86 &validation_context)) |
| 88 return false; | 87 return false; |
| 89 | 88 |
| 90 if (!IsValidMessageHeader(message->header(), &validation_context)) | 89 if (!IsValidMessageHeader(message->header(), &validation_context)) |
| 91 return false; | 90 return false; |
| 92 | 91 |
| 93 return sink_->Accept(message); | 92 return true; |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace mojo | 95 } // namespace mojo |
| OLD | NEW |