Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: mojo/public/platform/dart/dart_handle_watcher.cc

Issue 1874553002: Dart: Fix bug in unbind() for Stubs. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/dart/packages/_mojo_for_test_only/lib/test/echo_service.mojom.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/dart/packages/_mojo_for_test_only/lib/test/echo_service.mojom.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698