|
|
Chromium Code Reviews
DescriptionRemove dependency of power_save_blocker_android on various content bits
BUG=612337, 612563
TEST=start/stop video on m.youtube.com, content_browsertests
Committed: https://crrev.com/a25943038ebc706537cdd5e6229924c53217ed31
Cr-Commit-Position: refs/heads/master@{#399549}
Patch Set 1 #Patch Set 2 : . #Patch Set 3 : . #Patch Set 4 : . #Patch Set 5 : . #Patch Set 6 : . #Patch Set 7 : fix #Patch Set 8 : . #
Total comments: 2
Patch Set 9 : weakptr #Patch Set 10 : clear #
Total comments: 2
Patch Set 11 : no null check #
Total comments: 2
Patch Set 12 : back to weakptr #
Total comments: 6
Patch Set 13 : review fixes #
Total comments: 2
Patch Set 14 : only .reset() #Messages
Total messages: 62 (29 generated)
Description was changed from ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 ========== to ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 ==========
scottmg@chromium.org changed reviewers: + boliu@chromium.org, michaelbai@chromium.org
Apparently this doesn't work. I'm not too sure what I'm doing here, but I guess only certain views implement that interface.
Description was changed from ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 ========== to ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com ==========
scottmg@chromium.org changed reviewers: + nick@chromium.org
+nick for content/ Do you feel able to review this (including the .java)? (All of content/public/android/OWNERS are out until June-sometime.)
Description was changed from ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com ========== to ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com, content_browsertests ==========
hmm, code no longer handles the case of PowerSaveBlockerImpl::Delegate outliving WebContents/ViewAndroid. previously this was done with WebContentsObserver nulling out the web_contents() pointer. For this CL, it's kinda hard to reason about the lifetime of RenderFrameDevToolsAgentHost, since it's refcounted. https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... content/browser/power_save_blocker_android.cc:7: #include "base/location.h" is this needed?
I can give an owners stamp but you'll need a primary reviewer (bo?) who is more familiar with Android. (I have Java readability, etc, but am pretty shaky on the JNI+Java stuff) https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... content/browser/power_save_blocker_android.cc:7: #include "base/location.h" On 2016/05/31 17:23:43, boliu wrote: > is this needed? yes, for FROM_HERE. It was missing.
On 2016/05/31 17:23:44, boliu wrote: > hmm, code no longer handles the case of PowerSaveBlockerImpl::Delegate outliving > WebContents/ViewAndroid. previously this was done with WebContentsObserver > nulling out the web_contents() pointer. Thanks, I missed that subtlety. Does it seem correct to pass a new interface into InitDisplaySleepBlocker() that can then be used to call back to the holder of web_contents() to provide the view if it's still around? That is, we're not worried about the lifetime of the object that is the WebContentsObserver, just the View that it gave out, right? > > For this CL, it's kinda hard to reason about the lifetime of > RenderFrameDevToolsAgentHost, since it's refcounted. > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > File content/browser/power_save_blocker_android.cc (right): > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > content/browser/power_save_blocker_android.cc:7: #include "base/location.h" > is this needed?
On 2016/05/31 20:02:38, scottmg wrote: > On 2016/05/31 17:23:44, boliu wrote: > > hmm, code no longer handles the case of PowerSaveBlockerImpl::Delegate > outliving > > WebContents/ViewAndroid. previously this was done with WebContentsObserver > > nulling out the web_contents() pointer. > > Thanks, I missed that subtlety. > > Does it seem correct to pass a new interface into InitDisplaySleepBlocker() that > can then be used to call back to the holder of web_contents() to provide the > view if it's still around? That is, we're not worried about the lifetime of the > object that is the WebContentsObserver, just the View that it gave out, right? Hmm, I guess not. It depends now on PowerSaveBlockerImpl::Delegate also being a WebContentsObserver itself, so that gets nulled when the WebContents goes away, if I understand. I guess instead then, I could have three callers of InitDisplaySleepBlocker() clear the provided view in WebContentsDestroyed. That seems relatively straightforward. (?) > > > > > For this CL, it's kinda hard to reason about the lifetime of > > RenderFrameDevToolsAgentHost, since it's refcounted. > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > File content/browser/power_save_blocker_android.cc (right): > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > content/browser/power_save_blocker_android.cc:7: #include "base/location.h" > > is this needed?
On 2016/05/31 20:48:10, scottmg wrote: > On 2016/05/31 20:02:38, scottmg wrote: > > On 2016/05/31 17:23:44, boliu wrote: > > > hmm, code no longer handles the case of PowerSaveBlockerImpl::Delegate > > outliving > > > WebContents/ViewAndroid. previously this was done with WebContentsObserver > > > nulling out the web_contents() pointer. > > > > Thanks, I missed that subtlety. > > > > Does it seem correct to pass a new interface into InitDisplaySleepBlocker() > that > > can then be used to call back to the holder of web_contents() to provide the > > view if it's still around? That is, we're not worried about the lifetime of > the > > object that is the WebContentsObserver, just the View that it gave out, right? > > Hmm, I guess not. It depends now on PowerSaveBlockerImpl::Delegate also being a > WebContentsObserver itself, so that gets nulled when the WebContents goes away, > if I understand. > > I guess instead then, I could have three callers of InitDisplaySleepBlocker() > clear the provided view in WebContentsDestroyed. That seems relatively > straightforward. (?) Yeah that should work. Or maybe InitDisplaySleepBlocker can take a WeakPtr<ui::ViewAndroid>. > > > > > > > > > For this CL, it's kinda hard to reason about the lifetime of > > > RenderFrameDevToolsAgentHost, since it's refcounted. > > > > > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > > File content/browser/power_save_blocker_android.cc (right): > > > > > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > > content/browser/power_save_blocker_android.cc:7: #include "base/location.h" > > > is this needed?
Patchset #9 (id:150001) has been deleted
Patchset #10 (id:190001) has been deleted
Patchset #9 (id:170001) has been deleted
Patchset #10 (id:230001) has been deleted
Patchset #11 (id:270001) has been deleted
Patchset #11 (id:290001) has been deleted
Patchset #10 (id:250001) has been deleted
On 2016/05/31 20:56:29, boliu wrote: > On 2016/05/31 20:48:10, scottmg wrote: > > On 2016/05/31 20:02:38, scottmg wrote: > > > On 2016/05/31 17:23:44, boliu wrote: > > > > hmm, code no longer handles the case of PowerSaveBlockerImpl::Delegate > > > outliving > > > > WebContents/ViewAndroid. previously this was done with WebContentsObserver > > > > nulling out the web_contents() pointer. > > > > > > Thanks, I missed that subtlety. > > > > > > Does it seem correct to pass a new interface into InitDisplaySleepBlocker() > > that > > > can then be used to call back to the holder of web_contents() to provide the > > > view if it's still around? That is, we're not worried about the lifetime of > > the > > > object that is the WebContentsObserver, just the View that it gave out, > right? > > > > Hmm, I guess not. It depends now on PowerSaveBlockerImpl::Delegate also being > a > > WebContentsObserver itself, so that gets nulled when the WebContents goes > away, > > if I understand. > > > > I guess instead then, I could have three callers of InitDisplaySleepBlocker() > > clear the provided view in WebContentsDestroyed. That seems relatively > > straightforward. (?) > > Yeah that should work. > > Or maybe InitDisplaySleepBlocker can take a WeakPtr<ui::ViewAndroid>. I tried WeakPtr (see ps#9) as it seemed a bit nicer, but the WebView tests didn't work, it seems they want to have the PowerSave disabled on shutdown. So I've switched to a Clear function called from WebContentsDestroyed(). > > > > > > > > > > > > > > For this CL, it's kinda hard to reason about the lifetime of > > > > RenderFrameDevToolsAgentHost, since it's refcounted. > > > > > > > > > > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > > > File content/browser/power_save_blocker_android.cc (right): > > > > > > > > > > > > > > https://codereview.chromium.org/2003803002/diff/130001/content/browser/power_... > > > > content/browser/power_save_blocker_android.cc:7: #include > "base/location.h" > > > > is this needed?
https://codereview.chromium.org/2003803002/diff/310001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/310001/content/browser/power_... content/browser/power_save_blocker_android.cc:59: if (view_android_ && !view_android_->GetViewAndroidDelegate().is_null()) { the is_null check isn't actually "safe". in theory gc could run between this line and the body, and collect the object. So to do this safely, need to save the ScopedJavaLocalRef as a local variable, check is_null, and then call obj() to use it on the other hand, it's safe to assume GetViewAndroidDelegate() never returns null object, so maybe just skip this check altogether?
https://codereview.chromium.org/2003803002/diff/310001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/310001/content/browser/power_... content/browser/power_save_blocker_android.cc:59: if (view_android_ && !view_android_->GetViewAndroidDelegate().is_null()) { On 2016/06/01 21:37:07, boliu wrote: > the is_null check isn't actually "safe". in theory gc could run between this > line and the body, and collect the object. So to do this safely, need to save > the ScopedJavaLocalRef as a local variable, check is_null, and then call obj() > to use it > > on the other hand, it's safe to assume GetViewAndroidDelegate() never returns > null object, so maybe just skip this check altogether? Thanks, removed.
non-owner lgtm
lgtm https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... File content/browser/wake_lock/wake_lock_service_context.cc (right): https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... content/browser/wake_lock/wake_lock_service_context.cc:44: ->ClearViewForSleepBlocker(); Now that there are 2 downcasts, consider making wake_lock_ the Impl type, so that you only have to do the static_cast at CreatePowerSaveBlocker time (where it's also easier to verify that the cast is safe).
https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... File content/browser/wake_lock/wake_lock_service_context.cc (right): https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... content/browser/wake_lock/wake_lock_service_context.cc:44: ->ClearViewForSleepBlocker(); On 2016/06/01 22:01:11, ncarter wrote: > Now that there are 2 downcasts, consider making wake_lock_ the Impl type, so > that you only have to do the static_cast at CreatePowerSaveBlocker time (where > it's also easier to verify that the cast is safe). Or don't -- downcasting while assigning a unique_ptr can be a PITA, and it's probably worse than 2 static_casts.
https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... File content/browser/wake_lock/wake_lock_service_context.cc (right): https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... content/browser/wake_lock/wake_lock_service_context.cc:44: ->ClearViewForSleepBlocker(); On 2016/06/01 22:01:11, ncarter wrote: > Now that there are 2 downcasts, consider making wake_lock_ the Impl type, so > that you only have to do the static_cast at CreatePowerSaveBlocker time (where > it's also easier to verify that the cast is safe). Or don't -- downcasting while assigning a unique_ptr can be a PITA, and it's probably worse than 2 static_casts.
Patchset #12 (id:350001) has been deleted
The CQ bit was checked by scottmg@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003803002/390001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003803002/390001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by scottmg@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003803002/390001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003803002/390001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
Patchset #12 (id:370001) has been deleted
Patchset #12 (id:390001) has been deleted
The CQ bit was checked by scottmg@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003803002/450001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2003803002/450001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
Patchset #12 (id:410001) has been deleted
Patchset #13 (id:450001) has been deleted
Patchset #12 (id:430001) has been deleted
Patchset #12 (id:470001) has been deleted
Hi, finally got back to this and had to end up switching back to a WeakPtr because of some subtlety in the shutdown order that didn't work when just clearing the View during WebContentsDestroyed(). Sorry for the back and forth, but could you please look again?
lgtm let actual owner decide if my comments have merit :p https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... File content/browser/devtools/render_frame_devtools_agent_host.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... content/browser/devtools/render_frame_devtools_agent_host.cc:763: if (view_weak_factory_) view_weak_factory_.reset(); everywhere? https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... content/browser/power_save_blocker_android.cc:92: base::WeakPtr<ui::ViewAndroid> view_android) { should parameter be const&?
lgtm https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... File content/browser/devtools/render_frame_devtools_agent_host.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... content/browser/devtools/render_frame_devtools_agent_host.cc:763: if (view_weak_factory_) On 2016/06/13 14:56:43, boliu wrote: > view_weak_factory_.reset(); everywhere? I agree with boliu; otherwise you have a dangling NativeView ptr inside the weak factory. https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... content/browser/power_save_blocker_android.cc:92: base::WeakPtr<ui::ViewAndroid> view_android) { On 2016/06/13 14:56:43, boliu wrote: > should parameter be const&? I imagine const& is better, since copying a WeakPtr involves a refcount bump.
Thanks! https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... File content/browser/devtools/render_frame_devtools_agent_host.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/devtoo... content/browser/devtools/render_frame_devtools_agent_host.cc:763: if (view_weak_factory_) On 2016/06/13 14:56:43, boliu wrote: > view_weak_factory_.reset(); everywhere? Done. https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... File content/browser/power_save_blocker_android.cc (right): https://codereview.chromium.org/2003803002/diff/490001/content/browser/power_... content/browser/power_save_blocker_android.cc:92: base::WeakPtr<ui::ViewAndroid> view_android) { On 2016/06/13 14:56:43, boliu wrote: > should parameter be const&? Done.
https://codereview.chromium.org/2003803002/diff/510001/content/browser/devtoo... File content/browser/devtools/render_frame_devtools_agent_host.cc (right): https://codereview.chromium.org/2003803002/diff/510001/content/browser/devtoo... content/browser/devtools/render_frame_devtools_agent_host.cc:766: } err, just reset, no need for if or invalidate?
https://codereview.chromium.org/2003803002/diff/510001/content/browser/devtoo... File content/browser/devtools/render_frame_devtools_agent_host.cc (right): https://codereview.chromium.org/2003803002/diff/510001/content/browser/devtoo... content/browser/devtools/render_frame_devtools_agent_host.cc:766: } On 2016/06/13 18:54:45, boliu wrote: > err, just reset, no need for if or invalidate? Oops, done.
The CQ bit was checked by scottmg@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from nick@chromium.org, boliu@chromium.org Link to the patchset: https://codereview.chromium.org/2003803002/#ps530001 (title: "only .reset()")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2003803002/530001
Message was sent while issue was closed.
Description was changed from ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com, content_browsertests ========== to ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com, content_browsertests ==========
Message was sent while issue was closed.
Committed patchset #14 (id:530001)
Message was sent while issue was closed.
CQ bit was unchecked
Message was sent while issue was closed.
Description was changed from ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com, content_browsertests ========== to ========== Remove dependency of power_save_blocker_android on various content bits BUG=612337,612563 TEST=start/stop video on m.youtube.com, content_browsertests Committed: https://crrev.com/a25943038ebc706537cdd5e6229924c53217ed31 Cr-Commit-Position: refs/heads/master@{#399549} ==========
Message was sent while issue was closed.
Patchset 14 (id:??) landed as https://crrev.com/a25943038ebc706537cdd5e6229924c53217ed31 Cr-Commit-Position: refs/heads/master@{#399549}
Message was sent while issue was closed.
On 2016/06/01 22:02:57, ncarter wrote: > https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... > File content/browser/wake_lock/wake_lock_service_context.cc (right): > > https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... > content/browser/wake_lock/wake_lock_service_context.cc:44: > ->ClearViewForSleepBlocker(); > On 2016/06/01 22:01:11, ncarter wrote: > > Now that there are 2 downcasts, consider making wake_lock_ the Impl type, so > > that you only have to do the static_cast at CreatePowerSaveBlocker time (where > > it's also easier to verify that the cast is safe). > > Or don't -- downcasting while assigning a unique_ptr can be a PITA, and it's > probably worse than 2 static_casts. [ Thread necromancy, but just FYI: after moving this all to //device, the split of PowerSaveBlocker and PowerSaveBlockerImpl is no longer necessary, so the downcast is gone. \o/ ]
Message was sent while issue was closed.
Hooray. On Mon, Jun 20, 2016 at 3:07 PM, <scottmg@chromium.org> wrote: > On 2016/06/01 22:02:57, ncarter wrote: > > > > https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... > > File content/browser/wake_lock/wake_lock_service_context.cc (right): > > > > > > https://codereview.chromium.org/2003803002/diff/330001/content/browser/wake_l... > > content/browser/wake_lock/wake_lock_service_context.cc:44: > > ->ClearViewForSleepBlocker(); > > On 2016/06/01 22:01:11, ncarter wrote: > > > Now that there are 2 downcasts, consider making wake_lock_ the Impl > type, so > > > that you only have to do the static_cast at CreatePowerSaveBlocker time > (where > > > it's also easier to verify that the cast is safe). > > > > Or don't -- downcasting while assigning a unique_ptr can be a PITA, and > it's > > probably worse than 2 static_casts. > > [ Thread necromancy, but just FYI: after moving this all to //device, the > split > of PowerSaveBlocker and PowerSaveBlockerImpl is no longer necessary, so the > downcast is gone. \o/ ] > > https://codereview.chromium.org/2003803002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org. |
