# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utility classes to handle sending and receiving messages.""" import struct import sys import weakref import mojo_bindings.serialization as serialization # pylint: disable=E0611,F0401 import mojo_system as system # The flag values for a message header. NO_FLAG = 0 MESSAGE_EXPECTS_RESPONSE_FLAG = 1 << 0 MESSAGE_IS_RESPONSE_FLAG = 1 << 1 class MessagingException(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) self.__traceback__ = sys.exc_info()[2] class MessageHeader(object): """The header of a mojo message.""" _SIMPLE_MESSAGE_VERSION = 0 _SIMPLE_MESSAGE_STRUCT = struct.Struct("