Home | History | Annotate | Download | only in service

Lines Matching refs:DownloadRequest

144     // Keeps tracks of downloads in progress based on an attachment ID to DownloadRequest mapping.
145 final ConcurrentHashMap<Long, DownloadRequest> mDownloadsInProgress =
146 new ConcurrentHashMap<Long, DownloadRequest>();
169 static class DownloadRequest {
192 DownloadRequest(final int attPriority, final long attId) {
201 private DownloadRequest(final Context context, final Attachment attachment) {
214 private DownloadRequest(final DownloadRequest orig, final long newTime) {
239 if (!(object instanceof DownloadRequest)) return false;
240 final DownloadRequest req = (DownloadRequest)object;
247 * We need a class that allows us to prioritize a collection of {@link DownloadRequest} objects
249 * to be able to find a particular {@link DownloadRequest} by id or by reference for retrieval.
264 private static class DownloadComparator implements Comparator<DownloadRequest> {
266 public int compare(DownloadRequest req1, DownloadRequest req2) {
282 final PriorityQueue<DownloadRequest> mRequestQueue =
283 new PriorityQueue<DownloadRequest>(DEFAULT_SIZE, new DownloadComparator());
287 final ConcurrentHashMap<Long, DownloadRequest> mRequestMap =
288 new ConcurrentHashMap<Long, DownloadRequest>();
293 * @param request The {@link DownloadRequest} that should be added to our queue
296 public boolean addRequest(final DownloadRequest request)
307 LogUtils.d(LOG_TAG, "Not adding a DownloadRequest with an invalid attachment id");
310 debugTrace("Queuing DownloadRequest #%d", requestId);
318 debugTrace("DownloadRequest #%d was already in the queue");
326 * @param request The {@link DownloadRequest} that should be removed from our queue
330 public boolean removeRequest(final DownloadRequest request) {
335 debugTrace("Removing DownloadRequest #%d", request.mAttachmentId);
349 * @return The next {@link DownloadRequest} object or null if the queue is empty
351 public DownloadRequest getNextRequest() {
353 final DownloadRequest returnRequest;
362 debugTrace("Retrieved DownloadRequest #%d", returnRequest.mAttachmentId);
368 DownloadRequest} with the given ID (attachment ID)
370 * @return The associated {@link DownloadRequest} object or null if it does not exist
372 public DownloadRequest findRequestById(final long requestId) {
449 boolean validateDownloadRequest(final DownloadRequest dr, final int callbackTimeout,
454 LogUtils.d(LOG_TAG, "Timeout for DownloadRequest #%d ", dr.mAttachmentId);
469 final Collection<DownloadRequest> inProgressRequests =
471 for (DownloadRequest req: inProgressRequests) {
476 LogUtils.w(LOG_TAG, "Cancelling DownloadRequest #%d", req.mAttachmentId);
530 final DownloadRequest req = mDownloadsInProgress.get(attachmentId);
559 // Either way, the final updates to the DownloadRequest and attachment
751 DownloadRequest req = mDownloadQueue.findRequestById(att.mId);
771 req = new DownloadRequest(context, att);
860 final DownloadRequest req = mDownloadQueue.getNextRequest();
952 final DownloadRequest req = new DownloadRequest(this, att);
973 * Attempt to execute the DownloadRequest, enforcing the maximum downloads per account
975 * @param req the DownloadRequest
978 synchronized boolean tryStartDownload(final DownloadRequest req) {
1004 * @param req the DownloadRequest
1007 private void startDownload(final EmailServiceProxy service, final DownloadRequest req)
1018 synchronized void cancelDownload(final DownloadRequest req) {
1029 // The time field of DownloadRequest is final, because it's unsafe to change it
1030 // as long as the DownloadRequest is in the DownloadSet. It's needed for the
1032 // Instead, we'll create a new DownloadRequest with an updated time.
1034 final DownloadRequest newReq = new DownloadRequest(req, SystemClock.elapsedRealtime());
1067 final DownloadRequest req = mDownloadQueue.findRequestById(attachmentId);
1199 for (final DownloadRequest req: mDownloadsInProgress.values()) {
1295 for (final DownloadRequest req : mDownloadsInProgress.values()) {
1296 LogUtils.d(LOG_TAG, "--BEGIN DownloadRequest DUMP--");
1330 for (final DownloadRequest req : mDownloadQueue.mRequestMap.values()) {