diff options
author | kmarshall <kmarshall@chromium.org> | 2015-08-07 15:04:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 22:05:34 +0000 |
commit | 2578049d4925cc271160f3b17ae0e834d448c54d (patch) | |
tree | 4422625bdbae01abd62c45c77e0c897374cbfa9b /extensions/common | |
parent | 51bd366b4a9e8cad8fdf4717db9b5ecc371381f2 (diff) | |
download | chromium_src-2578049d4925cc271160f3b17ae0e834d448c54d.zip chromium_src-2578049d4925cc271160f3b17ae0e834d448c54d.tar.gz chromium_src-2578049d4925cc271160f3b17ae0e834d448c54d.tar.bz2 |
Improve clarity and robustness of CastSocket state machines.
This CL makes explicit checks to ensure that each state on the
state machine explicitly transitions to another state. Terminal states
are given their own specific identifiers.
The previous impl used *_NONE to indicate a terminal state,
but this could be conflated with potential bugs in the state machine
that failed to emit a new state.
Add error handlers to unexpected states in the state machine.
Previous impl caught this with NOTIMPLEMENTED(), which had no effect
for release builds and caused to undefined behavior.
Added check to DoConnectCallback to prevent it from executing the
connection callback twice.
Reduce test noise by adding GMock expectations for all mocked calls.
R=mfoltz@chromium.org
CC=wez@chromium.org
BUG=
Review URL: https://codereview.chromium.org/1259963004
Cr-Commit-Position: refs/heads/master@{#342453}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/api/cast_channel/logging.proto | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/extensions/common/api/cast_channel/logging.proto b/extensions/common/api/cast_channel/logging.proto index a284563..a629aee 100644 --- a/extensions/common/api/cast_channel/logging.proto +++ b/extensions/common/api/cast_channel/logging.proto @@ -59,7 +59,7 @@ enum ReadyState { } enum ConnectionState { - CONN_STATE_NONE = 1; + CONN_STATE_UNKNOWN = 1; CONN_STATE_TCP_CONNECT = 2; CONN_STATE_TCP_CONNECT_COMPLETE = 3; CONN_STATE_SSL_CONNECT = 4; @@ -67,22 +67,33 @@ enum ConnectionState { CONN_STATE_AUTH_CHALLENGE_SEND = 6; CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE = 7; CONN_STATE_AUTH_CHALLENGE_REPLY_COMPLETE = 8; + CONN_STATE_START_CONNECT = 9; + + // Terminal states follow. + CONN_STATE_FINISHED = 100; + CONN_STATE_ERROR = 101; + CONN_STATE_TIMEOUT = 102; } enum ReadState { - READ_STATE_NONE = 1; + READ_STATE_UNKNOWN = 1; READ_STATE_READ = 2; READ_STATE_READ_COMPLETE = 3; READ_STATE_DO_CALLBACK = 4; - READ_STATE_ERROR = 5; + READ_STATE_HANDLE_ERROR = 5; + READ_STATE_ERROR = 100; // Terminal state. } enum WriteState { - WRITE_STATE_NONE = 1; + WRITE_STATE_UNKNOWN = 1; WRITE_STATE_WRITE = 2; WRITE_STATE_WRITE_COMPLETE = 3; WRITE_STATE_DO_CALLBACK = 4; - WRITE_STATE_ERROR = 5; + WRITE_STATE_HANDLE_ERROR = 5; + + // Terminal states follow. + WRITE_STATE_ERROR = 100; + WRITE_STATE_IDLE = 101; } enum ErrorState { |