OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 if (tab->extension_tab_helper()->extension_app()) { | 599 if (tab->extension_tab_helper()->extension_app()) { |
600 SetTabExtensionAppID( | 600 SetTabExtensionAppID( |
601 tab->restore_tab_helper()->window_id(), | 601 tab->restore_tab_helper()->window_id(), |
602 tab->restore_tab_helper()->session_id(), | 602 tab->restore_tab_helper()->session_id(), |
603 tab->extension_tab_helper()->extension_app()->id()); | 603 tab->extension_tab_helper()->extension_app()->id()); |
604 } | 604 } |
605 | 605 |
606 // Record the association between the SessionStorageNamespace and the | 606 // Record the association between the SessionStorageNamespace and the |
607 // tab. | 607 // tab. |
608 content::SessionStorageNamespace* session_storage_namespace = | 608 content::SessionStorageNamespace* session_storage_namespace = |
609 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 609 tab->web_contents()->GetController().GetSessionStorageNamespaceMap() |
| 610 .find("")->second; |
610 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 611 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
611 tab->restore_tab_helper()->session_id(), | 612 tab->restore_tab_helper()->session_id(), |
612 session_storage_namespace->persistent_id())); | 613 session_storage_namespace->persistent_id())); |
613 session_storage_namespace->SetShouldPersist(true); | 614 session_storage_namespace->SetShouldPersist(true); |
614 break; | 615 break; |
615 } | 616 } |
616 | 617 |
617 case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { | 618 case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { |
618 TabContents* tab = content::Source<TabContents>(source).ptr(); | 619 TabContents* tab = content::Source<TabContents>(source).ptr(); |
619 if (!tab || tab->profile() != profile()) | 620 if (!tab || tab->profile() != profile()) |
620 return; | 621 return; |
621 // Allow the associated sessionStorage to get deleted; it won't be needed | 622 // Allow the associated sessionStorage to get deleted; it won't be needed |
622 // in the session restore. | 623 // in the session restore. |
623 content::SessionStorageNamespace* session_storage_namespace = | 624 content::SessionStorageNamespace* session_storage_namespace = |
624 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 625 tab->web_contents()->GetController().GetSessionStorageNamespaceMap() |
| 626 .find("")->second; |
625 session_storage_namespace->SetShouldPersist(false); | 627 session_storage_namespace->SetShouldPersist(false); |
626 TabClosed(tab->restore_tab_helper()->window_id(), | 628 TabClosed(tab->restore_tab_helper()->window_id(), |
627 tab->restore_tab_helper()->session_id(), | 629 tab->restore_tab_helper()->session_id(), |
628 tab->web_contents()->GetClosedByUserGesture()); | 630 tab->web_contents()->GetClosedByUserGesture()); |
629 RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); | 631 RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); |
630 break; | 632 break; |
631 } | 633 } |
632 | 634 |
633 case content::NOTIFICATION_NAV_LIST_PRUNED: { | 635 case content::NOTIFICATION_NAV_LIST_PRUNED: { |
634 TabContents* tab = TabContents::FromWebContents( | 636 TabContents* tab = TabContents::FromWebContents( |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 commands->push_back( | 1341 commands->push_back( |
1340 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); | 1342 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); |
1341 | 1343 |
1342 if (index_in_window != -1) { | 1344 if (index_in_window != -1) { |
1343 commands->push_back( | 1345 commands->push_back( |
1344 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); | 1346 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); |
1345 } | 1347 } |
1346 | 1348 |
1347 // Record the association between the sessionStorage namespace and the tab. | 1349 // Record the association between the sessionStorage namespace and the tab. |
1348 content::SessionStorageNamespace* session_storage_namespace = | 1350 content::SessionStorageNamespace* session_storage_namespace = |
1349 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 1351 tab->web_contents()->GetController().GetSessionStorageNamespaceMap() |
| 1352 .find("")->second; |
1350 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 1353 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
1351 tab->restore_tab_helper()->session_id(), | 1354 tab->restore_tab_helper()->session_id(), |
1352 session_storage_namespace->persistent_id())); | 1355 session_storage_namespace->persistent_id())); |
1353 } | 1356 } |
1354 | 1357 |
1355 void SessionService::BuildCommandsForBrowser( | 1358 void SessionService::BuildCommandsForBrowser( |
1356 Browser* browser, | 1359 Browser* browser, |
1357 std::vector<SessionCommand*>* commands, | 1360 std::vector<SessionCommand*>* commands, |
1358 IdToRange* tab_to_available_range, | 1361 IdToRange* tab_to_available_range, |
1359 std::set<SessionID::id_type>* windows_to_track) { | 1362 std::set<SessionID::id_type>* windows_to_track) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 50); | 1728 50); |
1726 if (use_long_period) { | 1729 if (use_long_period) { |
1727 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1730 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1728 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1731 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1729 delta, | 1732 delta, |
1730 save_delay_in_mins_, | 1733 save_delay_in_mins_, |
1731 save_delay_in_hrs_, | 1734 save_delay_in_hrs_, |
1732 50); | 1735 50); |
1733 } | 1736 } |
1734 } | 1737 } |
OLD | NEW |