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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 2015 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 "mojo/public/cpp/bindings/lib/message_validation.h"
6
7 #include <string>
8
9 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
10 #include "mojo/public/cpp/bindings/message.h"
11
12 namespace mojo {
13 namespace internal {
14
15 ValidationError ValidateMessageIsRequestWithoutResponse(const Message* message,
16 std::string* err) {
17 if (message->has_flag(kMessageIsResponse)) {
18 MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
19 << "message should be a request, not a response";
20 return ValidationError::MESSAGE_HEADER_INVALID_FLAGS;
21 }
22 if (message->has_flag(kMessageExpectsResponse)) {
23 MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
24 << "message should not expect a response";
25 return ValidationError::MESSAGE_HEADER_INVALID_FLAGS;
26 }
27 return ValidationError::NONE;
28 }
29
30 ValidationError ValidateMessageIsRequestExpectingResponse(
31 const Message* message,
32 std::string* err) {
33 if (message->has_flag(kMessageIsResponse)) {
34 MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
35 << "message should be a request, not a response";
36 return ValidationError::MESSAGE_HEADER_INVALID_FLAGS;
37 }
38 if (!message->has_flag(kMessageExpectsResponse)) {
39 MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err)
40 << "message should expect a response";
41 return ValidationError::MESSAGE_HEADER_INVALID_FLAGS;
42 }
43 return ValidationError::NONE;
44 }
45
46 ValidationError ValidateMessageIsResponse(const Message* message,
47 std::string* err) {
48 if (message->has_flag(kMessageExpectsResponse) ||
49 !message->has_flag(kMessageIsResponse)) {
50 MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err) << "message should be a response";
51 return ValidationError::MESSAGE_HEADER_INVALID_FLAGS;
52 }
53 return ValidationError::NONE;
54 }
55
56 } // namespace internal
57 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message_validation.h ('k') | mojo/public/cpp/bindings/lib/message_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698