Index: third_party/grpc/src/python/grpcio/grpc/_adapter/_common.py |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py b/third_party/grpc/src/python/grpcio/grpc/_adapter/_common.py |
similarity index 51% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py |
copy to third_party/grpc/src/python/grpcio/grpc/_adapter/_common.py |
index 1b02d66267e294ce83977dac64f075981705647c..492849f4cbbdc0ac28074ccc0c5f28db37c9ea0d 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py |
+++ b/third_party/grpc/src/python/grpcio/grpc/_adapter/_common.py |
@@ -1,4 +1,4 @@ |
-# Copyright 2011, Google Inc. |
+# Copyright 2015, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,27 +27,50 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+"""State used by both invocation-side and service-side code.""" |
-import logging |
-_GOODBYE_MESSAGE = u'Goodbye' |
+import enum |
-def web_socket_do_extra_handshake(request): |
- pass # Always accept. |
+@enum.unique |
+class HighWrite(enum.Enum): |
+ """The possible categories of high-level write state.""" |
+ OPEN = 'OPEN' |
+ CLOSED = 'CLOSED' |
-def web_socket_transfer_data(request): |
- while True: |
- line = request.ws_stream.receive_message() |
- if line is None: |
- return |
- if isinstance(line, unicode): |
- request.ws_stream.send_message(line, binary=False) |
- if line == _GOODBYE_MESSAGE: |
- return |
- else: |
- request.ws_stream.send_message(line, binary=True) |
+class WriteState(object): |
+ """A description of the state of writing to an RPC. |
-def web_socket_passive_closing_handshake(request): |
- return request.ws_close_code, request.ws_close_reason |
+ Attributes: |
+ low: A side-specific value describing the low-level state of writing. |
+ high: A HighWrite value describing the high-level state of writing. |
+ pending: A list of bytestrings for the RPC waiting to be written to the |
+ other side of the RPC. |
+ """ |
+ |
+ def __init__(self, low, high, pending): |
+ self.low = low |
+ self.high = high |
+ self.pending = pending |
+ |
+ |
+class CommonRPCState(object): |
+ """A description of an RPC's state. |
+ |
+ Attributes: |
+ write: A WriteState describing the state of writing to the RPC. |
+ sequence_number: The lowest-unused sequence number for use in generating |
+ tickets locally describing the progress of the RPC. |
+ deserializer: The behavior to be used to deserialize payload bytestreams |
+ taken off the wire. |
+ serializer: The behavior to be used to serialize payloads to be sent on the |
+ wire. |
+ """ |
+ |
+ def __init__(self, write, sequence_number, deserializer, serializer): |
+ self.write = write |
+ self.sequence_number = sequence_number |
+ self.deserializer = deserializer |
+ self.serializer = serializer |