| 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..a8aeefdcaefd7a41848040821e8f79c892680def 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);
|
| }
|
|
|
| @@ -76,16 +87,7 @@ void SaveItem::Cancel() {
|
|
|
| // Set finish state for a save item
|
| void SaveItem::Finish(int64 size, bool is_success) {
|
| - // When this function is called, the SaveItem should be one of following
|
| - // 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));
|
| + DCHECK(has_final_name() || !is_success_);
|
| state_ = COMPLETE;
|
| is_success_ = is_success;
|
| UpdateSize(size);
|
| @@ -120,11 +122,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;
|
|
|