|
|
DescriptionAdding platform support check for NetworkObserver
Committed: https://crrev.com/c94943b28b4876071a8d509f478e4c63ebb75ca2
Cr-Commit-Position: refs/heads/master@{#363020}
Patch Set 1 #Patch Set 2 : Fixed typo. #
Total comments: 2
Patch Set 3 : #Patch Set 4 : Addresses pauljensen's comments #
Total comments: 17
Patch Set 5 : Addresses pauljensen's comments. #
Total comments: 1
Patch Set 6 : comment addressed #Patch Set 7 : trying to fix compile error #Patch Set 8 : Fixing failing Android tests #Patch Set 9 : Response to pauljensen's comments #Patch Set 10 : Added forcing networkhandle support to NCNAndroid and NCNAndroidTest #
Messages
Total messages: 53 (20 generated)
jri@chromium.org changed reviewers: + pauljensen@chromium.org
I thought of adding a boolean return to AddNetworkObserver, but the semantics of that would not be clean, since AddNetworkObserver does not add an observer if the singleton is not yet instantiated. Feel free to suggest a different method of doing this.
Paul: Are there other observers for which such a method could/should be added? What about IPAddressObserver?
rch@chromium.org changed reviewers: + rch@chromium.org
Cool. But my opinion is not important; Paul's it. https://codereview.chromium.org/1454313002/diff/20001/net/base/network_change... File net/base/network_change_notifier.cc (right): https://codereview.chromium.org/1454313002/diff/20001/net/base/network_change... net/base/network_change_notifier.cc:810: return true; FWIW, you can just do: return base::android::BuildInfo::GetInstance()->sdk_int() >= base::android::SDK_VERSION_LOLLIPOP;
https://codereview.chromium.org/1454313002/diff/20001/net/base/network_change... File net/base/network_change_notifier.cc (right): https://codereview.chromium.org/1454313002/diff/20001/net/base/network_change... net/base/network_change_notifier.cc:810: return true; On 2015/11/19 02:19:04, Ryan Hamilton wrote: > FWIW, you can just do: > > return base::android::BuildInfo::GetInstance()->sdk_int() >= > base::android::SDK_VERSION_LOLLIPOP; Done.
So I think we need to make some changes to this: 1. Broaden the API to not just cover NetworkObservers but also the other APIs I added: static void GetConnectedNetworks(NetworkList* network_list); static ConnectionType GetNetworkConnectionType(NetworkHandle network); static NetworkHandle GetDefaultNetwork(); 2. Make this a virtual function with a default implementation that returns false. NetworkChangeNotifierAndroid can offer an implementation with the Android version check.
Jana and I discussed on VC: 1. I think changing the API name to AreNetworkHandlesSupported() 2. I think we should make all 5 functions covered by this API include DCHECK(AreNetworkHandlesSupported())
Paul: I think this patch does what you want to do. PTAL.
rch@chromium.org changed reviewers: - pauljensen@chromium.org
Looks good, but Paul knows for sure
pauljensen@chromium.org changed reviewers: + pauljensen@chromium.org
https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... File net/android/network_change_notifier_android.cc (right): https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... net/android/network_change_notifier_android.cc:166: // Notifications for API using NetworkHandles only implemented for Android Notifications->Notifications/querying https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... net/android/network_change_notifier_android.cc:166: // Notifications for API using NetworkHandles only implemented for Android API->APIs https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... File net/base/network_change_notifier.cc (right): https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.cc:851: void NetworkChangeNotifier::AddNetworkObserver(NetworkObserver* observer) { DCHECK(AreNetworkHandlesSupported()); https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.cc:896: void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) { DCHECK(AreNetworkHandlesSupported()); https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... File net/base/network_change_notifier.h (right): https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:294: // Returns true if the platform supports use of API based on NetworkHandles. API->APIs https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:296: // GetNetworkConnectionType(), and GetDefaultNetwork(). please also mention NetworkObserver https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:301: // empty when unimplemented. Requires NetworkHandles support. support->support, see AreNetworkHandlesSupported(). https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:308: // CONNECTION_UNKNOWN when unimplemented. Requires NetworkHandles support. ditto https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:318: // Requires NetworkHandles support. ditto
Thanks, Paul, comments addressed. https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... File net/android/network_change_notifier_android.cc (right): https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... net/android/network_change_notifier_android.cc:166: // Notifications for API using NetworkHandles only implemented for Android On 2015/11/30 20:23:48, pauljensen wrote: > API->APIs Done. https://codereview.chromium.org/1454313002/diff/60001/net/android/network_cha... net/android/network_change_notifier_android.cc:166: // Notifications for API using NetworkHandles only implemented for Android On 2015/11/30 20:23:48, pauljensen wrote: > Notifications->Notifications/querying Modified comment -- see if it's better. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... File net/base/network_change_notifier.cc (right): https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.cc:851: void NetworkChangeNotifier::AddNetworkObserver(NetworkObserver* observer) { On 2015/11/30 20:23:48, pauljensen wrote: > DCHECK(AreNetworkHandlesSupported()); Done. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.cc:896: void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) { On 2015/11/30 20:23:48, pauljensen wrote: > DCHECK(AreNetworkHandlesSupported()); Done. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... File net/base/network_change_notifier.h (right): https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:296: // GetNetworkConnectionType(), and GetDefaultNetwork(). On 2015/11/30 20:23:48, pauljensen wrote: > please also mention NetworkObserver Done. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:301: // empty when unimplemented. Requires NetworkHandles support. On 2015/11/30 20:23:48, pauljensen wrote: > support->support, see AreNetworkHandlesSupported(). Done. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:308: // CONNECTION_UNKNOWN when unimplemented. Requires NetworkHandles support. On 2015/11/30 20:23:48, pauljensen wrote: > ditto Done. https://codereview.chromium.org/1454313002/diff/60001/net/base/network_change... net/base/network_change_notifier.h:318: // Requires NetworkHandles support. On 2015/11/30 20:23:48, pauljensen wrote: > ditto Done.
lgtm modulo my one comment https://codereview.chromium.org/1454313002/diff/80001/net/base/network_change... File net/base/network_change_notifier.h (right): https://codereview.chromium.org/1454313002/diff/80001/net/base/network_change... net/base/network_change_notifier.h:297: // RemoveNetworkObserver, and all public NetworkObserver methods. RemoveNetworkObserver->RemoveNetworkObserver()
Thanks, Paul. Fixed, and submitting.
The CQ bit was checked by jri@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pauljensen@chromium.org Link to the patchset: https://codereview.chromium.org/1454313002/#ps100001 (title: "comment addressed")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/100001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_compile...)
The CQ bit was checked by jri@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pauljensen@chromium.org Link to the patchset: https://codereview.chromium.org/1454313002/#ps120001 (title: "trying to fix compile error")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/120001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_android_r...)
The CQ bit was checked by jri@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/120001
The CQ bit was unchecked by jri@chromium.org
The CQ bit was checked by jri@chromium.org
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_android_r...)
The CQ bit was checked by pauljensen@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/120001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_android_r...)
Paul: Per our offline conversation, I've added the set method for tests. PTAL
That's not how I envisioned this. Furthermore I don't think the change works: the test explicitly instantiates a NCNAndroid which overrides AreNetworkHandlesSupported() so mucking with the parent class won't affect this (or fix the test). Here's a simpler fix that doesn't affect the NCN API or involve the NCN singleton: 1. add private NCNAndroid::ForceNetworkHandlesSupportedForTesting() { force_network_handles_supported_for_testing_ = true; } 2. add protected NCNAndroidTest::ForceNetworkHandlesSupportedForTesting() { notifier_->ForceNetworkHandlesSupportedForTesting(); } 3. have the test call ForceNetworkHandlesSupportedForTesting() 4. add to the begining of NCNAndroid::AreNetworkHandlesSupported if (force_network_handles_supported_for_testing_) return true; 5. add private bool NCNAndroid::force_network_handles_supported_for_testing_
Paul: I think I'm going to need to do the same for tests later using MockNCN, so I think it's useful to have the forcing in NCN instead of just AndroidNCN. I've made some mods, PTAL. (I like your names better, so I'm using those)
On 2015/12/02 18:13:09, Jana wrote: > Paul: I think I'm going to need to do the same for tests later using MockNCN, so > I think it's useful to have the forcing in NCN instead of just AndroidNCN. I've > made some mods, PTAL. (I like your names better, so I'm using those) I don't think this fixes the test as I said in https://codereview.chromium.org/1454313002/#msg38 In the case of later tests using MockNCN, I'd much prefer we modify MockNCN::AreNetworkHandlesSupported() rather than the production NCN.
On 2015/12/02 18:16:14, pauljensen wrote: > On 2015/12/02 18:13:09, Jana wrote: > > Paul: I think I'm going to need to do the same for tests later using MockNCN, > so > > I think it's useful to have the forcing in NCN instead of just AndroidNCN. > I've > > made some mods, PTAL. (I like your names better, so I'm using those) > > I don't think this fixes the test as I said in > https://codereview.chromium.org/1454313002/#msg38 > In the case of later tests using MockNCN, I'd much prefer we modify > MockNCN::AreNetworkHandlesSupported() rather than the production NCN. Ah I see you adjusted NCNAndroid to call the parent override. I still would like this moved out of NCN as it's not necessary and involves the hideous global singleton.
I'll do it in AndroidNCN, but I was trying to point out that I'll have to do something similar in MockNCN later. That seems fine, and I'll make it happen.
Ok -- support added per your earlier comment. PTAL.
lgtm
The CQ bit was checked by pauljensen@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/180001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: ios_dbg_simulator_ninja on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios_dbg_simulator...)
The CQ bit was checked by jri@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1454313002/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1454313002/180001
Message was sent while issue was closed.
Committed patchset #10 (id:180001)
Message was sent while issue was closed.
Description was changed from ========== Adding platform support check for NetworkObserver ========== to ========== Adding platform support check for NetworkObserver Committed: https://crrev.com/c94943b28b4876071a8d509f478e4c63ebb75ca2 Cr-Commit-Position: refs/heads/master@{#363020} ==========
Message was sent while issue was closed.
Patchset 10 (id:??) landed as https://crrev.com/c94943b28b4876071a8d509f478e4c63ebb75ca2 Cr-Commit-Position: refs/heads/master@{#363020} |