Chromium Code Reviews| 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 Profile; | |
| 15 class DownloadManager; | |
| 16 class ChromeDownloadManagerDelegate; | |
|
Miranda Callahan
2011/10/06 20:07:32
nit: alphasorting
Randy Smith (Not in Mondays)
2011/10/08 23:46:54
Done.
| |
| 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. | |
|
Miranda Callahan
2011/10/06 20:07:32
Could you add to this comment that this function h
Randy Smith (Not in Mondays)
2011/10/08 23:46:54
Done.
| |
| 26 DownloadManager* GetDownloadManager(); | |
| 27 | |
| 28 // Has a download manager been created? (By calling above function.) | |
| 29 bool HasCreatedDownloadManager(); | |
| 30 | |
| 31 // Set the DownloadManagerDelegate associated with this object and | |
|
Miranda Callahan
2011/10/06 20:07:32
Parallel construction nit: could you change to "Se
Randy Smith (Not in Mondays)
2011/10/08 23:46:54
No problem--thanks for calling it out. Done.
| |
| 32 // its DownloadManager. Takes ownership of |delegate|, and destroys | |
| 33 // the previous delegate. For testing. | |
| 34 void SetDownloadManagerDelegate(ChromeDownloadManagerDelegate* delegate); | |
| 35 | |
| 36 // Will be called to release references on other services as part | |
| 37 // of Profile shutdown. | |
| 38 virtual void Shutdown() OVERRIDE; | |
| 39 | |
| 40 private: | |
| 41 bool download_manager_created_; | |
| 42 Profile* profile_; | |
| 43 | |
| 44 // Both of these objects are owned by this class. | |
| 45 // DownloadManager is RefCountedThreadSafe because of references | |
| 46 // from DownloadFile objects on the FILE thread, and may need to be | |
| 47 // kept alive until those objects are deleted. | |
| 48 // ChromeDownloadManagerDelegate may be the target of callbacks from | |
| 49 // the history service/DB thread and must be kept alive for those | |
| 50 // callbacks. | |
| 51 scoped_refptr<DownloadManager> manager_; | |
| 52 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(DownloadService); | |
| 55 }; | |
| 56 | |
| 57 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | |
| OLD | NEW |