Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
| 6 | 6 |
| 7 import android.content.ComponentName; | 7 import android.content.ComponentName; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.ServiceConnection; | 10 import android.content.ServiceConnection; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 mBoundService = service; | 104 mBoundService = service; |
| 105 } | 105 } |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * Handles all the pending notifications that hasn't been processed. | 108 * Handles all the pending notifications that hasn't been processed. |
| 109 */ | 109 */ |
| 110 @VisibleForTesting | 110 @VisibleForTesting |
| 111 void handlePendingNotifications() { | 111 void handlePendingNotifications() { |
| 112 if (mPendingNotifications.isEmpty()) return; | 112 if (mPendingNotifications.isEmpty()) return; |
| 113 for (int i = 0; i < mPendingNotifications.size(); i++) { | 113 for (int i = 0; i < mPendingNotifications.size(); i++) { |
| 114 // If we lose the service mid-loop retrigger the service load and qu it. | 114 // If we lose the service mid-loop retrigger the service load and qu it. |
|
qinmin
2017/03/23 23:21:00
can this actually happen in the middle of a runnin
David Trainor- moved to gerrit
2017/03/24 00:32:35
I think the service can try to stop itself if it h
qinmin
2017/03/24 05:05:09
you mean service.stopself()? I don't think that ma
David Trainor- moved to gerrit
2017/03/25 03:56:24
Gah lost a big reply by closing the tab :(. So tl
| |
| 115 if (mBoundService == null) { | 115 if (mBoundService == null) { |
| 116 startAndBindToServiceIfNeeded(); | 116 startAndBindToServiceIfNeeded(); |
| 117 // Prune the list by pulling out the items we've already process ed. | |
| 118 mPendingNotifications = new ArrayList<PendingNotificationInfo>( | |
| 119 mPendingNotifications.subList(i, mPendingNotifications.s ize())); | |
| 117 return; | 120 return; |
| 118 } | 121 } |
| 119 updateDownloadNotification( | 122 updateDownloadNotification( |
| 120 mPendingNotifications.get(i), i == mPendingNotifications.siz e() - 1); | 123 mPendingNotifications.get(i), i == mPendingNotifications.siz e() - 1); |
| 121 } | 124 } |
| 122 mPendingNotifications.clear(); | 125 mPendingNotifications.clear(); |
| 123 } | 126 } |
| 124 | 127 |
| 125 /** | 128 /** |
| 126 * Starts and binds to the download notification service if needed. | 129 * Starts and binds to the download notification service if needed. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 default: | 301 default: |
| 299 assert false; | 302 assert false; |
| 300 } | 303 } |
| 301 | 304 |
| 302 // Don't need to expose the notification id to ignore. Cancel will auto matically call this | 305 // Don't need to expose the notification id to ignore. Cancel will auto matically call this |
| 303 // method as well and pass it in. | 306 // method as well and pass it in. |
| 304 if (mBoundService != null) mBoundService.hideSummaryNotificationIfNecess ary(-1); | 307 if (mBoundService != null) mBoundService.hideSummaryNotificationIfNecess ary(-1); |
| 305 if (autoRelease) unbindServiceIfNeeded(); | 308 if (autoRelease) unbindServiceIfNeeded(); |
| 306 } | 309 } |
| 307 } | 310 } |
| OLD | NEW |