Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/download/download_manager.h" | 5 #include "content/browser/download/download_manager.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
| 18 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "content/browser/browser_context.h" | 20 #include "content/browser/browser_context.h" |
| 21 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
| 22 #include "content/browser/content_browser_client.h" | 22 #include "content/browser/content_browser_client.h" |
| 23 #include "content/browser/download/download_create_info.h" | 23 #include "content/browser/download/download_create_info.h" |
| 24 #include "content/browser/download/download_file_manager.h" | 24 #include "content/browser/download/download_file_manager.h" |
| 25 #include "content/browser/download/download_item.h" | 25 #include "content/browser/download/download_item.h" |
| 26 #include "content/browser/download/download_manager_delegate.h" | 26 #include "content/browser/download/download_manager_delegate.h" |
| 27 #include "content/browser/download/download_persistent_store_info.h" | 27 #include "content/browser/download/download_persistent_store_info.h" |
| 28 #include "content/browser/download/download_query.h" | |
| 28 #include "content/browser/download/download_status_updater.h" | 29 #include "content/browser/download/download_status_updater.h" |
| 29 #include "content/browser/renderer_host/render_process_host.h" | 30 #include "content/browser/renderer_host/render_process_host.h" |
| 30 #include "content/browser/renderer_host/render_view_host.h" | 31 #include "content/browser/renderer_host/render_view_host.h" |
| 31 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 32 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 32 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
| 33 #include "content/common/content_notification_types.h" | 34 #include "content/common/content_notification_types.h" |
| 34 #include "content/common/notification_service.h" | 35 #include "content/common/notification_service.h" |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 DCHECK(result); | 166 DCHECK(result); |
| 166 | 167 |
| 167 for (DownloadMap::iterator it = history_downloads_.begin(); | 168 for (DownloadMap::iterator it = history_downloads_.begin(); |
| 168 it != history_downloads_.end(); ++it) { | 169 it != history_downloads_.end(); ++it) { |
| 169 if (!it->second->is_temporary() && | 170 if (!it->second->is_temporary() && |
| 170 (dir_path.empty() || it->second->full_path().DirName() == dir_path)) | 171 (dir_path.empty() || it->second->full_path().DirName() == dir_path)) |
| 171 result->push_back(it->second); | 172 result->push_back(it->second); |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 | 175 |
| 176 bool DownloadManager::Search(const download_util::DownloadQuery& query, | |
| 177 std::string* error_msg, | |
| 178 DownloadVector* results, | |
| 179 base::ListValue* json_results) const { | |
| 180 DownloadVector default_results; | |
| 181 if (results== NULL) | |
| 182 results = &default_results; | |
| 183 results->clear(); | |
|
cbentzel
2011/10/10 14:35:30
How big is this? Is downloads_ unbounded?
benjhayden
2011/10/13 14:07:34
AFAIK yes.
| |
| 184 for (DownloadSet::const_iterator it = downloads_.begin(); | |
| 185 it != downloads_.end(); ++it) { | |
| 186 results->push_back(*it); | |
| 187 } | |
| 188 return query.Search(results, error_msg, json_results); | |
| 189 } | |
| 190 | |
| 175 void DownloadManager::SearchDownloads(const string16& query, | 191 void DownloadManager::SearchDownloads(const string16& query, |
| 176 DownloadVector* result) { | 192 DownloadVector* result) { |
| 177 string16 query_lower(base::i18n::ToLower(query)); | 193 string16 query_lower(base::i18n::ToLower(query)); |
| 178 | 194 |
| 179 for (DownloadMap::iterator it = history_downloads_.begin(); | 195 for (DownloadMap::iterator it = history_downloads_.begin(); |
| 180 it != history_downloads_.end(); ++it) { | 196 it != history_downloads_.end(); ++it) { |
| 181 DownloadItem* download_item = it->second; | 197 DownloadItem* download_item = it->second; |
| 182 | 198 |
| 183 if (download_item->is_temporary()) | 199 if (download_item->is_temporary()) |
| 184 continue; | 200 continue; |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 DCHECK(ContainsKey(save_page_downloads_, download->id())); | 1077 DCHECK(ContainsKey(save_page_downloads_, download->id())); |
| 1062 save_page_downloads_.erase(download->id()); | 1078 save_page_downloads_.erase(download->id()); |
| 1063 | 1079 |
| 1064 if (download->IsComplete()) | 1080 if (download->IsComplete()) |
| 1065 NotificationService::current()->Notify( | 1081 NotificationService::current()->Notify( |
| 1066 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 1082 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 1067 Source<DownloadManager>(this), | 1083 Source<DownloadManager>(this), |
| 1068 Details<DownloadItem>(download)); | 1084 Details<DownloadItem>(download)); |
| 1069 } | 1085 } |
| 1070 } | 1086 } |
| OLD | NEW |