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 SetDownloadManagerDelegateForTesting( |
| 36 ChromeDownloadManagerDelegate* delegate); |
| 37 |
| 38 // Will be called to release references on other services as part |
| 39 // of Profile shutdown. |
| 40 virtual void Shutdown() OVERRIDE; |
| 41 |
| 42 private: |
| 43 bool download_manager_created_; |
| 44 Profile* profile_; |
| 45 |
| 46 // Both of these objects are owned by this class. |
| 47 // DownloadManager is RefCountedThreadSafe because of references |
| 48 // from DownloadFile objects on the FILE thread, and may need to be |
| 49 // kept alive until those objects are deleted. |
| 50 // ChromeDownloadManagerDelegate may be the target of callbacks from |
| 51 // the history service/DB thread and must be kept alive for those |
| 52 // callbacks. |
| 53 scoped_refptr<DownloadManager> manager_; |
| 54 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
OLD | NEW |