| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 content::Details<content::PrunedDetails> pruned_details(details); | 582 content::Details<content::PrunedDetails> pruned_details(details); |
| 583 if (pruned_details->from_front) { | 583 if (pruned_details->from_front) { |
| 584 TabNavigationPathPrunedFromFront( | 584 TabNavigationPathPrunedFromFront( |
| 585 tab->restore_tab_helper()->window_id(), | 585 tab->restore_tab_helper()->window_id(), |
| 586 tab->restore_tab_helper()->session_id(), | 586 tab->restore_tab_helper()->session_id(), |
| 587 pruned_details->count); | 587 pruned_details->count); |
| 588 } else { | 588 } else { |
| 589 TabNavigationPathPrunedFromBack( | 589 TabNavigationPathPrunedFromBack( |
| 590 tab->restore_tab_helper()->window_id(), | 590 tab->restore_tab_helper()->window_id(), |
| 591 tab->restore_tab_helper()->session_id(), | 591 tab->restore_tab_helper()->session_id(), |
| 592 tab->controller().entry_count()); | 592 tab->tab_contents()->controller().entry_count()); |
| 593 } | 593 } |
| 594 RecordSessionUpdateHistogramData(content::NOTIFICATION_NAV_LIST_PRUNED, | 594 RecordSessionUpdateHistogramData(content::NOTIFICATION_NAV_LIST_PRUNED, |
| 595 &last_updated_nav_list_pruned_time_); | 595 &last_updated_nav_list_pruned_time_); |
| 596 break; | 596 break; |
| 597 } | 597 } |
| 598 | 598 |
| 599 case content::NOTIFICATION_NAV_ENTRY_CHANGED: { | 599 case content::NOTIFICATION_NAV_ENTRY_CHANGED: { |
| 600 TabContentsWrapper* tab = | 600 TabContentsWrapper* tab = |
| 601 TabContentsWrapper::GetCurrentWrapperForContents( | 601 TabContentsWrapper::GetCurrentWrapperForContents( |
| 602 content::Source<NavigationController>( | 602 content::Source<NavigationController>( |
| 603 source).ptr()->tab_contents()); | 603 source).ptr()->tab_contents()); |
| 604 if (!tab || tab->profile() != profile()) | 604 if (!tab || tab->profile() != profile()) |
| 605 return; | 605 return; |
| 606 content::Details<content::EntryChangedDetails> changed(details); | 606 content::Details<content::EntryChangedDetails> changed(details); |
| 607 UpdateTabNavigation( | 607 UpdateTabNavigation( |
| 608 tab->restore_tab_helper()->window_id(), | 608 tab->restore_tab_helper()->window_id(), |
| 609 tab->restore_tab_helper()->session_id(), | 609 tab->restore_tab_helper()->session_id(), |
| 610 changed->index, *changed->changed_entry); | 610 changed->index, *changed->changed_entry); |
| 611 break; | 611 break; |
| 612 } | 612 } |
| 613 | 613 |
| 614 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { | 614 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { |
| 615 TabContentsWrapper* tab = | 615 TabContentsWrapper* tab = |
| 616 TabContentsWrapper::GetCurrentWrapperForContents( | 616 TabContentsWrapper::GetCurrentWrapperForContents( |
| 617 content::Source<NavigationController>( | 617 content::Source<NavigationController>( |
| 618 source).ptr()->tab_contents()); | 618 source).ptr()->tab_contents()); |
| 619 if (!tab || tab->profile() != profile()) | 619 if (!tab || tab->profile() != profile()) |
| 620 return; | 620 return; |
| 621 int current_entry_index = tab->controller().GetCurrentEntryIndex(); | 621 int current_entry_index = |
| 622 tab->tab_contents()->controller().GetCurrentEntryIndex(); |
| 622 SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(), | 623 SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(), |
| 623 tab->restore_tab_helper()->session_id(), | 624 tab->restore_tab_helper()->session_id(), |
| 624 current_entry_index); | 625 current_entry_index); |
| 625 UpdateTabNavigation( | 626 UpdateTabNavigation( |
| 626 tab->restore_tab_helper()->window_id(), | 627 tab->restore_tab_helper()->window_id(), |
| 627 tab->restore_tab_helper()->session_id(), | 628 tab->restore_tab_helper()->session_id(), |
| 628 current_entry_index, | 629 current_entry_index, |
| 629 *tab->controller().GetEntryAtIndex(current_entry_index)); | 630 *tab->tab_contents()->controller().GetEntryAtIndex( |
| 631 current_entry_index)); |
| 630 content::Details<content::LoadCommittedDetails> changed(details); | 632 content::Details<content::LoadCommittedDetails> changed(details); |
| 631 if (changed->type == content::NAVIGATION_TYPE_NEW_PAGE || | 633 if (changed->type == content::NAVIGATION_TYPE_NEW_PAGE || |
| 632 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) { | 634 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) { |
| 633 RecordSessionUpdateHistogramData( | 635 RecordSessionUpdateHistogramData( |
| 634 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 636 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 635 &last_updated_nav_entry_commit_time_); | 637 &last_updated_nav_entry_commit_time_); |
| 636 } | 638 } |
| 637 break; | 639 break; |
| 638 } | 640 } |
| 639 | 641 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 void SessionService::BuildCommandsForTab( | 1135 void SessionService::BuildCommandsForTab( |
| 1134 const SessionID& window_id, | 1136 const SessionID& window_id, |
| 1135 TabContentsWrapper* tab, | 1137 TabContentsWrapper* tab, |
| 1136 int index_in_window, | 1138 int index_in_window, |
| 1137 bool is_pinned, | 1139 bool is_pinned, |
| 1138 std::vector<SessionCommand*>* commands, | 1140 std::vector<SessionCommand*>* commands, |
| 1139 IdToRange* tab_to_available_range) { | 1141 IdToRange* tab_to_available_range) { |
| 1140 DCHECK(tab && commands && window_id.id()); | 1142 DCHECK(tab && commands && window_id.id()); |
| 1141 const SessionID& session_id(tab->restore_tab_helper()->session_id()); | 1143 const SessionID& session_id(tab->restore_tab_helper()->session_id()); |
| 1142 commands->push_back(CreateSetTabWindowCommand(window_id, session_id)); | 1144 commands->push_back(CreateSetTabWindowCommand(window_id, session_id)); |
| 1143 const int current_index = tab->controller().GetCurrentEntryIndex(); | 1145 const int current_index = |
| 1146 tab->tab_contents()->controller().GetCurrentEntryIndex(); |
| 1144 const int min_index = std::max(0, | 1147 const int min_index = std::max(0, |
| 1145 current_index - max_persist_navigation_count); | 1148 current_index - max_persist_navigation_count); |
| 1146 const int max_index = std::min(current_index + max_persist_navigation_count, | 1149 const int max_index = |
| 1147 tab->controller().entry_count()); | 1150 std::min(current_index + max_persist_navigation_count, |
| 1148 const int pending_index = tab->controller().pending_entry_index(); | 1151 tab->tab_contents()->controller().entry_count()); |
| 1152 const int pending_index = |
| 1153 tab->tab_contents()->controller().pending_entry_index(); |
| 1149 if (tab_to_available_range) { | 1154 if (tab_to_available_range) { |
| 1150 (*tab_to_available_range)[session_id.id()] = | 1155 (*tab_to_available_range)[session_id.id()] = |
| 1151 std::pair<int, int>(min_index, max_index); | 1156 std::pair<int, int>(min_index, max_index); |
| 1152 } | 1157 } |
| 1153 if (is_pinned) { | 1158 if (is_pinned) { |
| 1154 commands->push_back(CreatePinnedStateCommand(session_id, true)); | 1159 commands->push_back(CreatePinnedStateCommand(session_id, true)); |
| 1155 } | 1160 } |
| 1156 TabContentsWrapper* wrapper = | 1161 TabContentsWrapper* wrapper = |
| 1157 TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents()); | 1162 TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents()); |
| 1158 if (wrapper->extension_tab_helper()->extension_app()) { | 1163 if (wrapper->extension_tab_helper()->extension_app()) { |
| 1159 commands->push_back( | 1164 commands->push_back( |
| 1160 CreateSetTabExtensionAppIDCommand( | 1165 CreateSetTabExtensionAppIDCommand( |
| 1161 kCommandSetExtensionAppID, session_id.id(), | 1166 kCommandSetExtensionAppID, session_id.id(), |
| 1162 wrapper->extension_tab_helper()->extension_app()->id())); | 1167 wrapper->extension_tab_helper()->extension_app()->id())); |
| 1163 } | 1168 } |
| 1164 for (int i = min_index; i < max_index; ++i) { | 1169 for (int i = min_index; i < max_index; ++i) { |
| 1165 const NavigationEntry* entry = (i == pending_index) ? | 1170 const NavigationEntry* entry = (i == pending_index) ? |
| 1166 tab->controller().pending_entry() : | 1171 tab->tab_contents()->controller().pending_entry() : |
| 1167 tab->controller().GetEntryAtIndex(i); | 1172 tab->tab_contents()->controller().GetEntryAtIndex(i); |
| 1168 DCHECK(entry); | 1173 DCHECK(entry); |
| 1169 if (ShouldTrackEntry(entry->virtual_url())) { | 1174 if (ShouldTrackEntry(entry->virtual_url())) { |
| 1170 commands->push_back( | 1175 commands->push_back( |
| 1171 CreateUpdateTabNavigationCommand( | 1176 CreateUpdateTabNavigationCommand( |
| 1172 kCommandUpdateTabNavigation, session_id.id(), i, *entry)); | 1177 kCommandUpdateTabNavigation, session_id.id(), i, *entry)); |
| 1173 } | 1178 } |
| 1174 } | 1179 } |
| 1175 commands->push_back( | 1180 commands->push_back( |
| 1176 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); | 1181 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); |
| 1177 | 1182 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 50); | 1539 50); |
| 1535 if (use_long_period) { | 1540 if (use_long_period) { |
| 1536 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1541 std::string long_name_("SessionRestore.SaveLongPeriod"); |
| 1537 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1542 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
| 1538 delta, | 1543 delta, |
| 1539 save_delay_in_mins_, | 1544 save_delay_in_mins_, |
| 1540 save_delay_in_hrs_, | 1545 save_delay_in_hrs_, |
| 1541 50); | 1546 50); |
| 1542 } | 1547 } |
| 1543 } | 1548 } |
| OLD | NEW |