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

Side by Side Diff: components/sessions/core/tab_restore_service_helper.cc

Issue 2762363002: Do not use GetPendingEntryIndex in TabRestoreServiceHelper::PopulateTab. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #include "components/sessions/core/tab_restore_service_helper.h" 5 #include "components/sessions/core/tab_restore_service_helper.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return ValidateWindow(static_cast<const Window&>(entry)); 403 return ValidateWindow(static_cast<const Window&>(entry));
404 } 404 }
405 NOTREACHED(); 405 NOTREACHED();
406 return false; 406 return false;
407 } 407 }
408 408
409 void TabRestoreServiceHelper::PopulateTab(Tab* tab, 409 void TabRestoreServiceHelper::PopulateTab(Tab* tab,
410 int index, 410 int index,
411 LiveTabContext* context, 411 LiveTabContext* context,
412 LiveTab* live_tab) { 412 LiveTab* live_tab) {
413 const int pending_index = live_tab->GetPendingEntryIndex();
414 int entry_count = 413 int entry_count =
415 live_tab->IsInitialBlankNavigation() ? 0 : live_tab->GetEntryCount(); 414 live_tab->IsInitialBlankNavigation() ? 0 : live_tab->GetEntryCount();
416 if (entry_count == 0 && pending_index == 0)
Eugene But (OOO till 7-30) 2017/03/21 22:31:14 When entry_count is 0, then pending_index is alway
Charlie Reis 2017/03/22 22:49:49 Yes, I can't think of a case that both entry_count
417 entry_count++;
418 tab->navigations.resize(static_cast<int>(entry_count)); 415 tab->navigations.resize(static_cast<int>(entry_count));
419 for (int i = 0; i < entry_count; ++i) { 416 for (int i = 0; i < entry_count; ++i) {
420 SerializedNavigationEntry entry = (i == pending_index) 417 SerializedNavigationEntry entry = live_tab->GetEntryAtIndex(i);
Eugene But (OOO till 7-30) 2017/03/21 22:31:15 Because |entry_count| does not include pending ite
sky 2017/03/22 03:20:16 Are you sure about that? I thought reload and poss
Eugene But (OOO till 7-30) 2017/03/22 14:38:40 It is true that reload and back-forward navigation
Charlie Reis 2017/03/22 22:49:49 Yeah, pointing to an existing one is fine-- your C
421 ? live_tab->GetPendingEntry()
422 : live_tab->GetEntryAtIndex(i);
423 tab->navigations[i] = entry; 418 tab->navigations[i] = entry;
424 } 419 }
425 tab->timestamp = TimeNow(); 420 tab->timestamp = TimeNow();
426 tab->current_navigation_index = live_tab->GetCurrentEntryIndex(); 421 tab->current_navigation_index = live_tab->GetCurrentEntryIndex();
427 tab->tabstrip_index = index; 422 tab->tabstrip_index = index;
428 423
429 tab->extension_app_id = client_->GetExtensionAppIDForTab(live_tab); 424 tab->extension_app_id = client_->GetExtensionAppIDForTab(live_tab);
430 425
431 tab->user_agent_override = live_tab->GetUserAgentOverride(); 426 tab->user_agent_override = live_tab->GetUserAgentOverride();
432 427
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 tab.browser_id = new_id; 549 tab.browser_id = new_id;
555 } 550 }
556 } 551 }
557 } 552 }
558 553
559 base::Time TabRestoreServiceHelper::TimeNow() const { 554 base::Time TabRestoreServiceHelper::TimeNow() const {
560 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); 555 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now();
561 } 556 }
562 557
563 } // namespace sessions 558 } // namespace sessions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698