| 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class DownloadService : public KeyedService { | 24 class DownloadService : public KeyedService { |
| 25 public: | 25 public: |
| 26 explicit DownloadService(Profile* profile); | 26 explicit DownloadService(Profile* profile); |
| 27 virtual ~DownloadService(); | 27 virtual ~DownloadService(); |
| 28 | 28 |
| 29 // Get the download manager delegate, creating it if it doesn't already exist. | 29 // Get the download manager delegate, creating it if it doesn't already exist. |
| 30 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); | 30 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); |
| 31 | 31 |
| 32 // Get the interface to the history system. Returns NULL if profile is | 32 // Get the interface to the history system. Returns NULL if profile is |
| 33 // incognito or if the DownloadManager hasn't been created yet or if there is | 33 // incognito or if the DownloadManager hasn't been created yet or if there is |
| 34 // no HistoryService for profile. | 34 // no HistoryService for profile. Virtual for testing. |
| 35 DownloadHistory* GetDownloadHistory(); | 35 virtual DownloadHistory* GetDownloadHistory(); |
| 36 | 36 |
| 37 #if !defined(OS_ANDROID) | 37 #if !defined(OS_ANDROID) |
| 38 ExtensionDownloadsEventRouter* GetExtensionEventRouter() { | 38 ExtensionDownloadsEventRouter* GetExtensionEventRouter() { |
| 39 return extension_event_router_.get(); | 39 return extension_event_router_.get(); |
| 40 } | 40 } |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 // Has a download manager been created? | 43 // Has a download manager been created? |
| 44 bool HasCreatedDownloadManager(); | 44 bool HasCreatedDownloadManager(); |
| 45 | 45 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // ChromeDownloadManagerDelegate may be the target of callbacks from | 77 // ChromeDownloadManagerDelegate may be the target of callbacks from |
| 78 // the history service/DB thread and must be kept alive for those | 78 // the history service/DB thread and must be kept alive for those |
| 79 // callbacks. | 79 // callbacks. |
| 80 scoped_ptr<ChromeDownloadManagerDelegate> manager_delegate_; | 80 scoped_ptr<ChromeDownloadManagerDelegate> manager_delegate_; |
| 81 | 81 |
| 82 scoped_ptr<DownloadHistory> download_history_; | 82 scoped_ptr<DownloadHistory> download_history_; |
| 83 | 83 |
| 84 // The UI controller is responsible for observing the download manager and | 84 // The UI controller is responsible for observing the download manager and |
| 85 // notifying the UI of any new downloads. Its lifetime matches that of the | 85 // notifying the UI of any new downloads. Its lifetime matches that of the |
| 86 // associated download manager. | 86 // associated download manager. |
| 87 // Note on destruction order: download_ui_ depends on download_history_ and |
| 88 // should be destroyed before the latter. |
| 87 scoped_ptr<DownloadUIController> download_ui_; | 89 scoped_ptr<DownloadUIController> download_ui_; |
| 88 | 90 |
| 89 // On Android, GET downloads are not handled by the DownloadManager. | 91 // On Android, GET downloads are not handled by the DownloadManager. |
| 90 // Once we have extensions on android, we probably need the EventRouter | 92 // Once we have extensions on android, we probably need the EventRouter |
| 91 // in ContentViewDownloadDelegate which knows about both GET and POST | 93 // in ContentViewDownloadDelegate which knows about both GET and POST |
| 92 // downloads. | 94 // downloads. |
| 93 #if !defined(OS_ANDROID) | 95 #if !defined(OS_ANDROID) |
| 94 // The ExtensionDownloadsEventRouter dispatches download creation, change, and | 96 // The ExtensionDownloadsEventRouter dispatches download creation, change, and |
| 95 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a | 97 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a |
| 96 // chrome-level concept and its lifetime should match DownloadManager. There | 98 // chrome-level concept and its lifetime should match DownloadManager. There |
| 97 // should be a separate EDER for on-record and off-record managers. | 99 // should be a separate EDER for on-record and off-record managers. |
| 98 // There does not appear to be a separate ExtensionSystem for on-record and | 100 // There does not appear to be a separate ExtensionSystem for on-record and |
| 99 // off-record profiles, so ExtensionSystem cannot own the EDER. | 101 // off-record profiles, so ExtensionSystem cannot own the EDER. |
| 100 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_; | 102 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_; |
| 101 #endif | 103 #endif |
| 102 | 104 |
| 103 DISALLOW_COPY_AND_ASSIGN(DownloadService); | 105 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 108 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |