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

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

Issue 1373573002: ABANDONED: OOPIFs: Moving stitching of local paths from renderer to browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-serialization-recursive-begone
Patch Set: Rebasing... Created 5 years, 2 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/save_item.h ('k') | content/browser/download/save_package.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b3dbd493d77f514caa32787e3941bba27fba840f 100644
--- a/content/browser/download/save_item.cc
+++ b/content/browser/download/save_item.cc
@@ -9,24 +9,24 @@
#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 {
// 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_id_(-1),
+ url_(url),
+ 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);
}
@@ -35,6 +35,7 @@ SaveItem::~SaveItem() {
// Set start state for save item.
void SaveItem::Start() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(state_ == WAIT_START);
state_ = IN_PROGRESS;
}
@@ -51,7 +52,8 @@ void SaveItem::UpdateSize(int64 bytes_so_far) {
// was being canceled in the UI thread, so we'll accept them unless we're
// complete.
void SaveItem::Update(int64 bytes_so_far) {
- if (state_ != IN_PROGRESS) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (state_ != IN_PROGRESS && state_ != COMPLETING) {
NOTREACHED();
return;
}
@@ -62,6 +64,8 @@ void SaveItem::Update(int64 bytes_so_far) {
// this command. The SavePackage will each in-progress SaveItem's cancel
// when canceling whole saving page job.
void SaveItem::Cancel() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
// If item is in WAIT_START mode, which means no request has been sent.
// So we need not to cancel it.
if (state_ != IN_PROGRESS) {
@@ -76,6 +80,8 @@ void SaveItem::Cancel() {
// Set finish state for a save item
void SaveItem::Finish(int64 size, bool is_success) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
// 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
@@ -93,8 +99,11 @@ void SaveItem::Finish(int64 size, bool is_success) {
// Calculate the percentage of the save item
int SaveItem::PercentComplete() const {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
switch (state_) {
case COMPLETE:
+ case COMPLETING:
case CANCELED:
return 100;
case WAIT_START:
@@ -114,6 +123,7 @@ int SaveItem::PercentComplete() const {
// Rename the save item with new path.
void SaveItem::Rename(const base::FilePath& full_path) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!full_path.empty() && !has_final_name());
full_path_ = full_path;
file_name_ = full_path_.BaseName();
@@ -121,13 +131,21 @@ void SaveItem::Rename(const base::FilePath& full_path) {
}
void SaveItem::SetSaveId(int32 save_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(-1, save_id_);
save_id_ = save_id;
}
void SaveItem::SetTotalBytes(int64 total_bytes) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(0, total_bytes_);
total_bytes_ = total_bytes;
}
+void SaveItem::MarkAsCompleting() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(state_ == IN_PROGRESS);
+ state_ = COMPLETING;
+}
+
} // namespace content
« no previous file with comments | « content/browser/download/save_item.h ('k') | content/browser/download/save_package.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698