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

Side by Side Diff: content/browser/download/download_manager.cc

Issue 7825035: Implement chrome.experimental.downloads.search() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rewrite Created 9 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
« no previous file with comments | « content/browser/download/download_manager.h ('k') | content/browser/download/download_query.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 18 #include "build/build_config.h"
19 #include "content/browser/browser_context.h" 19 #include "content/browser/browser_context.h"
20 #include "content/browser/download/download_create_info.h" 20 #include "content/browser/download/download_create_info.h"
21 #include "content/browser/download/download_file_manager.h" 21 #include "content/browser/download/download_file_manager.h"
22 #include "content/browser/download/download_id_factory.h" 22 #include "content/browser/download/download_id_factory.h"
23 #include "content/browser/download/download_item.h" 23 #include "content/browser/download/download_item.h"
24 #include "content/browser/download/download_persistent_store_info.h" 24 #include "content/browser/download/download_persistent_store_info.h"
25 #include "content/browser/download/download_query.h"
25 #include "content/browser/download/download_stats.h" 26 #include "content/browser/download/download_stats.h"
26 #include "content/browser/download/download_status_updater.h" 27 #include "content/browser/download/download_status_updater.h"
27 #include "content/browser/download/interrupt_reasons.h" 28 #include "content/browser/download/interrupt_reasons.h"
28 #include "content/browser/renderer_host/render_process_host.h" 29 #include "content/browser/renderer_host/render_process_host.h"
29 #include "content/browser/renderer_host/render_view_host.h" 30 #include "content/browser/renderer_host/render_view_host.h"
30 #include "content/browser/renderer_host/resource_dispatcher_host.h" 31 #include "content/browser/renderer_host/resource_dispatcher_host.h"
31 #include "content/browser/tab_contents/tab_contents.h" 32 #include "content/browser/tab_contents/tab_contents.h"
32 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/content_browser_client.h" 34 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/download_manager_delegate.h" 35 #include "content/public/browser/download_manager_delegate.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 DCHECK(result); 185 DCHECK(result);
185 186
186 for (DownloadMap::iterator it = history_downloads_.begin(); 187 for (DownloadMap::iterator it = history_downloads_.begin();
187 it != history_downloads_.end(); ++it) { 188 it != history_downloads_.end(); ++it) {
188 if (!it->second->is_temporary() && 189 if (!it->second->is_temporary() &&
189 (dir_path.empty() || it->second->full_path().DirName() == dir_path)) 190 (dir_path.empty() || it->second->full_path().DirName() == dir_path))
190 result->push_back(it->second); 191 result->push_back(it->second);
191 } 192 }
192 } 193 }
193 194
195 void DownloadManager::Search(const download_util::DownloadQuery& query,
196 DownloadVector* results) const {
197 query.Search(downloads_.begin(), downloads_.end(), results);
198 }
199
194 void DownloadManager::SearchDownloads(const string16& query, 200 void DownloadManager::SearchDownloads(const string16& query,
195 DownloadVector* result) { 201 DownloadVector* result) {
196 string16 query_lower(base::i18n::ToLower(query)); 202 string16 query_lower(base::i18n::ToLower(query));
197 203
198 for (DownloadMap::iterator it = history_downloads_.begin(); 204 for (DownloadMap::iterator it = history_downloads_.begin();
199 it != history_downloads_.end(); ++it) { 205 it != history_downloads_.end(); ++it) {
200 DownloadItem* download_item = it->second; 206 DownloadItem* download_item = it->second;
201 207
202 if (download_item->is_temporary()) 208 if (download_item->is_temporary())
203 continue; 209 continue;
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { 1080 void DownloadManager::MarkDownloadOpened(DownloadItem* download) {
1075 delegate_->UpdateItemInPersistentStore(download); 1081 delegate_->UpdateItemInPersistentStore(download);
1076 int num_unopened = 0; 1082 int num_unopened = 0;
1077 for (DownloadMap::iterator it = history_downloads_.begin(); 1083 for (DownloadMap::iterator it = history_downloads_.begin();
1078 it != history_downloads_.end(); ++it) { 1084 it != history_downloads_.end(); ++it) {
1079 if (it->second->IsComplete() && !it->second->opened()) 1085 if (it->second->IsComplete() && !it->second->opened())
1080 ++num_unopened; 1086 ++num_unopened;
1081 } 1087 }
1082 download_stats::RecordOpensOutstanding(num_unopened); 1088 download_stats::RecordOpensOutstanding(num_unopened);
1083 } 1089 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager.h ('k') | content/browser/download/download_query.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698