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

Issue 7006015: Implement NetworkChangeNotifier::IsCurrentlyOffline() for Mac. (Closed)

Created:
9 years, 6 months ago by adamk
Modified:
9 years, 6 months ago
CC:
chromium-reviews, pam+watch_chromium.org, cbentzel+watch_chromium.org, darin-cc_chromium.org
Visibility:
Public.

Description

Implement NetworkChangeNotifier::IsCurrentlyOffline() for Mac. R=willchan@chromium.org BUG=7469, 53473 TEST=load onlineTest.html attachment on bug 7469; disconnect/connect network cable Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87699

Patch Set 1 #

Total comments: 13

Patch Set 2 : Responded to review comments #

Total comments: 2

Patch Set 3 : Added a 0 #

Patch Set 4 : Remove TODO #

Total comments: 1

Patch Set 5 : Only notify if state changed #

Patch Set 6 : Call cleanup from destructor #

Total comments: 5

Patch Set 7 : Retain CFRunLoop, get rid of CleanUp method #

Total comments: 4

Patch Set 8 : Added thread ID DCHECKs #

Total comments: 1

Patch Set 9 : Replace thread id with run loop in DCHECK #

Total comments: 1

Patch Set 10 : Use DCHECK_EQ #

Patch Set 11 : Copyrights #

Unified diffs Side-by-side diffs Delta from patch set Stats (+77 lines, -7 lines) Patch
M net/base/network_change_notifier_mac.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +10 lines, -1 line 0 comments Download
M net/base/network_change_notifier_mac.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +67 lines, -6 lines 0 comments Download

Messages

Total messages: 30 (0 generated)
adamk
9 years, 6 months ago (2011-05-31 23:49:59 UTC) #1
adamk
I'm sad about the lack of a unittest, but I don't know if such a ...
9 years, 6 months ago (2011-05-31 23:51:01 UTC) #2
willchan no longer on Chromium
I usually add a Mac guy to help me with these OS X specific APIs. ...
9 years, 6 months ago (2011-06-01 20:46:04 UTC) #3
willchan no longer on Chromium
LGTM, but wait for Mark or someone he delegates to approve the OS X specific ...
9 years, 6 months ago (2011-06-01 20:48:47 UTC) #4
Mark Mentovai
LGTM from a Mac perspective. http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc#newcode7 net/base/network_change_notifier_mac.cc:7: #include <netinet/in.h> These shouldn’t ...
9 years, 6 months ago (2011-06-01 21:05:59 UTC) #5
adamk
http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc#newcode7 net/base/network_change_notifier_mac.cc:7: #include <netinet/in.h> On 2011/06/01 21:05:59, Mark Mentovai wrote: > ...
9 years, 6 months ago (2011-06-01 21:42:53 UTC) #6
Mark Mentovai
LGTM http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc#newcode56 net/base/network_change_notifier_mac.cc:56: struct sockaddr_in addr; adamk wrote: > On 2011/06/01 ...
9 years, 6 months ago (2011-06-01 22:02:45 UTC) #7
adamk
Thanks for the quick review! http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc#newcode56 net/base/network_change_notifier_mac.cc:56: struct sockaddr_in addr; On ...
9 years, 6 months ago (2011-06-01 22:09:34 UTC) #8
Mark Mentovai
http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/1/net/base/network_change_notifier_mac.cc#newcode56 net/base/network_change_notifier_mac.cc:56: struct sockaddr_in addr; adamk wrote: > Sorry, I meant ...
9 years, 6 months ago (2011-06-01 22:10:43 UTC) #9
adamk
http://codereview.chromium.org/7006015/diff/8001/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/8001/net/base/network_change_notifier_mac.cc#newcode67 net/base/network_change_notifier_mac.cc:67: // in handling this? On 2011/06/01 22:02:45, Mark Mentovai ...
9 years, 6 months ago (2011-06-01 22:11:28 UTC) #10
adamk
Hmm, some worrisome tryjob output. Will need to investigate: http://build.chromium.org/p/tryserver.chromium/builders/mac_sync/builds/2817/steps/sync_integration_tests/logs/stdio
9 years, 6 months ago (2011-06-01 23:16:51 UTC) #11
Mark Mentovai
http://codereview.chromium.org/7006015/diff/12001/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/12001/net/base/network_change_notifier_mac.cc#newcode110 net/base/network_change_notifier_mac.cc:110: notifier_mac->NotifyObserversOfOnlineStateChange(); Also: Do you only want to make this ...
9 years, 6 months ago (2011-06-01 23:28:50 UTC) #12
adamk
On Wed, Jun 1, 2011 at 4:28 PM, <mark@chromium.org> wrote: > > > http://codereview.chromium.org/7006015/diff/12001/net/base/network_change_notifier_mac.cc > ...
9 years, 6 months ago (2011-06-01 23:31:07 UTC) #13
Mark Mentovai
LGTM again, but the real reason I was rereading this was to try to figure ...
9 years, 6 months ago (2011-06-01 23:36:31 UTC) #14
adamk
My guess: the NetworkChangeNotifier is getting deleted too early, and so CleanUp() is being called ...
9 years, 6 months ago (2011-06-01 23:48:59 UTC) #15
adamk
Indeed, adding a call to CleanUp() in the destructor causes the tests to pass. I'm ...
9 years, 6 months ago (2011-06-02 00:51:41 UTC) #16
Mark Mentovai
http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc#newcode22 net/base/network_change_notifier_mac.cc:22: CleanUp(); Which thread does this happen on? http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc#newcode31 net/base/network_change_notifier_mac.cc:31: ...
9 years, 6 months ago (2011-06-02 16:26:57 UTC) #17
adamk
http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc#newcode22 net/base/network_change_notifier_mac.cc:22: CleanUp(); On 2011/06/02 16:26:57, Mark Mentovai wrote: > Which ...
9 years, 6 months ago (2011-06-02 16:43:50 UTC) #18
Mark Mentovai
http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/12003/net/base/network_change_notifier_mac.cc#newcode31 net/base/network_change_notifier_mac.cc:31: // Called on notifier thread. adamk wrote: > Not ...
9 years, 6 months ago (2011-06-02 16:47:19 UTC) #19
adamk
I've done away with the CleanUp() method, and instead I retain the CFRunLoop in order ...
9 years, 6 months ago (2011-06-02 19:14:00 UTC) #20
adamk
I've also added thread ID DCHECKs (using PlatformThread even though this is Mac-only since it ...
9 years, 6 months ago (2011-06-02 19:37:07 UTC) #21
Mark Mentovai
http://codereview.chromium.org/7006015/diff/16001/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/16001/net/base/network_change_notifier_mac.cc#newcode23 net/base/network_change_notifier_mac.cc:23: if (reachability_.get() && run_loop_) { Two alternatives here. 1. ...
9 years, 6 months ago (2011-06-02 19:46:36 UTC) #22
adamk
http://codereview.chromium.org/7006015/diff/16001/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/16001/net/base/network_change_notifier_mac.cc#newcode23 net/base/network_change_notifier_mac.cc:23: if (reachability_.get() && run_loop_) { On 2011/06/02 19:46:36, Mark ...
9 years, 6 months ago (2011-06-02 19:55:50 UTC) #23
Mark Mentovai
LGTM http://codereview.chromium.org/7006015/diff/14003/net/base/network_change_notifier_mac.cc File net/base/network_change_notifier_mac.cc (right): http://codereview.chromium.org/7006015/diff/14003/net/base/network_change_notifier_mac.cc#newcode91 net/base/network_change_notifier_mac.cc:91: DCHECK(run_loop_.get() == CFRunLoopGetCurrent()); You can still change this ...
9 years, 6 months ago (2011-06-02 20:02:43 UTC) #24
adamk
On Thu, Jun 2, 2011 at 1:02 PM, <mark@chromium.org> wrote: > LGTM > > > ...
9 years, 6 months ago (2011-06-02 20:28:24 UTC) #25
Mark Mentovai
Exactly!
9 years, 6 months ago (2011-06-02 20:29:10 UTC) #26
Mark Mentovai
LGTM
9 years, 6 months ago (2011-06-02 20:56:49 UTC) #27
eroman
I have two concerns with this implementation: (1) Does it work correctly if you launch ...
9 years, 6 months ago (2011-06-07 19:18:38 UTC) #28
eroman
(i obviously meant "initialized to true" in the above comment :)
9 years, 6 months ago (2011-06-07 19:19:16 UTC) #29
adamk
9 years, 6 months ago (2011-06-07 19:25:53 UTC) #30
On Tue, Jun 7, 2011 at 12:18 PM, <eroman@chromium.org> wrote:

> I have two concerns with this implementation:
>
> (1) Does it work correctly if you launch Chrome while offline?
>
> It looks to me like since |network_reachable_| is initialized to false, and
> is
> only subsequently updated by the change callback, we will think Chrome is
> "online" until the next online/offline transition.
>

This is very true, though I just noticed it yesterday.  Sorry, should have
seen it before.  There's actually a sync version of this call; where would
be a good place to make that call? Should it happen on construction? I just
worry about slowing down startup...


> (2) The "network_reachable_" boolean is updated non-atomically from a
> different
> thread than where it might be accessed from:
>
> notifier_mac->network_**reachable_ = reachable && !connection_required;
>
> Note that implementations are supposed to be threadsafe --> this bool may
> be
> accessed from other threads. Depending how the above line gets compiled,
> you
> could end up reading the intermediate value of the above expression...
>

Hmm, good point. I was only considering the OnlineStateObserver use-case,
but this is clearly wrong.  Would you prefer this be switched to use an
atomic op, or a mutex?


>
> Otherwise LGTM, thanks for writing this.
>
>
>
http://codereview.chromium.**org/7006015/<http://codereview.chromium.org/7006...
>

Powered by Google App Engine
This is Rietveld 408576698