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

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

Issue 2724583002: [Reading List] Check web state after the distillation delay. (Closed)
Patch Set: 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 baa4012447112b0d6efcc6b5ee36ba5f654625be..d1dc2a827f4b07e5ae6c0e0cb7b2125ff6b0242f 100644
--- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
+++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
@@ -40,6 +40,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);
}
@@ -61,6 +62,7 @@ void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
}
AttachWebState(std::move(new_web_state));
original_url_ = url;
+ delayed_task_id_++;
DistillerPageIOS::DistillPageImpl(url, script);
}
@@ -71,6 +73,7 @@ void ReadingListDistillerPage::OnDistillationDone(const GURL& page_url,
if (old_web_state) {
web_state_dispatcher_->ReturnWebState(std::move(old_web_state));
}
+ delayed_task_id_++;
DistillerPageIOS::OnDistillationDone(page_url, value);
}
@@ -122,11 +125,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