Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: chrome/browser/download/download_service.h

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r166491 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/profiles/profile_keyed_service.h" 14 #include "chrome/browser/profiles/profile_keyed_service.h"
14 15
15 class ChromeDownloadManagerDelegate; 16 class ChromeDownloadManagerDelegate;
17 class DownloadHistory;
16 class Profile; 18 class Profile;
17 19
18 namespace content { 20 namespace content {
19 class DownloadManager; 21 class DownloadManager;
20 } 22 }
21 23
22 // Owning class for ChromeDownloadManagerDelegate. 24 // Owning class for ChromeDownloadManagerDelegate.
23 class DownloadService : public ProfileKeyedService { 25 class DownloadService : public ProfileKeyedService {
24 public: 26 public:
25 explicit DownloadService(Profile* profile); 27 explicit DownloadService(Profile* profile);
26 virtual ~DownloadService(); 28 virtual ~DownloadService();
27 29
28 // Register a callback to be called whenever the DownloadManager is created. 30 // Register a callback to be called whenever the DownloadManager is created.
29 typedef base::Callback<void(content::DownloadManager*)> 31 typedef base::Callback<void(content::DownloadManager*)>
30 OnManagerCreatedCallback; 32 OnManagerCreatedCallback;
31 void OnManagerCreated(const OnManagerCreatedCallback& cb); 33 void OnManagerCreated(const OnManagerCreatedCallback& cb);
32 34
33 // Get the download manager delegate, creating it if it doesn't already exist. 35 // Get the download manager delegate, creating it if it doesn't already exist.
34 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); 36 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate();
35 37
38 // Get the interface to the history system.
39 DownloadHistory* GetDownloadHistory();
Randy Smith (Not in Mondays) 2012/11/07 21:10:29 Specify may be null if OTR.
benjhayden 2012/11/08 18:57:04 Done.
40
36 // Has a download manager been created? 41 // Has a download manager been created?
37 bool HasCreatedDownloadManager(); 42 bool HasCreatedDownloadManager();
38 43
39 // Number of downloads associated with this instance of the service. 44 // Number of downloads associated with this instance of the service.
40 int DownloadCount() const; 45 int DownloadCount() const;
41 46
42 // Number of downloads associated with all profiles. 47 // Number of downloads associated with all profiles.
43 static int DownloadCountAllProfiles(); 48 static int DownloadCountAllProfiles();
44 49
45 // Sets the DownloadManagerDelegate associated with this object and 50 // Sets the DownloadManagerDelegate associated with this object and
46 // its DownloadManager. Takes ownership of |delegate|, and destroys 51 // its DownloadManager. Takes ownership of |delegate|, and destroys
47 // the previous delegate. For testing. 52 // the previous delegate. For testing.
48 void SetDownloadManagerDelegateForTesting( 53 void SetDownloadManagerDelegateForTesting(
49 ChromeDownloadManagerDelegate* delegate); 54 ChromeDownloadManagerDelegate* delegate);
50 55
51 // Will be called to release references on other services as part 56 // Will be called to release references on other services as part
52 // of Profile shutdown. 57 // of Profile shutdown.
53 virtual void Shutdown() OVERRIDE; 58 virtual void Shutdown() OVERRIDE;
54 59
55 private: 60 private:
56 bool download_manager_created_; 61 bool download_manager_created_;
57 Profile* profile_; 62 Profile* profile_;
58 63
59 // ChromeDownloadManagerDelegate may be the target of callbacks from 64 // ChromeDownloadManagerDelegate may be the target of callbacks from
60 // the history service/DB thread and must be kept alive for those 65 // the history service/DB thread and must be kept alive for those
61 // callbacks. 66 // callbacks.
62 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; 67 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_;
63 68
69 scoped_ptr<DownloadHistory> download_history_;
70
64 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_; 71 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_;
65 72
66 DISALLOW_COPY_AND_ASSIGN(DownloadService); 73 DISALLOW_COPY_AND_ASSIGN(DownloadService);
67 }; 74 };
68 75
69 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ 76 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698