| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 Requests requests_; | 215 Requests requests_; |
| 216 | 216 |
| 217 DISALLOW_COPY_AND_ASSIGN(WatcherThreadManager); | 217 DISALLOW_COPY_AND_ASSIGN(WatcherThreadManager); |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 WatcherThreadManager::~WatcherThreadManager() { | 220 WatcherThreadManager::~WatcherThreadManager() { |
| 221 thread_.Stop(); | 221 thread_.Stop(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 WatcherThreadManager* WatcherThreadManager::GetInstance() { | 224 WatcherThreadManager* WatcherThreadManager::GetInstance() { |
| 225 // We need to leak this because otherwise when the process dies, AtExitManager | 225 return base::Singleton<WatcherThreadManager>::get(); |
| 226 // waits for destruction which waits till the handle watcher thread is joined. | |
| 227 // But that can't happen since the pump uses mojo message pipes to wake up the | |
| 228 // pump. Since mojo EDK has been shutdown already, this never completes. | |
| 229 return base::Singleton<WatcherThreadManager, | |
| 230 base::LeakySingletonTraits<WatcherThreadManager>>:: | |
| 231 get(); | |
| 232 } | 226 } |
| 233 | 227 |
| 234 WatcherID WatcherThreadManager::StartWatching( | 228 WatcherID WatcherThreadManager::StartWatching( |
| 235 const Handle& handle, | 229 const Handle& handle, |
| 236 MojoHandleSignals handle_signals, | 230 MojoHandleSignals handle_signals, |
| 237 base::TimeTicks deadline, | 231 base::TimeTicks deadline, |
| 238 const base::Callback<void(MojoResult)>& callback) { | 232 const base::Callback<void(MojoResult)>& callback) { |
| 239 RequestData request_data; | 233 RequestData request_data; |
| 240 request_data.type = REQUEST_START; | 234 request_data.type = REQUEST_START; |
| 241 request_data.start_data.id = watcher_id_generator_.GetNext(); | 235 request_data.start_data.id = watcher_id_generator_.GetNext(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 this, handle, handle_signals, deadline, callback)); | 466 this, handle, handle_signals, deadline, callback)); |
| 473 } | 467 } |
| 474 } | 468 } |
| 475 | 469 |
| 476 void HandleWatcher::Stop() { | 470 void HandleWatcher::Stop() { |
| 477 state_.reset(); | 471 state_.reset(); |
| 478 } | 472 } |
| 479 | 473 |
| 480 } // namespace common | 474 } // namespace common |
| 481 } // namespace mojo | 475 } // namespace mojo |
| OLD | NEW |