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

Unified Diff: net/base/network_change_notifier_mac.cc

Issue 7135005: NetworkChangeNotifierMac: lock access to network_reachable_ as it may be read (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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
« no previous file with comments | « net/base/network_change_notifier_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_change_notifier_mac.cc
diff --git a/net/base/network_change_notifier_mac.cc b/net/base/network_change_notifier_mac.cc
index cde4d6e6e98e4c69d3cd02cc7048c3299d0d8cbd..b8e25ed2107aaa7c95a5cc02b740a13a15771900 100644
--- a/net/base/network_change_notifier_mac.cc
+++ b/net/base/network_change_notifier_mac.cc
@@ -10,6 +10,7 @@
#include <SystemConfiguration/SCSchemaDefinitions.h>
#include "base/mac/scoped_cftyperef.h"
+#include "base/synchronization/lock.h"
namespace net {
@@ -27,6 +28,7 @@ NetworkChangeNotifierMac::~NetworkChangeNotifierMac() {
}
bool NetworkChangeNotifierMac::IsCurrentlyOffline() const {
+ base::AutoLock lock(network_reachable_lock_);
return !network_reachable_;
}
@@ -120,7 +122,10 @@ void NetworkChangeNotifierMac::ReachabilityCallback(
bool reachable = flags & kSCNetworkFlagsReachable;
bool connection_required = flags & kSCNetworkFlagsConnectionRequired;
bool old_reachability = notifier_mac->network_reachable_;
- notifier_mac->network_reachable_ = reachable && !connection_required;
+ {
+ base::AutoLock lock(notifier_mac->network_reachable_lock_);
+ notifier_mac->network_reachable_ = reachable && !connection_required;
+ }
if (old_reachability != notifier_mac->network_reachable_)
NotifyObserversOfOnlineStateChange();
}
« no previous file with comments | « net/base/network_change_notifier_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698