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

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Add scoped COM initialization to quench a couple of assertion failures. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/download/download_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/supports_user_data.h" 22 #include "base/supports_user_data.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "content/browser/byte_stream.h" 25 #include "content/browser/byte_stream.h"
26 #include "content/browser/child_process_security_policy_impl.h" 26 #include "content/browser/child_process_security_policy_impl.h"
27 #include "content/browser/download/download_create_info.h" 27 #include "content/browser/download/download_create_info.h"
28 #include "content/browser/download/download_file_factory.h" 28 #include "content/browser/download/download_file_factory.h"
29 #include "content/browser/download/download_item_factory.h" 29 #include "content/browser/download/download_item_factory.h"
30 #include "content/browser/download/download_item_impl.h" 30 #include "content/browser/download/download_item_impl.h"
31 #include "content/browser/download/download_stats.h" 31 #include "content/browser/download/download_stats.h"
32 #include "content/browser/download/download_task_runner.h"
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" 33 #include "content/browser/loader/resource_dispatcher_host_impl.h"
33 #include "content/browser/loader/resource_request_info_impl.h" 34 #include "content/browser/loader/resource_request_info_impl.h"
34 #include "content/browser/renderer_host/render_view_host_impl.h" 35 #include "content/browser/renderer_host/render_view_host_impl.h"
35 #include "content/browser/web_contents/web_contents_impl.h" 36 #include "content/browser/web_contents/web_contents_impl.h"
36 #include "content/public/browser/browser_context.h" 37 #include "content/public/browser/browser_context.h"
37 #include "content/public/browser/content_browser_client.h" 38 #include "content/public/browser/content_browser_client.h"
38 #include "content/public/browser/download_interrupt_reasons.h" 39 #include "content/public/browser/download_interrupt_reasons.h"
39 #include "content/public/browser/download_manager_delegate.h" 40 #include "content/public/browser/download_manager_delegate.h"
40 #include "content/public/browser/download_url_parameters.h" 41 #include "content/public/browser/download_url_parameters.h"
41 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (item_iterator == downloads_.end() || 356 if (item_iterator == downloads_.end() ||
356 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { 357 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) {
357 // If the download is no longer known to the DownloadManager, then it was 358 // If the download is no longer known to the DownloadManager, then it was
358 // removed after it was resumed. Ignore. If the download is cancelled 359 // removed after it was resumed. Ignore. If the download is cancelled
359 // while resuming, then also ignore the request. 360 // while resuming, then also ignore the request.
360 info->request_handle->CancelRequest(true); 361 info->request_handle->CancelRequest(true);
361 if (!on_started.is_null()) 362 if (!on_started.is_null())
362 on_started.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); 363 on_started.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
363 // The ByteStreamReader lives and dies on the FILE thread. 364 // The ByteStreamReader lives and dies on the FILE thread.
364 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) 365 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE)
365 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, 366 GetDownloadTaskRunner()->DeleteSoon(FROM_HERE, stream.release());
366 stream.release());
367 return; 367 return;
368 } 368 }
369 download = item_iterator->second.get(); 369 download = item_iterator->second.get();
370 } 370 }
371 371
372 base::FilePath default_download_directory; 372 base::FilePath default_download_directory;
373 #if defined(USE_X11) && !defined(OS_CHROMEOS) 373 #if defined(USE_X11) && !defined(OS_CHROMEOS)
374 // TODO(thomasanderson): Remove this when all Linux distros with 374 // TODO(thomasanderson): Remove this when all Linux distros with
375 // versions of GTK lower than 3.14.7 are no longer supported. This 375 // versions of GTK lower than 3.14.7 are no longer supported. This
376 // should happen when support for Ubuntu Trusty and Debian Jessie 376 // should happen when support for Ubuntu Trusty and Debian Jessie
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 if (delegate_) 772 if (delegate_)
773 delegate_->OpenDownload(download); 773 delegate_->OpenDownload(download);
774 } 774 }
775 775
776 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 776 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
777 if (delegate_) 777 if (delegate_)
778 delegate_->ShowDownloadInShell(download); 778 delegate_->ShowDownloadInShell(download);
779 } 779 }
780 780
781 } // namespace content 781 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698