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/message_pump/handle_watcher.h" | 5 #include "mojo/message_pump/handle_watcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 | 265 |
266 void WatcherThreadManager::AddRequest(const RequestData& data) { | 266 void WatcherThreadManager::AddRequest(const RequestData& data) { |
267 { | 267 { |
268 base::AutoLock auto_lock(lock_); | 268 base::AutoLock auto_lock(lock_); |
269 const bool was_empty = requests_.empty(); | 269 const bool was_empty = requests_.empty(); |
270 requests_.push_back(data); | 270 requests_.push_back(data); |
271 if (!was_empty) | 271 if (!was_empty) |
272 return; | 272 return; |
273 } | 273 } |
| 274 |
| 275 // With the new Mojo EDK, the MojoMessagePump will destruct when it sees that |
| 276 // the IO thread has gone away. So at shutdown this can be null. |
| 277 if (!thread_.task_runner()) |
| 278 return; |
| 279 |
274 // We outlive |thread_|, so it's safe to use Unretained() here. | 280 // We outlive |thread_|, so it's safe to use Unretained() here. |
275 thread_.task_runner()->PostTask( | 281 thread_.task_runner()->PostTask( |
276 FROM_HERE, | 282 FROM_HERE, |
277 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread, | 283 base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread, |
278 base::Unretained(this))); | 284 base::Unretained(this))); |
279 } | 285 } |
280 | 286 |
281 void WatcherThreadManager::ProcessRequestsOnBackendThread() { | 287 void WatcherThreadManager::ProcessRequestsOnBackendThread() { |
282 DCHECK_EQ(thread_.message_loop(), base::MessageLoop::current()); | 288 DCHECK_EQ(thread_.message_loop(), base::MessageLoop::current()); |
283 | 289 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 this, handle, handle_signals, deadline, callback)); | 479 this, handle, handle_signals, deadline, callback)); |
474 } | 480 } |
475 } | 481 } |
476 | 482 |
477 void HandleWatcher::Stop() { | 483 void HandleWatcher::Stop() { |
478 state_.reset(); | 484 state_.reset(); |
479 } | 485 } |
480 | 486 |
481 } // namespace common | 487 } // namespace common |
482 } // namespace mojo | 488 } // namespace mojo |
OLD | NEW |