OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/router.h" | 5 #include "mojo/public/cpp/bindings/lib/router.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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 async_responders_[request_id] = make_scoped_ptr(responder); | 155 async_responders_[request_id] = make_scoped_ptr(responder); |
156 return true; | 156 return true; |
157 } | 157 } |
158 | 158 |
159 bool response_received = false; | 159 bool response_received = false; |
160 scoped_ptr<MessageReceiver> sync_responder(responder); | 160 scoped_ptr<MessageReceiver> sync_responder(responder); |
161 sync_responses_.insert(std::make_pair( | 161 sync_responses_.insert(std::make_pair( |
162 request_id, make_scoped_ptr(new SyncResponseInfo(&response_received)))); | 162 request_id, make_scoped_ptr(new SyncResponseInfo(&response_received)))); |
163 | 163 |
164 base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr(); | 164 base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr(); |
165 bool result = connector_.SyncWatch(&response_received); | 165 connector_.SyncWatch(&response_received); |
166 // Make sure that this instance hasn't been destroyed. | 166 // Make sure that this instance hasn't been destroyed. |
167 if (weak_self) { | 167 if (weak_self) { |
168 DCHECK(ContainsKey(sync_responses_, request_id)); | 168 DCHECK(ContainsKey(sync_responses_, request_id)); |
169 auto iter = sync_responses_.find(request_id); | 169 auto iter = sync_responses_.find(request_id); |
170 DCHECK_EQ(&response_received, iter->second->response_received); | 170 DCHECK_EQ(&response_received, iter->second->response_received); |
171 if (result && response_received) { | 171 if (response_received) { |
172 scoped_ptr<Message> response = std::move(iter->second->response); | 172 scoped_ptr<Message> response = std::move(iter->second->response); |
173 ignore_result(sync_responder->Accept(response.get())); | 173 ignore_result(sync_responder->Accept(response.get())); |
174 } | 174 } |
175 sync_responses_.erase(iter); | 175 sync_responses_.erase(iter); |
176 } | 176 } |
177 | 177 |
178 // Return true means that we take ownership of |responder|. | 178 // Return true means that we take ownership of |responder|. |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 encountered_error_ = true; | 303 encountered_error_ = true; |
304 error_handler_.Run(); | 304 error_handler_.Run(); |
305 } | 305 } |
306 | 306 |
307 // ---------------------------------------------------------------------------- | 307 // ---------------------------------------------------------------------------- |
308 | 308 |
309 } // namespace internal | 309 } // namespace internal |
310 } // namespace mojo | 310 } // namespace mojo |
OLD | NEW |