| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <cstdio> | 5 #include <cstdio> |
| 6 #include <cstring> | 6 #include <cstring> |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <mutex> | 8 #include <mutex> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 handle_ports_.push_back(port); | 161 handle_ports_.push_back(port); |
| 162 handle_to_index_map_[handle] = index; | 162 handle_to_index_map_[handle] = index; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Sanity check. | 165 // Sanity check. |
| 166 MOJO_CHECK(wait_many_handles_.size() == handle_to_index_map_.size()); | 166 MOJO_CHECK(wait_many_handles_.size() == handle_to_index_map_.size()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void HandleWatcherThreadState::RemoveHandle(MojoHandle handle) { | 169 void HandleWatcherThreadState::RemoveHandle(MojoHandle handle) { |
| 170 auto it = handle_to_index_map_.find(handle); | 170 auto it = handle_to_index_map_.find(handle); |
| 171 MOJO_CHECK(it != handle_to_index_map_.end()); | 171 |
| 172 // Removal of a handle for an incoming event can race with the removal of |
| 173 // a handle for an unsubscribe() call on the Dart MojoEventSubscription. |
| 174 // This is not an error, so we ignore attempts to remove a handle that is not |
| 175 // in the map. |
| 176 if (it == handle_to_index_map_.end()) { |
| 177 return; |
| 178 } |
| 172 const intptr_t index = it->second; | 179 const intptr_t index = it->second; |
| 173 // We should never be removing the control handle. | 180 // We should never be removing the control handle. |
| 174 MOJO_CHECK(index != CONTROL_HANDLE_INDEX); | 181 MOJO_CHECK(index != CONTROL_HANDLE_INDEX); |
| 175 RemoveHandleAtIndex(index); | 182 RemoveHandleAtIndex(index); |
| 176 } | 183 } |
| 177 | 184 |
| 178 void HandleWatcherThreadState::CloseHandle(MojoHandle handle, | 185 void HandleWatcherThreadState::CloseHandle(MojoHandle handle, |
| 179 Dart_Port port, | 186 Dart_Port port, |
| 180 bool pruning) { | 187 bool pruning) { |
| 181 MOJO_CHECK(!pruning || (port == ILLEGAL_PORT)); | 188 MOJO_CHECK(!pruning || (port == ILLEGAL_PORT)); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 control_handles.push_back(it.first); | 589 control_handles.push_back(it.first); |
| 583 } | 590 } |
| 584 | 591 |
| 585 for (auto it : control_handles) { | 592 for (auto it : control_handles) { |
| 586 StopLocked(it); | 593 StopLocked(it); |
| 587 } | 594 } |
| 588 } | 595 } |
| 589 | 596 |
| 590 } // namespace dart | 597 } // namespace dart |
| 591 } // namespace mojo | 598 } // namespace mojo |
| OLD | NEW |