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_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 base::TimeDelta time_to_process_sessions = | 725 base::TimeDelta time_to_process_sessions = |
726 base::TimeTicks::Now() - restore_started_; | 726 base::TimeTicks::Now() - restore_started_; |
727 UMA_HISTOGRAM_CUSTOM_TIMES( | 727 UMA_HISTOGRAM_CUSTOM_TIMES( |
728 "SessionRestore.TimeToProcessSessions", | 728 "SessionRestore.TimeToProcessSessions", |
729 time_to_process_sessions, | 729 time_to_process_sessions, |
730 base::TimeDelta::FromMilliseconds(10), | 730 base::TimeDelta::FromMilliseconds(10), |
731 base::TimeDelta::FromSeconds(1000), | 731 base::TimeDelta::FromSeconds(1000), |
732 100); | 732 100); |
733 | 733 |
734 if (windows->empty()) { | 734 if (windows->empty()) { |
735 // Restore was unsuccessful. | 735 // Restore was unsuccessful. The DOM storage system can also delete its |
| 736 // data, since no session restore will happen at a later point in time. |
| 737 content::DOMStorageContext* dom_storage_context = |
| 738 content::BrowserContext::GetDOMStorageContext(profile_); |
| 739 dom_storage_context->StartScavengingUnusedSessionStorage(); |
736 return FinishedTabCreation(false, false); | 740 return FinishedTabCreation(false, false); |
737 } | 741 } |
738 | 742 |
739 #if defined(OS_CHROMEOS) | 743 #if defined(OS_CHROMEOS) |
740 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 744 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
741 "SessionRestore-CreatingTabs-Start", false); | 745 "SessionRestore-CreatingTabs-Start", false); |
742 #endif | 746 #endif |
743 StartTabCreation(); | 747 StartTabCreation(); |
744 | 748 |
745 // After the for loop this contains the last TABBED_BROWSER. Is null if no | 749 // After the for loop this contains the last TABBED_BROWSER. Is null if no |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 #if defined(OS_CHROMEOS) | 818 #if defined(OS_CHROMEOS) |
815 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 819 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
816 "SessionRestore-CreatingTabs-End", false); | 820 "SessionRestore-CreatingTabs-End", false); |
817 #endif | 821 #endif |
818 // If last_browser is NULL and urls_to_open_ is non-empty, | 822 // If last_browser is NULL and urls_to_open_ is non-empty, |
819 // FinishedTabCreation will create a new TabbedBrowser and add the urls to | 823 // FinishedTabCreation will create a new TabbedBrowser and add the urls to |
820 // it. | 824 // it. |
821 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); | 825 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); |
822 if (finished_browser) | 826 if (finished_browser) |
823 last_browser = finished_browser; | 827 last_browser = finished_browser; |
| 828 |
| 829 // sessionStorages needed for the session restore have now been recreated |
| 830 // by RestoreTab. Now it's safe for the DOM storage system to start |
| 831 // deleting leftover data. |
| 832 content::DOMStorageContext* dom_storage_context = |
| 833 content::BrowserContext::GetDOMStorageContext(profile_); |
| 834 dom_storage_context->StartScavengingUnusedSessionStorage(); |
824 return last_browser; | 835 return last_browser; |
825 } | 836 } |
826 | 837 |
827 // Record an app launch event (if appropriate) for a tab which is about to | 838 // Record an app launch event (if appropriate) for a tab which is about to |
828 // be restored. Callers should ensure that selected_index is within the | 839 // be restored. Callers should ensure that selected_index is within the |
829 // bounds of tab.navigations before calling. | 840 // bounds of tab.navigations before calling. |
830 void RecordAppLaunchForTab(Browser* browser, | 841 void RecordAppLaunchForTab(Browser* browser, |
831 const SessionTab& tab, | 842 const SessionTab& tab, |
832 int selected_index) { | 843 int selected_index) { |
833 DCHECK(selected_index >= 0 && | 844 DCHECK(selected_index >= 0 && |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 if (active_session_restorers == NULL) | 1100 if (active_session_restorers == NULL) |
1090 return false; | 1101 return false; |
1091 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1102 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1092 active_session_restorers->begin(); | 1103 active_session_restorers->begin(); |
1093 it != active_session_restorers->end(); ++it) { | 1104 it != active_session_restorers->end(); ++it) { |
1094 if ((*it)->profile() == profile) | 1105 if ((*it)->profile() == profile) |
1095 return true; | 1106 return true; |
1096 } | 1107 } |
1097 return false; | 1108 return false; |
1098 } | 1109 } |
OLD | NEW |