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

Unified Diff: content/browser/download/download_item_impl.cc

Issue 1781983002: [Downloads] Introduce GUIDs for downloads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 9 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 | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 6a6dc7d74112e7334413b6be0d36d97355ba44f3..19e4675a60b915a34a8f46827aadea2c3d3fa1f8 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -29,9 +29,11 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
+#include "base/guid.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
+#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/download/download_create_info.h"
@@ -105,6 +107,7 @@ const int DownloadItemImpl::kMaxAutoResumeAttempts = 5;
// Constructor for reading from the history service.
DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
+ const std::string& guid,
uint32_t download_id,
const base::FilePath& current_path,
const base::FilePath& target_path,
@@ -123,7 +126,8 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
DownloadInterruptReason interrupt_reason,
bool opened,
const net::BoundNetLog& bound_net_log)
- : download_id_(download_id),
+ : guid_(base::ToUpperASCII(guid)),
+ download_id_(download_id),
current_path_(current_path),
target_path_(target_path),
url_chain_(url_chain),
@@ -148,6 +152,7 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
delegate_->Attach();
DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL ||
state_ == CANCELLED_INTERNAL);
+ DCHECK(base::IsValidGUID(guid_));
Init(false /* not actively downloading */, SRC_HISTORY_IMPORT);
}
@@ -156,7 +161,8 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
uint32_t download_id,
const DownloadCreateInfo& info,
const net::BoundNetLog& bound_net_log)
- : download_id_(download_id),
+ : guid_(base::ToUpperASCII(base::GenerateGUID())),
+ download_id_(download_id),
target_disposition_((info.save_info->prompt_for_save_location)
? TARGET_DISPOSITION_PROMPT
: TARGET_DISPOSITION_OVERWRITE),
@@ -207,6 +213,7 @@ DownloadItemImpl::DownloadItemImpl(
const net::BoundNetLog& bound_net_log)
: is_save_package_download_(true),
request_handle_(std::move(request_handle)),
+ guid_(base::ToUpperASCII(base::GenerateGUID())),
download_id_(download_id),
current_path_(path),
target_path_(path),
@@ -425,6 +432,10 @@ uint32_t DownloadItemImpl::GetId() const {
return download_id_;
}
+const std::string& DownloadItemImpl::GetGuid() const {
+ return guid_;
+}
+
DownloadItem::DownloadState DownloadItemImpl::GetState() const {
return InternalToExternalState(state_);
}
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698