Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/web_state/ui/crw_wk_navigation_states.h" | 5 #import "ios/web/web_state/ui/crw_wk_navigation_states.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "ios/web/web_state/navigation_context_impl.h" | 8 #import "ios/web/web_state/navigation_context_impl.h" |
| 9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 id key = [self keyForNavigation:navigation]; | 115 id key = [self keyForNavigation:navigation]; |
| 116 CRWWKNavigationsStateRecord* record = [_records objectForKey:key]; | 116 CRWWKNavigationsStateRecord* record = [_records objectForKey:key]; |
| 117 if (!record) { | 117 if (!record) { |
| 118 DCHECK(state == web::WKNavigationState::REQUESTED || | 118 DCHECK(state == web::WKNavigationState::REQUESTED || |
| 119 state == web::WKNavigationState::STARTED || | 119 state == web::WKNavigationState::STARTED || |
| 120 state == web::WKNavigationState::COMMITTED); | 120 state == web::WKNavigationState::COMMITTED); |
| 121 record = | 121 record = |
| 122 [[CRWWKNavigationsStateRecord alloc] initWithState:state | 122 [[CRWWKNavigationsStateRecord alloc] initWithState:state |
| 123 index:++_lastStateIndex]; | 123 index:++_lastStateIndex]; |
| 124 } else { | 124 } else { |
| 125 DCHECK( | 125 DCHECK(record.state < state || |
| 126 record.state < state || | 126 (record.state == state && |
| 127 (record.state == state && state == web::WKNavigationState::REDIRECTED)); | 127 state == web::WKNavigationState::REDIRECTED) || |
| 128 (record.state == web::WKNavigationState::FINISHED && | |
| 129 state == web::WKNavigationState::COMMITTED)); | |
|
kkhorimoto
2017/06/22 00:49:02
Can you add some comments for this DCHECK explaini
Eugene But (OOO till 7-30)
2017/06/22 01:58:06
Done.
| |
| 128 record.state = state; | 130 record.state = state; |
| 129 } | 131 } |
| 130 [_records setObject:record forKey:key]; | 132 [_records setObject:record forKey:key]; |
| 131 } | 133 } |
| 132 | 134 |
| 135 - (web::WKNavigationState)stateForNavigation:(WKNavigation*)navigation { | |
| 136 id key = [self keyForNavigation:navigation]; | |
| 137 CRWWKNavigationsStateRecord* record = [_records objectForKey:key]; | |
| 138 return record ? record.state : web::WKNavigationState::NONE; | |
| 139 } | |
| 140 | |
| 133 - (void)removeNavigation:(WKNavigation*)navigation { | 141 - (void)removeNavigation:(WKNavigation*)navigation { |
| 134 id key = [self keyForNavigation:navigation]; | 142 id key = [self keyForNavigation:navigation]; |
| 135 DCHECK([_records objectForKey:key]); | 143 DCHECK([_records objectForKey:key]); |
| 136 [_records removeObjectForKey:key]; | 144 [_records removeObjectForKey:key]; |
| 137 } | 145 } |
| 138 | 146 |
| 139 - (void)setContext:(std::unique_ptr<web::NavigationContextImpl>)context | 147 - (void)setContext:(std::unique_ptr<web::NavigationContextImpl>)context |
| 140 forNavigation:(WKNavigation*)navigation { | 148 forNavigation:(WKNavigation*)navigation { |
| 141 id key = [self keyForNavigation:navigation]; | 149 id key = [self keyForNavigation:navigation]; |
| 142 CRWWKNavigationsStateRecord* record = [_records objectForKey:key]; | 150 CRWWKNavigationsStateRecord* record = [_records objectForKey:key]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 } | 207 } |
| 200 } | 208 } |
| 201 | 209 |
| 202 if (*outNavigation == _nullNavigation) { | 210 if (*outNavigation == _nullNavigation) { |
| 203 // |_nullNavigation| is a key for storing null navigations. | 211 // |_nullNavigation| is a key for storing null navigations. |
| 204 *outNavigation = nil; | 212 *outNavigation = nil; |
| 205 } | 213 } |
| 206 } | 214 } |
| 207 | 215 |
| 208 @end | 216 @end |
| OLD | NEW |