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

Unified Diff: ios/chrome/browser/reading_list/reading_list_distiller_page.mm

Issue 2717483003: [Reading List] Check web state after the distillation delay. (Closed)
Patch Set: add task_id Created 3 years, 10 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 | « ios/chrome/browser/reading_list/reading_list_distiller_page.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/reading_list/reading_list_distiller_page.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
index e774a3c2f00b7d443290c235ab4c368fd492dfd5..6ac1c4ad5b4047feaddfec0173351a24c6b493b1 100644
--- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
+++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
@@ -53,6 +53,7 @@ ReadingListDistillerPage::ReadingListDistillerPage(
: dom_distiller::DistillerPageIOS(browser_state),
web_state_dispatcher_(web_state_dispatcher),
delegate_(delegate),
+ delayed_task_id_(0),
weak_ptr_factory_(this) {
DCHECK(delegate);
}
@@ -69,6 +70,7 @@ void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
web_state_dispatcher_->RequestWebState();
AttachWebState(std::move(new_web_state));
original_url_ = url;
+ delayed_task_id_++;
FetchFavicon(url);
DistillerPageIOS::DistillPageImpl(url, script);
@@ -105,6 +107,7 @@ void ReadingListDistillerPage::OnDistillationDone(const GURL& page_url,
[old_web_state->GetView() removeFromSuperview];
web_state_dispatcher_->ReturnWebState(std::move(old_web_state));
}
+ delayed_task_id_++;
DistillerPageIOS::OnDistillationDone(page_url, value);
}
@@ -158,11 +161,17 @@ void ReadingListDistillerPage::OnLoadURLDone(
weak_ptr_factory_.GetWeakPtr();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
- base::Bind(&ReadingListDistillerPage::DelayedOnLoadURLDone, weak_this),
+ base::Bind(&ReadingListDistillerPage::DelayedOnLoadURLDone, weak_this,
+ delayed_task_id_),
base::TimeDelta::FromSeconds(kPageLoadDelayInSeconds));
}
-void ReadingListDistillerPage::DelayedOnLoadURLDone() {
+void ReadingListDistillerPage::DelayedOnLoadURLDone(int delayed_task_id) {
+ if (!CurrentWebState() || delayed_task_id != delayed_task_id_) {
+ // Something interrupted the distillation.
+ // Abort here.
+ return;
+ }
if (IsGoogleCachedAMPPage()) {
// Workaround for Google AMP pages.
HandleGoogleCachedAMPPage();
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_distiller_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698