Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mojo/public/cpp/bindings/lib/connector.h" | 5 #include "mojo/public/cpp/bindings/lib/connector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/bindings/error_handler.h" | 9 #include "mojo/public/cpp/bindings/error_handler.h" |
| 10 #include "mojo/public/cpp/environment/logging.h" | 10 #include "mojo/public/cpp/environment/logging.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // to track their lifetime any longer. | 90 // to track their lifetime any longer. |
| 91 message->mutable_handles()->clear(); | 91 message->mutable_handles()->clear(); |
| 92 break; | 92 break; |
| 93 case MOJO_RESULT_FAILED_PRECONDITION: | 93 case MOJO_RESULT_FAILED_PRECONDITION: |
| 94 // There's no point in continuing to write to this pipe since the other | 94 // There's no point in continuing to write to this pipe since the other |
| 95 // end is gone. Avoid writing any future messages. Hide write failures | 95 // end is gone. Avoid writing any future messages. Hide write failures |
| 96 // from the caller since we'd like them to continue consuming any backlog | 96 // from the caller since we'd like them to continue consuming any backlog |
| 97 // of incoming messages before regarding the message pipe as closed. | 97 // of incoming messages before regarding the message pipe as closed. |
| 98 drop_writes_ = true; | 98 drop_writes_ = true; |
| 99 break; | 99 break; |
| 100 case MOJO_RESULT_BUSY: | |
| 101 // We'd get a "busy" result if one of the message's handles is: | |
| 102 // - |message_pipe_|'s own handle; | |
| 103 // - simultaneously being used on another thread; or | |
| 104 // - in a "busy" state that prohibits it from being transferred (e.g., | |
| 105 // a data pipe handle in the middle of a two-phase read/write, | |
| 106 // regardless of which thread that two-phase read/write is happening | |
| 107 // on). | |
| 108 // TODO(vtl): I wonder if this should be a |MOJO_DCHECK()|. | |
| 109 MOJO_CHECK(false) << "Not reached: race condition or other bug"; | |
|
yzshen1
2014/07/18 22:08:08
nit: other bug*s*. :)
| |
| 110 return false; | |
| 100 default: | 111 default: |
| 101 // This particular write was rejected, presumably because of bad input. | 112 // This particular write was rejected, presumably because of bad input. |
| 102 // The pipe is not necessarily in a bad state. | 113 // The pipe is not necessarily in a bad state. |
| 103 return false; | 114 return false; |
| 104 } | 115 } |
| 105 return true; | 116 return true; |
| 106 } | 117 } |
| 107 | 118 |
| 108 // static | 119 // static |
| 109 void Connector::CallOnHandleReady(void* closure, MojoResult result) { | 120 void Connector::CallOnHandleReady(void* closure, MojoResult result) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 // should end early. | 194 // should end early. |
| 184 if (destroyed_flag_) { | 195 if (destroyed_flag_) { |
| 185 *destroyed_flag_ = true; // Propagate flag. | 196 *destroyed_flag_ = true; // Propagate flag. |
| 186 } | 197 } |
| 187 if (error_handler_) | 198 if (error_handler_) |
| 188 error_handler_->OnConnectionError(); | 199 error_handler_->OnConnectionError(); |
| 189 } | 200 } |
| 190 | 201 |
| 191 } // namespace internal | 202 } // namespace internal |
| 192 } // namespace mojo | 203 } // namespace mojo |
| OLD | NEW |