| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 void WatcherBackend::RemoveAndNotify(const Handle& handle, | 118 void WatcherBackend::RemoveAndNotify(const Handle& handle, |
| 119 MojoResult result) { | 119 MojoResult result) { |
| 120 if (handle_to_data_.count(handle) == 0) | 120 if (handle_to_data_.count(handle) == 0) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 const WatchData data(handle_to_data_[handle]); | 123 const WatchData data(handle_to_data_[handle]); |
| 124 handle_to_data_.erase(handle); | 124 handle_to_data_.erase(handle); |
| 125 MessagePumpMojo::current()->RemoveHandler(handle); | 125 MessagePumpMojo::current()->RemoveHandler(handle); |
| 126 | |
| 127 data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result)); | 126 data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result)); |
| 128 } | 127 } |
| 129 | 128 |
| 130 bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id, | 129 bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id, |
| 131 Handle* handle) const { | 130 Handle* handle) const { |
| 132 for (HandleToWatchDataMap::const_iterator i = handle_to_data_.begin(); | 131 for (HandleToWatchDataMap::const_iterator i = handle_to_data_.begin(); |
| 133 i != handle_to_data_.end(); ++i) { | 132 i != handle_to_data_.end(); ++i) { |
| 134 if (i->second.id == watcher_id) { | 133 if (i->second.id == watcher_id) { |
| 135 *handle = i->second.handle; | 134 *handle = i->second.handle; |
| 136 return true; | 135 return true; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 this, handle, handle_signals, deadline, callback)); | 466 this, handle, handle_signals, deadline, callback)); |
| 468 } | 467 } |
| 469 } | 468 } |
| 470 | 469 |
| 471 void HandleWatcher::Stop() { | 470 void HandleWatcher::Stop() { |
| 472 state_.reset(); | 471 state_.reset(); |
| 473 } | 472 } |
| 474 | 473 |
| 475 } // namespace common | 474 } // namespace common |
| 476 } // namespace mojo | 475 } // namespace mojo |
| OLD | NEW |