| 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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.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" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 // We'll have nothing more to report to the observers after this point. | 327 // We'll have nothing more to report to the observers after this point. |
| 328 observers_.Clear(); | 328 observers_.Clear(); |
| 329 | 329 |
| 330 file_manager_ = NULL; | 330 file_manager_ = NULL; |
| 331 if (delegate_) | 331 if (delegate_) |
| 332 delegate_->Shutdown(); | 332 delegate_->Shutdown(); |
| 333 delegate_ = NULL; | 333 delegate_ = NULL; |
| 334 } | 334 } |
| 335 | 335 |
| 336 void DownloadManagerImpl::SearchDownloads(const string16& query, | |
| 337 DownloadVector* result) { | |
| 338 string16 query_lower(base::i18n::ToLower(query)); | |
| 339 | |
| 340 for (DownloadMap::iterator it = downloads_.begin(); | |
| 341 it != downloads_.end(); ++it) { | |
| 342 DownloadItemImpl* download_item = it->second; | |
| 343 // TODO(benjhayden): Don't check IsPersisted(). | |
| 344 if (!download_item->IsTemporary() && | |
| 345 download_item->IsPersisted() && | |
| 346 download_item->MatchesQuery(query_lower)) { | |
| 347 result->push_back(download_item); | |
| 348 } | |
| 349 } | |
| 350 } | |
| 351 | |
| 352 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { | 336 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { |
| 353 DCHECK(browser_context); | 337 DCHECK(browser_context); |
| 354 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; | 338 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; |
| 355 shutdown_needed_ = true; | 339 shutdown_needed_ = true; |
| 356 | 340 |
| 357 browser_context_ = browser_context; | 341 browser_context_ = browser_context; |
| 358 | 342 |
| 359 return true; | 343 return true; |
| 360 } | 344 } |
| 361 | 345 |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1044 void DownloadManagerImpl::DownloadRenamedToFinalName( |
| 1061 DownloadItemImpl* download) { | 1045 DownloadItemImpl* download) { |
| 1062 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1046 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1063 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1047 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
| 1064 // receive the DownloadRenamedToFinalName() call. | 1048 // receive the DownloadRenamedToFinalName() call. |
| 1065 if (delegate_) { | 1049 if (delegate_) { |
| 1066 delegate_->UpdatePathForItemInPersistentStore( | 1050 delegate_->UpdatePathForItemInPersistentStore( |
| 1067 download, download->GetFullPath()); | 1051 download, download->GetFullPath()); |
| 1068 } | 1052 } |
| 1069 } | 1053 } |
| OLD | NEW |