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 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 incoming_receiver_(nullptr), | 126 incoming_receiver_(nullptr), |
127 next_request_id_(0), | 127 next_request_id_(0), |
128 testing_mode_(false), | 128 testing_mode_(false), |
129 pending_task_for_messages_(false), | 129 pending_task_for_messages_(false), |
130 encountered_error_(false), | 130 encountered_error_(false), |
131 weak_factory_(this) { | 131 weak_factory_(this) { |
132 filters_.SetSink(&thunk_); | 132 filters_.SetSink(&thunk_); |
133 if (expects_sync_requests) | 133 if (expects_sync_requests) |
134 connector_.AllowWokenUpBySyncWatchOnSameThread(); | 134 connector_.AllowWokenUpBySyncWatchOnSameThread(); |
135 connector_.set_incoming_receiver(filters_.GetHead()); | 135 connector_.set_incoming_receiver(filters_.GetHead()); |
136 connector_.set_connection_error_handler([this]() { OnConnectionError(); }); | 136 connector_.set_connection_error_handler( |
| 137 base::Bind(&Router::OnConnectionError, base::Unretained(this))); |
137 } | 138 } |
138 | 139 |
139 Router::~Router() {} | 140 Router::~Router() {} |
140 | 141 |
141 bool Router::Accept(Message* message) { | 142 bool Router::Accept(Message* message) { |
142 DCHECK(thread_checker_.CalledOnValidThread()); | 143 DCHECK(thread_checker_.CalledOnValidThread()); |
143 DCHECK(!message->has_flag(kMessageExpectsResponse)); | 144 DCHECK(!message->has_flag(kMessageExpectsResponse)); |
144 return connector_.Accept(message); | 145 return connector_.Accept(message); |
145 } | 146 } |
146 | 147 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 303 |
303 if (connector_.during_sync_handle_watcher_callback()) { | 304 if (connector_.during_sync_handle_watcher_callback()) { |
304 // We don't want the error handler to reenter an ongoing sync call. | 305 // We don't want the error handler to reenter an ongoing sync call. |
305 connector_.task_runner()->PostTask( | 306 connector_.task_runner()->PostTask( |
306 FROM_HERE, | 307 FROM_HERE, |
307 base::Bind(&Router::OnConnectionError, weak_factory_.GetWeakPtr())); | 308 base::Bind(&Router::OnConnectionError, weak_factory_.GetWeakPtr())); |
308 return; | 309 return; |
309 } | 310 } |
310 | 311 |
311 encountered_error_ = true; | 312 encountered_error_ = true; |
312 error_handler_.Run(); | 313 if (!error_handler_.is_null()) |
| 314 error_handler_.Run(); |
313 } | 315 } |
314 | 316 |
315 // ---------------------------------------------------------------------------- | 317 // ---------------------------------------------------------------------------- |
316 | 318 |
317 } // namespace internal | 319 } // namespace internal |
318 } // namespace mojo | 320 } // namespace mojo |
OLD | NEW |