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

Unified Diff: ios/web/web_state/ui/crw_wk_navigation_states.mm

Issue 2950853002: Gracefully handle didCommitNavigation: call after didFinishNavigation: (Closed)
Patch Set: Updated comments Created 3 years, 6 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
Index: ios/web/web_state/ui/crw_wk_navigation_states.mm
diff --git a/ios/web/web_state/ui/crw_wk_navigation_states.mm b/ios/web/web_state/ui/crw_wk_navigation_states.mm
index 235562e4f5ebbeb90f9dc63d04a1d92b996bebd5..24389a86605d0bf4c3d1a9cab0241d80c95ca001 100644
--- a/ios/web/web_state/ui/crw_wk_navigation_states.mm
+++ b/ios/web/web_state/ui/crw_wk_navigation_states.mm
@@ -122,14 +122,24 @@
[[CRWWKNavigationsStateRecord alloc] initWithState:state
index:++_lastStateIndex];
} else {
- DCHECK(
- record.state < state ||
- (record.state == state && state == web::WKNavigationState::REDIRECTED));
+ DCHECK(record.state < state ||
+ // Redirect can be called multiple times.
+ (record.state == state &&
+ state == web::WKNavigationState::REDIRECTED) ||
+ // didFinishNavigation can be called before didCommitNvigation.
+ (record.state == web::WKNavigationState::FINISHED &&
+ state == web::WKNavigationState::COMMITTED));
record.state = state;
}
[_records setObject:record forKey:key];
}
+- (web::WKNavigationState)stateForNavigation:(WKNavigation*)navigation {
+ id key = [self keyForNavigation:navigation];
+ CRWWKNavigationsStateRecord* record = [_records objectForKey:key];
+ return record ? record.state : web::WKNavigationState::NONE;
+}
+
- (void)removeNavigation:(WKNavigation*)navigation {
id key = [self keyForNavigation:navigation];
DCHECK([_records objectForKey:key]);
« no previous file with comments | « ios/web/web_state/ui/crw_wk_navigation_states.h ('k') | ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698