New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 875392 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug
Proj-Servicification



Sign in to add a comment

Consider using RAII to manage NetworkConnectionTracker registrations

Project Member Reported by rmcelrath@chromium.org, Aug 17

Issue description

See isherman@'s comment on https://crrev.com/c/1175486

It might be cleaner to have some object representing a NetworkConnectionTracker registration that will automatically unregister itself upon destruction.

Most classes that use NetworkConnectionTracker register in the constructor and unregister in the destructor, though there are a few that deregister outside the destructor (ForceSigninVerifier, NetworkStatusListenerImpl, AutoEnrollmentClientImpl). Several classes register outside of the constructor, either in a Start method or on a another thread posted to by the constructor.
 
Components: Internals>Network>Connectivity
i think that's a good idea and I haven't considered it before.
NetworkConnectionTracker is modeled after net::NetworkChangeNotifier.

I see there are a couple of use cases that are guarded with checks, e.g: 
https://cs.chromium.org/chromium/src/components/sync/engine_impl/sync_manager_impl.cc?l=305
https://cs.chromium.org/chromium/src/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc?l=76

But you are right that most use cases follow the same pattern. The remaining ones probably can be converted to adopt RAII by creating a wrapper object.
Labels: Hotlist-KnownIssue

Sign in to add a comment