| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/interface_endpoint_client.h" | 5 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (encountered_error_) | 212 if (encountered_error_) |
| 213 return false; | 213 return false; |
| 214 | 214 |
| 215 // Reserve 0 in case we want it to convey special meaning in the future. | 215 // Reserve 0 in case we want it to convey special meaning in the future. |
| 216 uint64_t request_id = next_request_id_++; | 216 uint64_t request_id = next_request_id_++; |
| 217 if (request_id == 0) | 217 if (request_id == 0) |
| 218 request_id = next_request_id_++; | 218 request_id = next_request_id_++; |
| 219 | 219 |
| 220 message->set_request_id(request_id); | 220 message->set_request_id(request_id); |
| 221 | 221 |
| 222 bool is_sync = message->has_flag(kMessageIsSync); |
| 222 if (!controller_->SendMessage(message)) | 223 if (!controller_->SendMessage(message)) |
| 223 return false; | 224 return false; |
| 224 | 225 |
| 225 if (!message->has_flag(kMessageIsSync)) { | 226 if (!is_sync) { |
| 226 // We assume ownership of |responder|. | 227 // We assume ownership of |responder|. |
| 227 async_responders_[request_id] = base::WrapUnique(responder); | 228 async_responders_[request_id] = base::WrapUnique(responder); |
| 228 return true; | 229 return true; |
| 229 } | 230 } |
| 230 | 231 |
| 231 bool response_received = false; | 232 bool response_received = false; |
| 232 std::unique_ptr<MessageReceiver> sync_responder(responder); | 233 std::unique_ptr<MessageReceiver> sync_responder(responder); |
| 233 sync_responses_.insert(std::make_pair( | 234 sync_responses_.insert(std::make_pair( |
| 234 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); | 235 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); |
| 235 | 236 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } else { | 303 } else { |
| 303 if (!incoming_receiver_) | 304 if (!incoming_receiver_) |
| 304 return false; | 305 return false; |
| 305 | 306 |
| 306 return incoming_receiver_->Accept(message); | 307 return incoming_receiver_->Accept(message); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 310 } // namespace internal | 311 } // namespace internal |
| 311 } // namespace mojo | 312 } // namespace mojo |
| OLD | NEW |