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

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: @r166680 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. Returns NULL if profile is
39 // incognito or if the DownloadManager hasn't been created yet or if there is
40 // no HistoryService for profile.
41 DownloadHistory* GetDownloadHistory();
42
36 // Has a download manager been created? 43 // Has a download manager been created?
37 bool HasCreatedDownloadManager(); 44 bool HasCreatedDownloadManager();
38 45
39 // Number of downloads associated with this instance of the service. 46 // Number of downloads associated with this instance of the service.
40 int DownloadCount() const; 47 int DownloadCount() const;
41 48
42 // Number of downloads associated with all profiles. 49 // Number of downloads associated with all profiles.
43 static int DownloadCountAllProfiles(); 50 static int DownloadCountAllProfiles();
44 51
45 // Sets the DownloadManagerDelegate associated with this object and 52 // Sets the DownloadManagerDelegate associated with this object and
46 // its DownloadManager. Takes ownership of |delegate|, and destroys 53 // its DownloadManager. Takes ownership of |delegate|, and destroys
47 // the previous delegate. For testing. 54 // the previous delegate. For testing.
48 void SetDownloadManagerDelegateForTesting( 55 void SetDownloadManagerDelegateForTesting(
49 ChromeDownloadManagerDelegate* delegate); 56 ChromeDownloadManagerDelegate* delegate);
50 57
51 // Will be called to release references on other services as part 58 // Will be called to release references on other services as part
52 // of Profile shutdown. 59 // of Profile shutdown.
53 virtual void Shutdown() OVERRIDE; 60 virtual void Shutdown() OVERRIDE;
54 61
55 private: 62 private:
56 bool download_manager_created_; 63 bool download_manager_created_;
57 Profile* profile_; 64 Profile* profile_;
58 65
59 // ChromeDownloadManagerDelegate may be the target of callbacks from 66 // ChromeDownloadManagerDelegate may be the target of callbacks from
60 // the history service/DB thread and must be kept alive for those 67 // the history service/DB thread and must be kept alive for those
61 // callbacks. 68 // callbacks.
62 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; 69 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_;
63 70
71 scoped_ptr<DownloadHistory> download_history_;
72
64 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_; 73 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_;
65 74
66 DISALLOW_COPY_AND_ASSIGN(DownloadService); 75 DISALLOW_COPY_AND_ASSIGN(DownloadService);
67 }; 76 };
68 77
69 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ 78 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698