Commit 42e241ce authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[Background Fetch] Fix download notification bugs.

- Set is_resumable in the OfflineItem to true so that paused downloads
can be resumed.
- Fix deallocated memory access in the Abort workflow which was causing
the browser to crash.

Change-Id: I2369ffe517796c245b6d3351e4d90aa6b4a1510b
Reviewed-on: https://chromium-review.googlesource.com/1253624
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595443}
parent 54eb51e9
...@@ -506,6 +506,7 @@ IN_PROC_BROWSER_TEST_F(BackgroundFetchBrowserTest, ...@@ -506,6 +506,7 @@ IN_PROC_BROWSER_TEST_F(BackgroundFetchBrowserTest,
EXPECT_EQ(offline_item.title, GetExpectedTitle(kSingleFileDownloadTitle)); EXPECT_EQ(offline_item.title, GetExpectedTitle(kSingleFileDownloadTitle));
EXPECT_EQ(offline_item.filter, OfflineItemFilter::FILTER_OTHER); EXPECT_EQ(offline_item.filter, OfflineItemFilter::FILTER_OTHER);
EXPECT_TRUE(offline_item.is_transient); EXPECT_TRUE(offline_item.is_transient);
EXPECT_TRUE(offline_item.is_resumable);
EXPECT_FALSE(offline_item.is_suggested); EXPECT_FALSE(offline_item.is_suggested);
EXPECT_FALSE(offline_item.is_off_the_record); EXPECT_FALSE(offline_item.is_off_the_record);
...@@ -517,7 +518,6 @@ IN_PROC_BROWSER_TEST_F(BackgroundFetchBrowserTest, ...@@ -517,7 +518,6 @@ IN_PROC_BROWSER_TEST_F(BackgroundFetchBrowserTest,
// Change-detector tests for values we might want to provide or change. // Change-detector tests for values we might want to provide or change.
EXPECT_TRUE(offline_item.description.empty()); EXPECT_TRUE(offline_item.description.empty());
EXPECT_TRUE(offline_item.page_url.is_empty()); EXPECT_TRUE(offline_item.page_url.is_empty());
EXPECT_FALSE(offline_item.is_resumable);
EXPECT_FALSE(offline_item.is_off_the_record); EXPECT_FALSE(offline_item.is_off_the_record);
} }
......
...@@ -112,8 +112,9 @@ void BackgroundFetchDelegateImpl::JobDetails::UpdateOfflineItem() { ...@@ -112,8 +112,9 @@ void BackgroundFetchDelegateImpl::JobDetails::UpdateOfflineItem() {
base::StringPrintf("%s (%s)", fetch_description->title.c_str(), base::StringPrintf("%s (%s)", fetch_description->title.c_str(),
fetch_description->origin.Serialize().c_str()); fetch_description->origin.Serialize().c_str());
} }
// TODO(delphick): Figure out what to put in offline_item.description.
offline_item.is_transient = true; offline_item.is_transient = true;
offline_item.is_resumable = true;
using OfflineItemState = offline_items_collection::OfflineItemState; using OfflineItemState = offline_items_collection::OfflineItemState;
if (cancelled) { if (cancelled) {
...@@ -519,11 +520,14 @@ void BackgroundFetchDelegateImpl::FailFetch(const std::string& job_unique_id) { ...@@ -519,11 +520,14 @@ void BackgroundFetchDelegateImpl::FailFetch(const std::string& job_unique_id) {
void BackgroundFetchDelegateImpl::CancelDownload( void BackgroundFetchDelegateImpl::CancelDownload(
const offline_items_collection::ContentId& id) { const offline_items_collection::ContentId& id) {
Abort(id.id); // Save a copy before Abort() deletes the reference.
const std::string unique_id = id.id;
Abort(unique_id);
if (client()) { if (client()) {
client()->OnJobCancelled( client()->OnJobCancelled(
id.id, blink::mojom::BackgroundFetchFailureReason::CANCELLED_FROM_UI); unique_id,
blink::mojom::BackgroundFetchFailureReason::CANCELLED_FROM_UI);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment