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

Side by Side Diff: chrome/browser/sessions/session_restore.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code review (pkasting) Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 base::TimeDelta time_to_process_sessions = 726 base::TimeDelta time_to_process_sessions =
727 base::TimeTicks::Now() - restore_started_; 727 base::TimeTicks::Now() - restore_started_;
728 UMA_HISTOGRAM_CUSTOM_TIMES( 728 UMA_HISTOGRAM_CUSTOM_TIMES(
729 "SessionRestore.TimeToProcessSessions", 729 "SessionRestore.TimeToProcessSessions",
730 time_to_process_sessions, 730 time_to_process_sessions,
731 base::TimeDelta::FromMilliseconds(10), 731 base::TimeDelta::FromMilliseconds(10),
732 base::TimeDelta::FromSeconds(1000), 732 base::TimeDelta::FromSeconds(1000),
733 100); 733 100);
734 734
735 if (windows->empty()) { 735 if (windows->empty()) {
736 // Restore was unsuccessful. 736 // Restore was unsuccessful. The DOM storage system can also delete its
737 // data, since no session restore will happen at a later point in time.
738 content::DOMStorageContext* dom_storage_context =
Peter Kasting 2012/08/07 01:31:54 Nit: I'd probably just do: content::BrowserCont
marja 2012/08/07 07:31:22 Done.
739 content::BrowserContext::GetDefaultDOMStorageContext(profile_);
740 dom_storage_context->StartScavengingUnusedSessionStorage();
737 return FinishedTabCreation(false, false); 741 return FinishedTabCreation(false, false);
738 } 742 }
739 743
740 #if defined(OS_CHROMEOS) 744 #if defined(OS_CHROMEOS)
741 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 745 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
742 "SessionRestore-CreatingTabs-Start", false); 746 "SessionRestore-CreatingTabs-Start", false);
743 #endif 747 #endif
744 StartTabCreation(); 748 StartTabCreation();
745 749
746 // After the for loop this contains the last TABBED_BROWSER. Is null if no 750 // 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
815 #if defined(OS_CHROMEOS) 819 #if defined(OS_CHROMEOS)
816 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 820 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
817 "SessionRestore-CreatingTabs-End", false); 821 "SessionRestore-CreatingTabs-End", false);
818 #endif 822 #endif
819 // If last_browser is NULL and urls_to_open_ is non-empty, 823 // If last_browser is NULL and urls_to_open_ is non-empty,
820 // FinishedTabCreation will create a new TabbedBrowser and add the urls to 824 // FinishedTabCreation will create a new TabbedBrowser and add the urls to
821 // it. 825 // it.
822 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); 826 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser);
823 if (finished_browser) 827 if (finished_browser)
824 last_browser = finished_browser; 828 last_browser = finished_browser;
829
830 // sessionStorages needed for the session restore have now been recreated
831 // by RestoreTab. Now it's safe for the DOM storage system to start
832 // deleting leftover data.
833 content::DOMStorageContext* dom_storage_context =
834 content::BrowserContext::GetDefaultDOMStorageContext(profile_);
835 dom_storage_context->StartScavengingUnusedSessionStorage();
825 return last_browser; 836 return last_browser;
826 } 837 }
827 838
828 // Record an app launch event (if appropriate) for a tab which is about to 839 // Record an app launch event (if appropriate) for a tab which is about to
829 // be restored. Callers should ensure that selected_index is within the 840 // be restored. Callers should ensure that selected_index is within the
830 // bounds of tab.navigations before calling. 841 // bounds of tab.navigations before calling.
831 void RecordAppLaunchForTab(Browser* browser, 842 void RecordAppLaunchForTab(Browser* browser,
832 const SessionTab& tab, 843 const SessionTab& tab,
833 int selected_index) { 844 int selected_index) {
834 DCHECK(selected_index >= 0 && 845 DCHECK(selected_index >= 0 &&
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 if (active_session_restorers == NULL) 1101 if (active_session_restorers == NULL)
1091 return false; 1102 return false;
1092 for (std::set<SessionRestoreImpl*>::const_iterator it = 1103 for (std::set<SessionRestoreImpl*>::const_iterator it =
1093 active_session_restorers->begin(); 1104 active_session_restorers->begin();
1094 it != active_session_restorers->end(); ++it) { 1105 it != active_session_restorers->end(); ++it) {
1095 if ((*it)->profile() == profile) 1106 if ((*it)->profile() == profile)
1096 return true; 1107 return true;
1097 } 1108 }
1098 return false; 1109 return false;
1099 } 1110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698