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