| 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" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // transition on the DownloadItem. | 476 // transition on the DownloadItem. |
| 477 | 477 |
| 478 // Confirm we're in the proper set of states to be here; | 478 // Confirm we're in the proper set of states to be here; |
| 479 // in in_progress_, have all data, have a history handle, (validated or safe). | 479 // in in_progress_, have all data, have a history handle, (validated or safe). |
| 480 DCHECK_NE(DownloadItem::DANGEROUS, download->safety_state()); | 480 DCHECK_NE(DownloadItem::DANGEROUS, download->safety_state()); |
| 481 DCHECK_EQ(1u, in_progress_.count(download->id())); | 481 DCHECK_EQ(1u, in_progress_.count(download->id())); |
| 482 DCHECK(download->all_data_saved()); | 482 DCHECK(download->all_data_saved()); |
| 483 DCHECK(download->db_handle() != DownloadItem::kUninitializedHandle); | 483 DCHECK(download->db_handle() != DownloadItem::kUninitializedHandle); |
| 484 DCHECK_EQ(1u, history_downloads_.count(download->db_handle())); | 484 DCHECK_EQ(1u, history_downloads_.count(download->db_handle())); |
| 485 | 485 |
| 486 // Give the delegate a chance to override. |
| 487 if (!delegate_->ShouldCompleteDownload(download)) |
| 488 return; |
| 489 |
| 486 VLOG(20) << __FUNCTION__ << "()" << " executing: download = " | 490 VLOG(20) << __FUNCTION__ << "()" << " executing: download = " |
| 487 << download->DebugString(false); | 491 << download->DebugString(false); |
| 488 | 492 |
| 489 // Remove the id from in_progress | 493 // Remove the id from in_progress |
| 490 in_progress_.erase(download->id()); | 494 in_progress_.erase(download->id()); |
| 491 UpdateDownloadProgress(); // Reflect removal from in_progress_. | 495 UpdateDownloadProgress(); // Reflect removal from in_progress_. |
| 492 | 496 |
| 493 delegate_->UpdateItemInPersistentStore(download); | 497 delegate_->UpdateItemInPersistentStore(download); |
| 494 | 498 |
| 495 // Finish the download. | 499 // Finish the download. |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { | 1074 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { |
| 1071 delegate_->UpdateItemInPersistentStore(download); | 1075 delegate_->UpdateItemInPersistentStore(download); |
| 1072 int num_unopened = 0; | 1076 int num_unopened = 0; |
| 1073 for (DownloadMap::iterator it = history_downloads_.begin(); | 1077 for (DownloadMap::iterator it = history_downloads_.begin(); |
| 1074 it != history_downloads_.end(); ++it) { | 1078 it != history_downloads_.end(); ++it) { |
| 1075 if (it->second->IsComplete() && !it->second->opened()) | 1079 if (it->second->IsComplete() && !it->second->opened()) |
| 1076 ++num_unopened; | 1080 ++num_unopened; |
| 1077 } | 1081 } |
| 1078 download_stats::RecordOpensOutstanding(num_unopened); | 1082 download_stats::RecordOpensOutstanding(num_unopened); |
| 1079 } | 1083 } |
| OLD | NEW |