Commit 253ee7c5 authored by Erik Jensen's avatar Erik Jensen Committed by Commit Bot

Remove cancel message in favor of CANCELED error type.

Most code doesn't care to distinguish between an error and cancelation,
as both abort the transfer. The few places that do care (e.g., the code
that decides whether to show an error to the user) can explicitly check
the type. This also allows cancellation to be easily propagated through
the error path from the source, instead of requiring a secondary
cancellation path.

Bug: 679313
Change-Id: I3c90ff55e7a58043535244a9d92cfc9e6814a4e6
Reviewed-on: https://chromium-review.googlesource.com/c/1437657
Commit-Queue: Erik Jensen <rkjnsn@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626294}
parent 4ea3580d
...@@ -82,9 +82,10 @@ void FileTransferMessageHandler::OnIncomingMessage( ...@@ -82,9 +82,10 @@ void FileTransferMessageHandler::OnIncomingMessage(
Close(); Close();
break; break;
case protocol::FileTransfer::kError: case protocol::FileTransfer::kError:
LOG(ERROR) << "File transfer error from client: " << message.error(); if (message.error().type() !=
FALLTHROUGH; protocol::FileTransfer_Error_Type_CANCELED) {
case protocol::FileTransfer::kCancel: LOG(ERROR) << "File transfer error from client: " << message.error();
}
Cancel(); Cancel();
break; break;
default: default:
......
...@@ -33,27 +33,24 @@ message FileTransfer { ...@@ -33,27 +33,24 @@ message FileTransfer {
// Next Id: 1 // Next Id: 1
message Success {} message Success {}
// Bidirectional message canceling the transfer as the result of a user action // Bidirectional message aborting the transfer due to an error or user
// or otherwise not due to an error. When Cancel is received, no more messages // cancellation. This may be sent by the sender to signal a read error, by the
// relating to the transfer should be sent, but the canceling end should be // receiver to signal a write error, or by either side to signal any of the
// prepared to handle any messages that may already be on the wire. // myriad of other things that can go wrong while attempting to transfer a
// Next Id: 1 // file. When Error is received, no more messages relating to the transfer
message Cancel {} // should be sent, but the end sending the error should be prepared to handle
// any messages that may already be on the wire.
// Bidirectional message aborting the transfer due to an error. This may be
// sent by the sender to signal a read error, by the receiver to signal a
// write error, or by either side to signal any of the myriad of other things
// that can go wrong while attempting to transfer a file.
// Next Id: 6 // Next Id: 6
message Error { message Error {
enum Type { enum Type {
UNSPECIFIED = 0; UNSPECIFIED = 0;
UNEXPECTED_ERROR = 1; CANCELED = 1;
PROTOCOL_ERROR = 2; UNEXPECTED_ERROR = 2;
PERMISSION_DENIED = 3; PROTOCOL_ERROR = 3;
OUT_OF_DISK_SPACE = 4; PERMISSION_DENIED = 4;
IO_ERROR = 5; OUT_OF_DISK_SPACE = 5;
NOT_LOGGED_IN = 6; IO_ERROR = 6;
NOT_LOGGED_IN = 7;
} }
// An error category to be used to select a user-displayed error message. // An error category to be used to select a user-displayed error message.
...@@ -73,7 +70,6 @@ message FileTransfer { ...@@ -73,7 +70,6 @@ message FileTransfer {
Data data = 2; Data data = 2;
End end = 3; End end = 3;
Success success = 4; Success success = 4;
Cancel cancel = 5; Error error = 5;
Error error = 6;
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment