OLD | NEW |
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 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { | 112 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { |
113 } | 113 } |
114 | 114 |
115 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { | 115 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { |
116 download_manager_ = dm; | 116 download_manager_ = dm; |
117 download_history_.reset(new DownloadHistory(profile_)); | 117 download_history_.reset(new DownloadHistory(profile_)); |
118 download_history_->Load( | 118 download_history_->Load( |
119 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, | 119 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, |
120 base::Unretained(dm))); | 120 base::Unretained(dm))); |
121 extension_event_router_.reset(new ExtensionDownloadsEventRouter(profile_)); | 121 extension_event_router_.reset(new ExtensionDownloadsEventRouter( |
| 122 profile_, download_manager_)); |
122 } | 123 } |
123 | 124 |
124 void ChromeDownloadManagerDelegate::Shutdown() { | 125 void ChromeDownloadManagerDelegate::Shutdown() { |
125 download_history_.reset(); | 126 download_history_.reset(); |
126 download_prefs_.reset(); | 127 download_prefs_.reset(); |
127 } | 128 } |
128 | 129 |
129 DownloadId ChromeDownloadManagerDelegate::GetNextId() { | 130 DownloadId ChromeDownloadManagerDelegate::GetNextId() { |
130 if (!profile_->IsOffTheRecord()) | 131 if (!profile_->IsOffTheRecord()) |
131 return DownloadId(this, next_download_id_++); | 132 return DownloadId(this, next_download_id_++); |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 int32 download_id, int64 db_handle) { | 851 int32 download_id, int64 db_handle) { |
851 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 852 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
852 // call this function with an invalid |db_handle|. For instance, this can | 853 // call this function with an invalid |db_handle|. For instance, this can |
853 // happen when the history database is offline. We cannot have multiple | 854 // happen when the history database is offline. We cannot have multiple |
854 // DownloadItems with the same invalid db_handle, so we need to assign a | 855 // DownloadItems with the same invalid db_handle, so we need to assign a |
855 // unique |db_handle| here. | 856 // unique |db_handle| here. |
856 if (db_handle == DownloadItem::kUninitializedHandle) | 857 if (db_handle == DownloadItem::kUninitializedHandle) |
857 db_handle = download_history_->GetNextFakeDbHandle(); | 858 db_handle = download_history_->GetNextFakeDbHandle(); |
858 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 859 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
859 } | 860 } |
OLD | NEW |