| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ |
| 6 #define MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ | 6 #define MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_piece.h" |
| 11 #include "mojo/public/c/system/message_pipe.h" | 12 #include "mojo/public/c/system/message_pipe.h" |
| 12 #include "mojo/public/cpp/system/handle.h" | 13 #include "mojo/public/cpp/system/handle.h" |
| 13 | 14 |
| 14 namespace mojo { | 15 namespace mojo { |
| 15 | 16 |
| 16 const MojoMessageHandle kInvalidMessageHandleValue = | 17 const MojoMessageHandle kInvalidMessageHandleValue = |
| 17 MOJO_MESSAGE_HANDLE_INVALID; | 18 MOJO_MESSAGE_HANDLE_INVALID; |
| 18 | 19 |
| 19 // Handle wrapper base class for a |MojoMessageHandle|. | 20 // Handle wrapper base class for a |MojoMessageHandle|. |
| 20 class MessageHandle { | 21 class MessageHandle { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 65 |
| 65 handle->reset(MessageHandle(raw_handle)); | 66 handle->reset(MessageHandle(raw_handle)); |
| 66 return MOJO_RESULT_OK; | 67 return MOJO_RESULT_OK; |
| 67 } | 68 } |
| 68 | 69 |
| 69 inline MojoResult GetMessageBuffer(MessageHandle message, void** buffer) { | 70 inline MojoResult GetMessageBuffer(MessageHandle message, void** buffer) { |
| 70 DCHECK(message.is_valid()); | 71 DCHECK(message.is_valid()); |
| 71 return MojoGetMessageBuffer(message.value(), buffer); | 72 return MojoGetMessageBuffer(message.value(), buffer); |
| 72 } | 73 } |
| 73 | 74 |
| 75 inline MojoResult NotifyBadMessage(MessageHandle message, |
| 76 const base::StringPiece& error) { |
| 77 DCHECK(message.is_valid()); |
| 78 return MojoNotifyBadMessage(message.value(), error.data(), error.size()); |
| 79 } |
| 80 |
| 74 } // namespace mojo | 81 } // namespace mojo |
| 75 | 82 |
| 76 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ | 83 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_H_ |
| OLD | NEW |