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