Chromium Code Reviews| Index: chrome/browser/android/tab_state.cc |
| diff --git a/chrome/browser/android/tab_state.cc b/chrome/browser/android/tab_state.cc |
| index b3547a251ce1c89d51214178aaf7b8daa892885e..d79661332806b67620c7efd97c7c7f718a090d50 100644 |
| --- a/chrome/browser/android/tab_state.cc |
| +++ b/chrome/browser/android/tab_state.cc |
| @@ -286,37 +286,31 @@ bool ExtractNavigationEntries( |
| }; // anonymous namespace |
| ScopedJavaLocalRef<jobject> WebContentsState::GetContentsStateAsByteBuffer( |
| - JNIEnv* env, TabAndroid* tab) { |
| + JNIEnv* env, |
| + TabAndroid* tab) { |
| Profile* profile = tab->GetProfile(); |
| if (!profile) |
| return ScopedJavaLocalRef<jobject>(); |
| content::NavigationController& controller = |
| tab->web_contents()->GetController(); |
| + const int entry_count = controller.GetEntryCount(); |
| + const int current_index = controller.GetLastCommittedEntryIndex(); |
| const int pending_index = controller.GetPendingEntryIndex(); |
| - int entry_count = controller.GetEntryCount(); |
| - if (entry_count == 0 && pending_index == 0) |
| - entry_count++; |
| + DCHECK(current_index < entry_count); |
| + DCHECK(pending_index < entry_count); |
| if (entry_count == 0) |
| return ScopedJavaLocalRef<jobject>(); |
| - int current_entry = controller.GetLastCommittedEntryIndex(); |
| - if (current_entry == -1 && entry_count > 0) |
| - current_entry = 0; |
| - |
| std::vector<content::NavigationEntry*> navigations(entry_count); |
| for (int i = 0; i < entry_count; ++i) { |
| - content::NavigationEntry* entry = (i == pending_index) ? |
| - controller.GetPendingEntry() : controller.GetEntryAtIndex(i); |
| - navigations[i] = entry; |
| + navigations[i] = (i == pending_index) ? controller.GetPendingEntry() |
|
Eugene But (OOO till 7-30)
2017/04/07 15:21:07
I was under impression that if |i == pending_index
arthursonzogni
2017/04/10 08:16:35
It would have been nice if the code could be simpl
|
| + : controller.GetEntryAtIndex(i); |
| } |
| return WebContentsState::WriteNavigationsAsByteBuffer( |
| - env, |
| - profile->IsOffTheRecord(), |
| - navigations, |
| - current_entry); |
| + env, profile->IsOffTheRecord(), navigations, current_index); |
| } |
| // Common implementation for GetContentsStateAsByteBuffer() and |