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

Unified Diff: chrome/browser/download/download_item.cc

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_item.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_item.cc
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index 0c3dca16675ab9f03bee8be3beb5e699cb078464..b04b6ebd84e579362addeffc6aa2c08efedb049b 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -121,7 +121,8 @@ DownloadItem::DangerType GetDangerType(bool dangerous_file,
// Constructor for reading from the history service.
DownloadItem::DownloadItem(DownloadManager* download_manager,
const DownloadHistoryInfo& info)
- : download_id_(-1),
+ : download_id_(info.id),
+ is_in_history_(true),
full_path_(info.path),
url_chain_(1, info.url),
referrer_url_(info.referrer_url),
@@ -130,7 +131,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
start_tick_(base::TimeTicks()),
state_(static_cast<DownloadState>(info.state)),
start_time_(info.start_time),
- db_handle_(info.db_handle),
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
@@ -159,6 +159,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
info.is_extension_install),
request_handle_(info.request_handle),
download_id_(info.download_id),
+ is_in_history_(false),
full_path_(info.path),
url_chain_(info.url_chain),
referrer_url_(info.referrer_url),
@@ -172,7 +173,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
start_tick_(base::TimeTicks::Now()),
state_(IN_PROGRESS),
start_time_(info.start_time),
- db_handle_(DownloadHistory::kUninitializedHandle),
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
@@ -192,7 +192,8 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
const FilePath& path,
const GURL& url,
bool is_otr)
- : download_id_(1),
+ : download_id_(-1/*TODO(benjhayden) XXX*/),
+ is_in_history_(false),
full_path_(path),
url_chain_(1, url),
referrer_url_(GURL()),
@@ -202,7 +203,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
start_tick_(base::TimeTicks::Now()),
state_(IN_PROGRESS),
start_time_(base::Time::Now()),
- db_handle_(DownloadHistory::kUninitializedHandle),
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
@@ -540,7 +540,7 @@ void DownloadItem::Remove() {
download_manager_->AssertQueueStateConsistent(this);
state_ = REMOVING;
- download_manager_->RemoveDownload(db_handle_);
+ download_manager_->RemoveDownload(id());
// We have now been deleted.
}
@@ -603,8 +603,7 @@ void DownloadItem::TogglePause() {
void DownloadItem::OnDownloadCompleting(DownloadFileManager* file_manager) {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- VLOG(20) << __FUNCTION__ << "()"
+ DVLOG(1) << __FUNCTION__ << "()"
<< " needs rename = " << NeedsRename()
<< " " << DebugString(true);
DCHECK_NE(DANGEROUS, safety_state());
@@ -630,7 +629,7 @@ void DownloadItem::OnDownloadRenamedToFinalName(const FilePath& full_path) {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- VLOG(20) << __FUNCTION__ << "()"
+ DVLOG(1) << __FUNCTION__ << "()"
<< " full_path = \"" << full_path.value() << "\""
<< " needed rename = " << NeedsRename()
<< " " << DebugString(false);
@@ -645,6 +644,7 @@ void DownloadItem::OnDownloadRenamedToFinalName(const FilePath& full_path) {
}
Completed();
+ DVLOG(1) << DebugString(true);
}
bool DownloadItem::MatchesQuery(const string16& query) const {
@@ -732,7 +732,7 @@ DownloadHistoryInfo DownloadItem::GetHistoryInfo() const {
received_bytes(),
total_bytes(),
state(),
- db_handle());
+ id());
}
FilePath DownloadItem::GetTargetFilePath() const {
@@ -788,6 +788,10 @@ bool DownloadItem::IsComplete() const {
return (state_ == COMPLETE);
}
+bool DownloadItem::IsInHistory() const {
+ return is_in_history_;
+}
+
const GURL& DownloadItem::GetURL() const {
return url_chain_.empty() ?
GURL::EmptyGURL() : url_chain_.back();
@@ -797,7 +801,7 @@ std::string DownloadItem::DebugString(bool verbose) const {
std::string description =
base::StringPrintf("{ id = %d"
" state = %s",
- download_id_,
+ id(),
DebugDownloadStateString(state()));
// Construct a string of the URL chain.
@@ -816,7 +820,6 @@ std::string DownloadItem::DebugString(bool verbose) const {
if (verbose) {
description += base::StringPrintf(
- " db_handle = %" PRId64
" total_bytes = %" PRId64
" received_bytes = %" PRId64
" is_paused = %c"
@@ -826,7 +829,6 @@ std::string DownloadItem::DebugString(bool verbose) const {
" url_chain = \n\t\"%s\"\n\t"
" target_name = \"%" PRFilePath "\""
" full_path = \"%" PRFilePath "\"",
- db_handle(),
total_bytes(),
received_bytes(),
is_paused() ? 'T' : 'F',
« no previous file with comments | « chrome/browser/download/download_item.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698