| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "mojo/public/cpp/bindings/associated_group.h" | 17 #include "mojo/public/cpp/bindings/associated_group.h" |
| 18 #include "mojo/public/cpp/bindings/lib/interface_endpoint_controller.h" | 18 #include "mojo/public/cpp/bindings/lib/interface_endpoint_controller.h" |
| 19 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 19 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
| 20 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" |
| 20 | 21 |
| 21 namespace mojo { | 22 namespace mojo { |
| 22 namespace internal { | 23 namespace internal { |
| 23 | 24 |
| 24 // ---------------------------------------------------------------------------- | 25 // ---------------------------------------------------------------------------- |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 void DCheckIfInvalid(const base::WeakPtr<InterfaceEndpointClient>& client, | 29 void DCheckIfInvalid(const base::WeakPtr<InterfaceEndpointClient>& client, |
| 29 const std::string& message) { | 30 const std::string& message) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 bool is_sync = message->has_flag(kMessageIsSync); | 223 bool is_sync = message->has_flag(kMessageIsSync); |
| 223 if (!controller_->SendMessage(message)) | 224 if (!controller_->SendMessage(message)) |
| 224 return false; | 225 return false; |
| 225 | 226 |
| 226 if (!is_sync) { | 227 if (!is_sync) { |
| 227 // We assume ownership of |responder|. | 228 // We assume ownership of |responder|. |
| 228 async_responders_[request_id] = base::WrapUnique(responder); | 229 async_responders_[request_id] = base::WrapUnique(responder); |
| 229 return true; | 230 return true; |
| 230 } | 231 } |
| 231 | 232 |
| 233 SyncCallRestrictions::AssertSyncCallAllowed(); |
| 234 |
| 232 bool response_received = false; | 235 bool response_received = false; |
| 233 std::unique_ptr<MessageReceiver> sync_responder(responder); | 236 std::unique_ptr<MessageReceiver> sync_responder(responder); |
| 234 sync_responses_.insert(std::make_pair( | 237 sync_responses_.insert(std::make_pair( |
| 235 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); | 238 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); |
| 236 | 239 |
| 237 base::WeakPtr<InterfaceEndpointClient> weak_self = | 240 base::WeakPtr<InterfaceEndpointClient> weak_self = |
| 238 weak_ptr_factory_.GetWeakPtr(); | 241 weak_ptr_factory_.GetWeakPtr(); |
| 239 controller_->SyncWatch(&response_received); | 242 controller_->SyncWatch(&response_received); |
| 240 // Make sure that this instance hasn't been destroyed. | 243 // Make sure that this instance hasn't been destroyed. |
| 241 if (weak_self) { | 244 if (weak_self) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } else { | 307 } else { |
| 305 if (!incoming_receiver_) | 308 if (!incoming_receiver_) |
| 306 return false; | 309 return false; |
| 307 | 310 |
| 308 return incoming_receiver_->Accept(message); | 311 return incoming_receiver_->Accept(message); |
| 309 } | 312 } |
| 310 } | 313 } |
| 311 | 314 |
| 312 } // namespace internal | 315 } // namespace internal |
| 313 } // namespace mojo | 316 } // namespace mojo |
| OLD | NEW |