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

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

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_service.cc
diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc
index 68a4934f0f0493ff27c8522bca3abf515c5a7db6..97139af3d602782ac5441a5d39bfd75a2bd928bb 100644
--- a/chrome/browser/download/download_service.cc
+++ b/chrome/browser/download/download_service.cc
@@ -7,8 +7,11 @@
#include "base/callback.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
+#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_status_updater.h"
+#include "chrome/browser/history/history.h"
+#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -52,11 +55,20 @@ ChromeDownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() {
manager_delegate_->SetDownloadManager(manager);
+ if (!profile_->IsOffTheRecord()) {
+ HistoryService* hs = HistoryServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (hs)
+ download_history_.reset(new DownloadHistory(
+ manager,
+ scoped_ptr<DownloadHistory::HistoryAdapter>(
+ new DownloadHistory::HistoryAdapter(hs))));
+ }
+
// Include this download manager in the set monitored by the
// global status updater.
g_browser_process->download_status_updater()->AddManager(manager);
- download_manager_created_ = true;
for (std::vector<OnManagerCreatedCallback>::iterator cb =
on_manager_created_callbacks_.begin();
cb != on_manager_created_callbacks_.end(); ++cb) {
@@ -67,6 +79,14 @@ ChromeDownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() {
return manager_delegate_.get();
}
+DownloadHistory* DownloadService::GetDownloadHistory() {
+ if (!download_manager_created_) {
+ GetDownloadManagerDelegate();
+ }
+ DCHECK(download_manager_created_);
+ return download_history_.get();
+}
+
bool DownloadService::HasCreatedDownloadManager() {
return download_manager_created_;
}
@@ -118,4 +138,5 @@ void DownloadService::Shutdown() {
BrowserContext::GetDownloadManager(profile_)->Shutdown();
}
manager_delegate_ = NULL;
+ download_history_.reset();
}

Powered by Google App Engine
This is Rietveld 408576698