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