| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> |
| 10 |
| 9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" |
| 10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 13 | 16 |
| 14 class ChromeDownloadManagerDelegate; | 17 class ChromeDownloadManagerDelegate; |
| 15 class DownloadManager; | 18 class DownloadManager; |
| 16 class Profile; | 19 class Profile; |
| 17 class DownloadIdFactory; | 20 class DownloadIdFactory; |
| 18 | 21 |
| 19 // Owning class for DownloadManager (content) and | 22 // Owning class for DownloadManager (content) and |
| 20 // ChromeDownloadManagerDelegate (chrome) | 23 // ChromeDownloadManagerDelegate (chrome) |
| 21 class DownloadService : public ProfileKeyedService { | 24 class DownloadService : public ProfileKeyedService { |
| 22 public: | 25 public: |
| 23 explicit DownloadService(Profile* profile); | 26 explicit DownloadService(Profile* profile); |
| 24 virtual ~DownloadService(); | 27 virtual ~DownloadService(); |
| 25 | 28 |
| 26 DownloadIdFactory* GetDownloadIdFactory() const; | 29 DownloadIdFactory* GetDownloadIdFactory() const; |
| 27 | 30 |
| 31 // Register a callback to be called whenever the DownloadManager is created. |
| 32 typedef base::Callback<void(DownloadManager*)> OnManagerCreatedCallback; |
| 33 void OnManagerCreated(const OnManagerCreatedCallback& cb); |
| 34 |
| 28 // Get the download manager. Creates the download manager if | 35 // Get the download manager. Creates the download manager if |
| 29 // it does not already exist. | 36 // it does not already exist. |
| 30 DownloadManager* GetDownloadManager(); | 37 DownloadManager* GetDownloadManager(); |
| 31 | 38 |
| 32 // Has a download manager been created? (By calling above function.) | 39 // Has a download manager been created? (By calling above function.) |
| 33 bool HasCreatedDownloadManager(); | 40 bool HasCreatedDownloadManager(); |
| 34 | 41 |
| 35 // Number of downloads associated with this instance of the service. | 42 // Number of downloads associated with this instance of the service. |
| 36 int DownloadCount() const; | 43 int DownloadCount() const; |
| 37 | 44 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 57 // Both of these objects are owned by this class. | 64 // Both of these objects are owned by this class. |
| 58 // DownloadManager is RefCountedThreadSafe because of references | 65 // DownloadManager is RefCountedThreadSafe because of references |
| 59 // from DownloadFile objects on the FILE thread, and may need to be | 66 // from DownloadFile objects on the FILE thread, and may need to be |
| 60 // kept alive until those objects are deleted. | 67 // kept alive until those objects are deleted. |
| 61 // ChromeDownloadManagerDelegate may be the target of callbacks from | 68 // ChromeDownloadManagerDelegate may be the target of callbacks from |
| 62 // the history service/DB thread and must be kept alive for those | 69 // the history service/DB thread and must be kept alive for those |
| 63 // callbacks. | 70 // callbacks. |
| 64 scoped_refptr<DownloadManager> manager_; | 71 scoped_refptr<DownloadManager> manager_; |
| 65 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; | 72 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
| 66 | 73 |
| 74 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_; |
| 75 |
| 67 DISALLOW_COPY_AND_ASSIGN(DownloadService); | 76 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
| 68 }; | 77 }; |
| 69 | 78 |
| 70 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 79 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |