Commit 4feba85f authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Improved FileDataPipeProducer errors part 2.

1. Returned more specific errors in OnHandleReady/TransferSomeBytes.
2. Described returned errors in header documentation.
3. Not mapping MOJO_RESULT_ALREADY_EXISTS as that will not be
   returned.

Bug: none
Change-Id: Icaa78bd347995c175cc50eb807d9a400d21e96e4
Reviewed-on: https://chromium-review.googlesource.com/809324Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522106}
parent b04d8e25
...@@ -32,8 +32,6 @@ MojoResult FileErrorToMojoResult(base::File::Error error) { ...@@ -32,8 +32,6 @@ MojoResult FileErrorToMojoResult(base::File::Error error) {
switch (error) { switch (error) {
case base::File::FILE_OK: case base::File::FILE_OK:
return MOJO_RESULT_OK; return MOJO_RESULT_OK;
case base::File::FILE_ERROR_EXISTS:
return MOJO_RESULT_ALREADY_EXISTS;
case base::File::FILE_ERROR_NOT_FOUND: case base::File::FILE_ERROR_NOT_FOUND:
return MOJO_RESULT_NOT_FOUND; return MOJO_RESULT_NOT_FOUND;
case base::File::FILE_ERROR_SECURITY: case base::File::FILE_ERROR_SECURITY:
...@@ -132,7 +130,7 @@ class FileDataPipeProducer::FileSequenceState ...@@ -132,7 +130,7 @@ class FileDataPipeProducer::FileSequenceState
if (result != MOJO_RESULT_OK) { if (result != MOJO_RESULT_OK) {
// Either the consumer pipe has been closed or something terrible // Either the consumer pipe has been closed or something terrible
// happened. In any case, we'll never be able to write more data. // happened. In any case, we'll never be able to write more data.
Finish(MOJO_RESULT_ABORTED); Finish(result);
return; return;
} }
...@@ -149,7 +147,7 @@ class FileDataPipeProducer::FileSequenceState ...@@ -149,7 +147,7 @@ class FileDataPipeProducer::FileSequenceState
if (result == MOJO_RESULT_SHOULD_WAIT) if (result == MOJO_RESULT_SHOULD_WAIT)
return; return;
if (result != MOJO_RESULT_OK) { if (result != MOJO_RESULT_OK) {
Finish(MOJO_RESULT_ABORTED); Finish(result);
return; return;
} }
......
...@@ -39,8 +39,14 @@ class MOJO_CPP_SYSTEM_EXPORT FileDataPipeProducer { ...@@ -39,8 +39,14 @@ class MOJO_CPP_SYSTEM_EXPORT FileDataPipeProducer {
// //
// If the write is successful |result| will be |MOJO_RESULT_OK|. Otherwise // If the write is successful |result| will be |MOJO_RESULT_OK|. Otherwise
// (e.g. if the producer detects the consumer is closed and the pipe has no // (e.g. if the producer detects the consumer is closed and the pipe has no
// remaining capacity, or if file reads fail for any reason) |result| will be // remaining capacity, or if file open/reads fail for any reason) |result|
// |MOJO_RESULT_ABORTED|. // will be one of the following:
//
// |MOJO_RESULT_ABORTED|
// |MOJO_RESULT_NOT_FOUND|
// |MOJO_RESULT_PERMISSION_DENIED|
// |MOJO_RESULT_RESOURCE_EXHAUSTED|
// |MOJO_RESULT_UNKNOWN|
// //
// Note that if the FileDataPipeProducer is destroyed before |callback| can be // Note that if the FileDataPipeProducer is destroyed before |callback| can be
// invoked, |callback| is *never* invoked, and the write will be permanently // invoked, |callback| is *never* invoked, and the write will be permanently
......
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