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

Issue 2759193003: Downloads: Properly prune processed actions (Closed)

Created:
3 years, 9 months ago by David Trainor- moved to gerrit
Modified:
3 years, 8 months ago
Reviewers:
qinmin
CC:
chromium-reviews, asanka, agrieve+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Downloads: Properly prune processed actions If the DownloadNotificationService is torn down during the processing of events, make sure we properly clean up the events we did properly send to the service. Right now we don't modify the list, which means when the service is restarted we'll process the original few items again. BUG=703212

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -0 lines) Patch
M chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java View 1 chunk +3 lines, -0 lines 4 comments Download

Depends on Patchset:

Messages

Total messages: 13 (6 generated)
David Trainor- moved to gerrit
ptal thanks!
3 years, 9 months ago (2017-03-23 02:17:57 UTC) #6
qinmin
https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java File chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java (right): https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java#newcode114 chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java:114: // If we lose the service mid-loop retrigger the ...
3 years, 9 months ago (2017-03-23 23:21:00 UTC) #7
David Trainor- moved to gerrit
https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java File chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java (right): https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java#newcode114 chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java:114: // If we lose the service mid-loop retrigger the ...
3 years, 9 months ago (2017-03-24 00:32:36 UTC) #8
qinmin
https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java File chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java (right): https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java#newcode114 chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java:114: // If we lose the service mid-loop retrigger the ...
3 years, 9 months ago (2017-03-24 05:05:09 UTC) #9
David Trainor- moved to gerrit
On 2017/03/24 05:05:09, qinmin wrote: > https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java > File > chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java > (right): > > ...
3 years, 9 months ago (2017-03-24 17:34:31 UTC) #10
qinmin
On 2017/03/24 17:34:31, David Trainor-ping if over 24h wrote: > On 2017/03/24 05:05:09, qinmin wrote: ...
3 years, 9 months ago (2017-03-24 20:53:59 UTC) #11
David Trainor- moved to gerrit
3 years, 9 months ago (2017-03-25 03:56:25 UTC) #12
https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org...
File
chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
(right):

https://codereview.chromium.org/2759193003/diff/1/chrome/android/java/src/org...
chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java:114:
// If we lose the service mid-loop retrigger the service load and quit.
On 2017/03/24 05:05:09, qinmin wrote:
> On 2017/03/24 00:32:35, David Trainor-ping if over 24h wrote:
> > On 2017/03/23 23:21:00, qinmin wrote:
> > > can this actually happen in the middle of a running function? 
> > > autoRelease only happen for the last notification in the list, and all
other
> > > method that tries to call unbindService happens on the same UI thread,
> right?
> > 
> > I think the service can try to stop itself if it has no more notifications
to
> > show, which could in theory make it attempt to shutdown (e.g. the cancel
> case?).
> 
> you mean service.stopself()? I don't think that matters. Stopself() won't be
> executed immediately, it still put a task on a message queue to wait the
current
> code to finish.

Gah lost a big reply by closing the tab :(.  So tl;dr there is an issue but it
might not end up being a problem.  The issue is Service.stopSelf() doesn't stop
the service if there are clients bound.  But once the client unbinds the service
will be destroyed.  To make this deterministic and make sense, I just have the
service tell this notifier to unbind itself now so we don't have this weird 'in
between' state.

If we don't manually tell the service to unbind, we'll only unbind when we have
no running downloads.  So the scenario is:

Download ID | State    | Batch
1             PROGRESS   1
1             CANCEL     2   // Service calls stopSelf.  Destroy gets queued.
2             PROGRESS   2   // Gets processed because we're still bound.
                             // Now we are a foreground service that will die?
2             PAUSED     3   // No longer foreground.  Unbind.  Does the service
die?

If the service dies here, we should be good as long as we've detached the
notification.  I need to test what happens.  I can recreate it this weekend or
on Monday.

If this isn't a problem I need to remove the callback method.  I'll write up a
patch that does that and send it to you while I investigate.  Thanks!

Powered by Google App Engine
This is Rietveld 408576698