OLD | NEW |
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 "chrome/browser/download/download_service.h" | 5 #include "chrome/browser/download/download_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
10 #include "chrome/browser/download/download_service_factory.h" | 10 #include "chrome/browser/download/download_service_factory.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 void DownloadService::OnManagerCreated( | 28 void DownloadService::OnManagerCreated( |
29 const DownloadService::OnManagerCreatedCallback& cb) { | 29 const DownloadService::OnManagerCreatedCallback& cb) { |
30 if (download_manager_created_) { | 30 if (download_manager_created_) { |
31 DownloadManager* dm = BrowserContext::GetDownloadManager(profile_); | 31 DownloadManager* dm = BrowserContext::GetDownloadManager(profile_); |
32 cb.Run(dm); | 32 cb.Run(dm); |
33 } else { | 33 } else { |
34 on_manager_created_callbacks_.push_back(cb); | 34 on_manager_created_callbacks_.push_back(cb); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 DownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() { | 38 ChromeDownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() { |
39 DCHECK(!download_manager_created_); | 39 DCHECK(!download_manager_created_); |
40 download_manager_created_ = true; | 40 download_manager_created_ = true; |
41 | 41 |
42 // In case the delegate has already been set by | 42 // In case the delegate has already been set by |
43 // SetDownloadManagerDelegateForTesting. | 43 // SetDownloadManagerDelegateForTesting. |
44 if (!manager_delegate_.get()) | 44 if (!manager_delegate_.get()) |
45 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); | 45 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); |
46 | 46 |
47 DownloadManager* dm = BrowserContext::GetDownloadManager(profile_); | 47 DownloadManager* dm = BrowserContext::GetDownloadManager(profile_); |
48 manager_delegate_->SetDownloadManager(dm); | 48 manager_delegate_->SetDownloadManager(dm); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (download_manager_created_) { | 102 if (download_manager_created_) { |
103 // Normally the DownloadManager would be shutdown later, after the Profile | 103 // Normally the DownloadManager would be shutdown later, after the Profile |
104 // goes away and BrowserContext's destructor runs. But that would be too | 104 // goes away and BrowserContext's destructor runs. But that would be too |
105 // late for us since we need to use the profile (indirectly through history | 105 // late for us since we need to use the profile (indirectly through history |
106 // code) when the DownloadManager is shutting down. So we shut it down | 106 // code) when the DownloadManager is shutting down. So we shut it down |
107 // manually earlier. See http://crbug.com/131692 | 107 // manually earlier. See http://crbug.com/131692 |
108 BrowserContext::GetDownloadManager(profile_)->Shutdown(); | 108 BrowserContext::GetDownloadManager(profile_)->Shutdown(); |
109 } | 109 } |
110 manager_delegate_.release(); | 110 manager_delegate_.release(); |
111 } | 111 } |
OLD | NEW |