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

Unified Diff: chrome/browser/download/download_service.h

Issue 8135017: Refactor downloads into a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to LKGR to run try bots. Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_service.h
diff --git a/chrome/browser/download/download_service.h b/chrome/browser/download/download_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..f5287f7b19fea288ff2f2353875ef67b60ea28cc
--- /dev/null
+++ b/chrome/browser/download/download_service.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
+#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+
+class Profile;
+class DownloadManager;
+class ChromeDownloadManagerDelegate;
Miranda Callahan 2011/10/06 20:07:32 nit: alphasorting
Randy Smith (Not in Mondays) 2011/10/08 23:46:54 Done.
+
+// Owning class for DownloadManager (content) and
+// ChromeDownloadManagerDelegate (chrome)
+class DownloadService : public ProfileKeyedService {
+ public:
+ explicit DownloadService(Profile* profile);
+ virtual ~DownloadService();
+
+ // 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.
+ DownloadManager* GetDownloadManager();
+
+ // Has a download manager been created? (By calling above function.)
+ bool HasCreatedDownloadManager();
+
+ // 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.
+ // its DownloadManager. Takes ownership of |delegate|, and destroys
+ // the previous delegate. For testing.
+ void SetDownloadManagerDelegate(ChromeDownloadManagerDelegate* delegate);
+
+ // Will be called to release references on other services as part
+ // of Profile shutdown.
+ virtual void Shutdown() OVERRIDE;
+
+ private:
+ bool download_manager_created_;
+ Profile* profile_;
+
+ // Both of these objects are owned by this class.
+ // DownloadManager is RefCountedThreadSafe because of references
+ // from DownloadFile objects on the FILE thread, and may need to be
+ // kept alive until those objects are deleted.
+ // ChromeDownloadManagerDelegate may be the target of callbacks from
+ // the history service/DB thread and must be kept alive for those
+ // callbacks.
+ scoped_refptr<DownloadManager> manager_;
+ scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadService);
+};
+
+#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698