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 """Utility classes to handle sending and receiving messages.""" | 5 """Utility classes to handle sending and receiving messages.""" |
6 | 6 |
7 | 7 |
8 import struct | 8 import struct |
9 import weakref | 9 import weakref |
10 | 10 |
11 # pylint: disable=F0401 | |
12 import mojo.bindings.serialization as serialization | 11 import mojo.bindings.serialization as serialization |
| 12 |
| 13 # pylint: disable=E0611,F0401 |
13 import mojo.system as system | 14 import mojo.system as system |
14 | 15 |
15 | 16 |
16 # The flag values for a message header. | 17 # The flag values for a message header. |
17 NO_FLAG = 0 | 18 NO_FLAG = 0 |
18 MESSAGE_EXPECTS_RESPONSE_FLAG = 1 << 0 | 19 MESSAGE_EXPECTS_RESPONSE_FLAG = 1 << 0 |
19 MESSAGE_IS_RESPONSE_FLAG = 1 << 1 | 20 MESSAGE_IS_RESPONSE_FLAG = 1 << 1 |
20 | 21 |
21 | 22 |
22 class MessageHeader(object): | 23 class MessageHeader(object): |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 message_receiver.Accept(Message(bytearray(), [])) | 379 message_receiver.Accept(Message(bytearray(), [])) |
379 if result != system.RESULT_RESOURCE_EXHAUSTED: | 380 if result != system.RESULT_RESOURCE_EXHAUSTED: |
380 return result | 381 return result |
381 (result, data, _) = handle.ReadMessage(bytearray(sizes[0])) | 382 (result, data, _) = handle.ReadMessage(bytearray(sizes[0])) |
382 if result == system.RESULT_OK and message_receiver: | 383 if result == system.RESULT_OK and message_receiver: |
383 message_receiver.Accept(Message(data[0], data[1])) | 384 message_receiver.Accept(Message(data[0], data[1])) |
384 return result | 385 return result |
385 | 386 |
386 def _HasRequestId(flags): | 387 def _HasRequestId(flags): |
387 return flags & (MESSAGE_EXPECTS_RESPONSE_FLAG|MESSAGE_IS_RESPONSE_FLAG) != 0 | 388 return flags & (MESSAGE_EXPECTS_RESPONSE_FLAG|MESSAGE_IS_RESPONSE_FLAG) != 0 |
OLD | NEW |