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" |
11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop.h" |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
18 #include "base/sys_string_conversions.h" | 19 #include "base/sys_string_conversions.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "content/browser/download/byte_stream.h" | 21 #include "content/browser/download/byte_stream.h" |
21 #include "content/browser/download/download_create_info.h" | 22 #include "content/browser/download/download_create_info.h" |
22 #include "content/browser/download/download_file_manager.h" | 23 #include "content/browser/download/download_file_manager.h" |
23 #include "content/browser/download/download_item_impl.h" | 24 #include "content/browser/download/download_item_impl.h" |
24 #include "content/browser/download/download_stats.h" | 25 #include "content/browser/download/download_stats.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 DownloadItem* download_item = it->second; | 354 DownloadItem* download_item = it->second; |
354 // Display Incognito downloads only in Incognito window, and vice versa. | 355 // Display Incognito downloads only in Incognito window, and vice versa. |
355 // The Incognito Downloads page will get the list of non-Incognito downloads | 356 // The Incognito Downloads page will get the list of non-Incognito downloads |
356 // from its parent profile. | 357 // from its parent profile. |
357 // TODO(benjhayden): Don't check IsPersisted(). | 358 // TODO(benjhayden): Don't check IsPersisted(). |
358 if (!download_item->IsTemporary() && | 359 if (!download_item->IsTemporary() && |
359 download_item->IsPersisted() && | 360 download_item->IsPersisted() && |
360 (browser_context_->IsOffTheRecord() == download_item->IsOtr()) && | 361 (browser_context_->IsOffTheRecord() == download_item->IsOtr()) && |
361 download_item->MatchesQuery(query_lower)) { | 362 download_item->MatchesQuery(query_lower)) { |
362 result->push_back(download_item); | 363 result->push_back(download_item); |
363 } | |
364 } | 364 } |
365 } | 365 } |
| 366 } |
366 | 367 |
367 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { | 368 bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) { |
368 DCHECK(browser_context); | 369 DCHECK(browser_context); |
369 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; | 370 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; |
370 shutdown_needed_ = true; | 371 shutdown_needed_ = true; |
371 | 372 |
372 browser_context_ = browser_context; | 373 browser_context_ = browser_context; |
373 | 374 |
374 return true; | 375 return true; |
375 } | 376 } |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1185 void DownloadManagerImpl::DownloadRenamedToFinalName( |
1185 DownloadItem* download) { | 1186 DownloadItem* download) { |
1186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1187 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1188 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
1188 // receive the DownloadRenamedToFinalName() call. | 1189 // receive the DownloadRenamedToFinalName() call. |
1189 if (delegate_) { | 1190 if (delegate_) { |
1190 delegate_->UpdatePathForItemInPersistentStore( | 1191 delegate_->UpdatePathForItemInPersistentStore( |
1191 download, download->GetFullPath()); | 1192 download, download->GetFullPath()); |
1192 } | 1193 } |
1193 } | 1194 } |
OLD | NEW |