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

Unified Diff: chromeos/network/network_state_handler.h

Issue 1562593002: Fix potential crashes in NetworkHandler code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test
Patch Set: Call NetworkStateHandler::Shutdown in destructor for unit tests Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/network/network_state_handler.h
diff --git a/chromeos/network/network_state_handler.h b/chromeos/network/network_state_handler.h
index 2477c1a7a6b71690732674c92fa03f561d367dbc..90b5105a5fbc2716ec78b0f299fb30b10d909488 100644
--- a/chromeos/network/network_state_handler.h
+++ b/chromeos/network/network_state_handler.h
@@ -81,6 +81,10 @@ class CHROMEOS_EXPORT NetworkStateHandler
~NetworkStateHandler() override;
+ // Called just before destruction to give observers a chance to remove
+ // themselves and disable any networking.
+ void Shutdown();
+
// Add/remove observers.
void AddObserver(NetworkStateHandlerObserver* observer,
const tracked_objects::Location& from_here);
@@ -374,14 +378,14 @@ class CHROMEOS_EXPORT NetworkStateHandler
scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_;
// Observer list
- base::ObserverList<NetworkStateHandlerObserver> observers_;
+ base::ObserverList<NetworkStateHandlerObserver, true> observers_;
// List of managed network states
ManagedStateList network_list_;
// Set to true when the network list is sorted, cleared when network updates
// arrive. Used to trigger sorting when needed.
- bool network_list_sorted_;
+ bool network_list_sorted_ = false;
// List of managed device states
ManagedStateList device_list_;
@@ -396,6 +400,9 @@ class CHROMEOS_EXPORT NetworkStateHandler
// NetworkState that is not saved in a profile.
SpecifierGuidMap specifier_guid_map_;
+ // Ensure that Shutdown() gets called exactly once.
+ bool did_shutdown_ = false;
+
DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler);
};

Powered by Google App Engine
This is Rietveld 408576698