| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 13 |
| 14 class ChromeDownloadManagerDelegate; |
| 15 class DownloadManager; |
| 16 class Profile; |
| 17 |
| 18 // Owning class for DownloadManager (content) and |
| 19 // ChromeDownloadManagerDelegate (chrome) |
| 20 class DownloadService : public ProfileKeyedService { |
| 21 public: |
| 22 explicit DownloadService(Profile* profile); |
| 23 virtual ~DownloadService(); |
| 24 |
| 25 // Get the download manager. Creates the download manager if |
| 26 // it does not already exist. |
| 27 DownloadManager* GetDownloadManager(); |
| 28 |
| 29 // Has a download manager been created? (By calling above function.) |
| 30 bool HasCreatedDownloadManager(); |
| 31 |
| 32 // Sets the DownloadManagerDelegate associated with this object and |
| 33 // its DownloadManager. Takes ownership of |delegate|, and destroys |
| 34 // the previous delegate. For testing. |
| 35 void SetDownloadManagerDelegate(ChromeDownloadManagerDelegate* delegate); |
| 36 |
| 37 // Will be called to release references on other services as part |
| 38 // of Profile shutdown. |
| 39 virtual void Shutdown() OVERRIDE; |
| 40 |
| 41 private: |
| 42 bool download_manager_created_; |
| 43 Profile* profile_; |
| 44 |
| 45 // Both of these objects are owned by this class. |
| 46 // DownloadManager is RefCountedThreadSafe because of references |
| 47 // from DownloadFile objects on the FILE thread, and may need to be |
| 48 // kept alive until those objects are deleted. |
| 49 // ChromeDownloadManagerDelegate may be the target of callbacks from |
| 50 // the history service/DB thread and must be kept alive for those |
| 51 // callbacks. |
| 52 scoped_refptr<DownloadManager> manager_; |
| 53 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
| 56 }; |
| 57 |
| 58 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
| OLD | NEW |