Chromium Code Reviews| 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/common/handle_watcher.h" | 5 #include "mojo/common/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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 HandleWatcher::~HandleWatcher() { | 451 HandleWatcher::~HandleWatcher() { |
| 452 } | 452 } |
| 453 | 453 |
| 454 void HandleWatcher::Start(const Handle& handle, | 454 void HandleWatcher::Start(const Handle& handle, |
| 455 MojoHandleSignals handle_signals, | 455 MojoHandleSignals handle_signals, |
| 456 MojoDeadline deadline, | 456 MojoDeadline deadline, |
| 457 const base::Callback<void(MojoResult)>& callback) { | 457 const base::Callback<void(MojoResult)>& callback) { |
| 458 DCHECK(handle.is_valid()); | 458 DCHECK(handle.is_valid()); |
| 459 DCHECK_NE(MOJO_HANDLE_SIGNAL_NONE, handle_signals); | 459 DCHECK_NE(MOJO_HANDLE_SIGNAL_NONE, handle_signals); |
| 460 | 460 |
| 461 // Need to clear the state before creating a new one. | |
| 462 state_.reset(); | |
|
viettrungluu
2014/12/08 18:10:01
I assume that this is because we need the dtor of
qsr
2014/12/09 10:02:23
The destructor remove the handler, and neither of
| |
| 461 if (MessagePumpMojo::IsCurrent()) { | 463 if (MessagePumpMojo::IsCurrent()) { |
| 462 state_.reset(new SameThreadWatchingState( | 464 state_.reset(new SameThreadWatchingState( |
| 463 this, handle, handle_signals, deadline, callback)); | 465 this, handle, handle_signals, deadline, callback)); |
| 464 } else { | 466 } else { |
| 465 state_.reset(new SecondaryThreadWatchingState( | 467 state_.reset(new SecondaryThreadWatchingState( |
| 466 this, handle, handle_signals, deadline, callback)); | 468 this, handle, handle_signals, deadline, callback)); |
| 467 } | 469 } |
| 468 } | 470 } |
| 469 | 471 |
| 470 void HandleWatcher::Stop() { | 472 void HandleWatcher::Stop() { |
| 471 state_.reset(); | 473 state_.reset(); |
| 472 } | 474 } |
| 473 | 475 |
| 474 } // namespace common | 476 } // namespace common |
| 475 } // namespace mojo | 477 } // namespace mojo |
| OLD | NEW |