| commit | c8ce86e4dd397fd208f581045206f1ce47e8528d | [log] [tgz] |
|---|---|---|
| author | Matt Reynolds <mattreynolds@chromium.org> | Wed Sep 18 18:52:34 2019 |
| committer | Commit Bot <commit-bot@chromium.org> | Wed Sep 18 18:52:34 2019 |
| tree | 9758638423727fa4375887320cfd6b982a3d7b48 | |
| parent | b66148bd0b9c12522da8499db9be74398d19d313 [diff] |
[gamepad] Enforce GamepadService consumers invariant GamepadService maintains a set of GamepadConsumers that are registered to receive gamepad events. In normal operation, ConsumerBecameActive is called when the consumer is ready to receive events and ConsumerBecameInactive is called when the consumer wants to temporarily pause events without unregistering. The |num_active_consumers_| member tracks how many consumers are currently active and should always equal the count of consumers in |consumers_| that have the is_active flag set. If a consumer calls these methods in an invalid order, this invariant may be broken. For instance, calling ConsumerBecameInactive will decrement |num_active_consumers_| even if the consumer was already inactive. This CL enforces the invariant by changing DCHECKs into CHECKs. This also fixes a bug where consumers_.end() may be dereferenced when ConsumerBecameInactive is called for a consumer that was never added to |consumers_|. BUG=998431 Change-Id: I86c53a481601cf05a66b3b0a8b011412660c805e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804379 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Matt Reynolds <mattreynolds@chromium.org> Cr-Commit-Position: refs/heads/master@{#697706}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .