| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 WriteMessageRaw(message_pipe_.get(), | 153 WriteMessageRaw(message_pipe_.get(), |
| 154 message->data(), | 154 message->data(), |
| 155 message->data_num_bytes(), | 155 message->data_num_bytes(), |
| 156 message->mutable_handles()->empty() | 156 message->mutable_handles()->empty() |
| 157 ? nullptr | 157 ? nullptr |
| 158 : reinterpret_cast<const MojoHandle*>( | 158 : reinterpret_cast<const MojoHandle*>( |
| 159 &message->mutable_handles()->front()), | 159 &message->mutable_handles()->front()), |
| 160 static_cast<uint32_t>(message->mutable_handles()->size()), | 160 static_cast<uint32_t>(message->mutable_handles()->size()), |
| 161 MOJO_WRITE_MESSAGE_FLAG_NONE); | 161 MOJO_WRITE_MESSAGE_FLAG_NONE); |
| 162 | 162 |
| 163 // The handles are always either transferred or closed, so we don't need the |
| 164 // message to track their lifetime any longer. |
| 165 message->mutable_handles()->clear(); |
| 166 |
| 163 switch (rv) { | 167 switch (rv) { |
| 164 case MOJO_RESULT_OK: | 168 case MOJO_RESULT_OK: |
| 165 // The handles were successfully transferred, so we don't need the message | |
| 166 // to track their lifetime any longer. | |
| 167 message->mutable_handles()->clear(); | |
| 168 break; | 169 break; |
| 169 case MOJO_RESULT_FAILED_PRECONDITION: | 170 case MOJO_RESULT_FAILED_PRECONDITION: |
| 170 // There's no point in continuing to write to this pipe since the other | 171 // There's no point in continuing to write to this pipe since the other |
| 171 // end is gone. Avoid writing any future messages. Hide write failures | 172 // end is gone. Avoid writing any future messages. Hide write failures |
| 172 // from the caller since we'd like them to continue consuming any backlog | 173 // from the caller since we'd like them to continue consuming any backlog |
| 173 // of incoming messages before regarding the message pipe as closed. | 174 // of incoming messages before regarding the message pipe as closed. |
| 174 drop_writes_ = true; | 175 drop_writes_ = true; |
| 175 break; | 176 break; |
| 176 case MOJO_RESULT_BUSY: | 177 case MOJO_RESULT_BUSY: |
| 177 // We'd get a "busy" result if one of the message's handles is: | 178 // We'd get a "busy" result if one of the message's handles is: |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (sync_watcher_) | 358 if (sync_watcher_) |
| 358 return; | 359 return; |
| 359 sync_watcher_.reset(new SyncHandleWatcher( | 360 sync_watcher_.reset(new SyncHandleWatcher( |
| 360 message_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE, | 361 message_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE, |
| 361 base::Bind(&Connector::OnSyncHandleWatcherHandleReady, | 362 base::Bind(&Connector::OnSyncHandleWatcherHandleReady, |
| 362 base::Unretained(this)))); | 363 base::Unretained(this)))); |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace internal | 366 } // namespace internal |
| 366 } // namespace mojo | 367 } // namespace mojo |
| OLD | NEW |