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

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

Issue 1484093002: Allowing multiple SaveItems to have same URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nested-frames-more-involved-fix
Patch Set: Rebasing... Created 5 years, 1 month 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
Index: content/browser/download/save_item.cc
diff --git a/content/browser/download/save_item.cc b/content/browser/download/save_item.cc
index 9e516204202074978e14e03f609ce24bc83f0b50..84cd279fe0b49752bcbf03446a8a35293d0f66d8 100644
--- a/content/browser/download/save_item.cc
+++ b/content/browser/download/save_item.cc
@@ -9,24 +9,35 @@
#include "content/browser/download/save_file.h"
#include "content/browser/download/save_file_manager.h"
#include "content/browser/download/save_package.h"
+#include "content/public/browser/browser_thread.h"
namespace content {
+namespace {
+
+int GetNextSaveItemId() {
+ static int g_next_save_item_id = 0;
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ return g_next_save_item_id++;
+}
+
+} // namespace
+
// Constructor for SaveItem when creating each saving job.
SaveItem::SaveItem(const GURL& url,
const Referrer& referrer,
SavePackage* package,
SaveFileCreateInfo::SaveFileSource save_source)
- : save_id_(-1),
- url_(url),
- referrer_(referrer),
- total_bytes_(0),
- received_bytes_(0),
- state_(WAIT_START),
- has_final_name_(false),
- is_success_(false),
- save_source_(save_source),
- package_(package) {
+ : save_item_id_(GetNextSaveItemId()),
+ url_(url),
+ referrer_(referrer),
+ total_bytes_(0),
+ received_bytes_(0),
+ state_(WAIT_START),
+ has_final_name_(false),
+ is_success_(false),
+ save_source_(save_source),
+ package_(package) {
DCHECK(package);
}
@@ -80,12 +91,9 @@ void SaveItem::Finish(int64 size, bool is_success) {
// three situations.
// a) The data of this SaveItem is finished saving. So it should have
// generated final name.
- // b) Error happened before the start of saving process. So no |save_id_| is
- // generated for this SaveItem and the |is_success_| should be false.
- // c) Error happened in the start of saving process, the SaveItem has a save
- // id, |is_success_| should be false, and the |size| should be 0.
- DCHECK(has_final_name() || (save_id_ == -1 && !is_success_) ||
- (save_id_ != -1 && !is_success_ && !size));
+ // b) Error happened before the start of saving process.
+ // c) Error happened in the start of saving process.
Randy Smith (Not in Mondays) 2015/12/03 20:58:28 nit: I think this comment was originally intended
Łukasz Anforowicz 2015/12/04 21:16:45 Done (I've removed the comment altogether - I agre
+ DCHECK(has_final_name() || !is_success_);
state_ = COMPLETE;
is_success_ = is_success;
UpdateSize(size);
@@ -120,11 +128,6 @@ void SaveItem::Rename(const base::FilePath& full_path) {
has_final_name_ = true;
}
-void SaveItem::SetSaveId(int32 save_id) {
- DCHECK_EQ(-1, save_id_);
- save_id_ = save_id;
-}
-
void SaveItem::SetTotalBytes(int64 total_bytes) {
DCHECK_EQ(0, total_bytes_);
total_bytes_ = total_bytes;

Powered by Google App Engine
This is Rietveld 408576698