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 25 matching lines...) Expand all Loading... |
36 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
37 #include "content/public/browser/child_process_security_policy.h" | 37 #include "content/public/browser/child_process_security_policy.h" |
38 #include "content/public/browser/dom_storage_context.h" | 38 #include "content/public/browser/dom_storage_context.h" |
39 #include "content/public/browser/navigation_controller.h" | 39 #include "content/public/browser/navigation_controller.h" |
40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
41 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
43 #include "content/public/browser/render_widget_host.h" | 43 #include "content/public/browser/render_widget_host.h" |
44 #include "content/public/browser/render_widget_host_view.h" | 44 #include "content/public/browser/render_widget_host_view.h" |
45 #include "content/public/browser/session_storage_namespace.h" | 45 #include "content/public/browser/session_storage_namespace.h" |
| 46 #include "content/public/browser/storage_partition.h" |
46 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
47 #include "content/public/browser/web_contents_view.h" | 48 #include "content/public/browser/web_contents_view.h" |
48 #include "net/base/network_change_notifier.h" | 49 #include "net/base/network_change_notifier.h" |
49 #include "webkit/glue/glue_serialize.h" | 50 #include "webkit/glue/glue_serialize.h" |
50 | 51 |
51 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
52 #include "chrome/browser/chromeos/boot_times_loader.h" | 53 #include "chrome/browser/chromeos/boot_times_loader.h" |
53 #endif | 54 #endif |
54 | 55 |
55 using content::NavigationController; | 56 using content::NavigationController; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 UMA_HISTOGRAM_CUSTOM_TIMES( | 732 UMA_HISTOGRAM_CUSTOM_TIMES( |
732 "SessionRestore.TimeToProcessSessions", | 733 "SessionRestore.TimeToProcessSessions", |
733 time_to_process_sessions, | 734 time_to_process_sessions, |
734 base::TimeDelta::FromMilliseconds(10), | 735 base::TimeDelta::FromMilliseconds(10), |
735 base::TimeDelta::FromSeconds(1000), | 736 base::TimeDelta::FromSeconds(1000), |
736 100); | 737 100); |
737 | 738 |
738 if (windows->empty()) { | 739 if (windows->empty()) { |
739 // Restore was unsuccessful. The DOM storage system can also delete its | 740 // Restore was unsuccessful. The DOM storage system can also delete its |
740 // data, since no session restore will happen at a later point in time. | 741 // data, since no session restore will happen at a later point in time. |
741 content::BrowserContext::GetDefaultDOMStorageContext(profile_)-> | 742 content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
742 StartScavengingUnusedSessionStorage(); | 743 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); |
743 return FinishedTabCreation(false, false); | 744 return FinishedTabCreation(false, false); |
744 } | 745 } |
745 | 746 |
746 #if defined(OS_CHROMEOS) | 747 #if defined(OS_CHROMEOS) |
747 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 748 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
748 "SessionRestore-CreatingTabs-Start", false); | 749 "SessionRestore-CreatingTabs-Start", false); |
749 #endif | 750 #endif |
750 StartTabCreation(); | 751 StartTabCreation(); |
751 | 752 |
752 // After the for loop this contains the last TABBED_BROWSER. Is null if no | 753 // After the for loop this contains the last TABBED_BROWSER. Is null if no |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 // If last_browser is NULL and urls_to_open_ is non-empty, | 826 // If last_browser is NULL and urls_to_open_ is non-empty, |
826 // FinishedTabCreation will create a new TabbedBrowser and add the urls to | 827 // FinishedTabCreation will create a new TabbedBrowser and add the urls to |
827 // it. | 828 // it. |
828 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); | 829 Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser); |
829 if (finished_browser) | 830 if (finished_browser) |
830 last_browser = finished_browser; | 831 last_browser = finished_browser; |
831 | 832 |
832 // sessionStorages needed for the session restore have now been recreated | 833 // sessionStorages needed for the session restore have now been recreated |
833 // by RestoreTab. Now it's safe for the DOM storage system to start | 834 // by RestoreTab. Now it's safe for the DOM storage system to start |
834 // deleting leftover data. | 835 // deleting leftover data. |
835 content::BrowserContext::GetDefaultDOMStorageContext(profile_)-> | 836 content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
836 StartScavengingUnusedSessionStorage(); | 837 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); |
837 return last_browser; | 838 return last_browser; |
838 } | 839 } |
839 | 840 |
840 // Record an app launch event (if appropriate) for a tab which is about to | 841 // Record an app launch event (if appropriate) for a tab which is about to |
841 // be restored. Callers should ensure that selected_index is within the | 842 // be restored. Callers should ensure that selected_index is within the |
842 // bounds of tab.navigations before calling. | 843 // bounds of tab.navigations before calling. |
843 void RecordAppLaunchForTab(Browser* browser, | 844 void RecordAppLaunchForTab(Browser* browser, |
844 const SessionTab& tab, | 845 const SessionTab& tab, |
845 int selected_index) { | 846 int selected_index) { |
846 DCHECK(selected_index >= 0 && | 847 DCHECK(selected_index >= 0 && |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 0, | 885 0, |
885 std::min(selected_index, | 886 std::min(selected_index, |
886 static_cast<int>(tab.navigations.size() - 1))); | 887 static_cast<int>(tab.navigations.size() - 1))); |
887 | 888 |
888 RecordAppLaunchForTab(browser, tab, selected_index); | 889 RecordAppLaunchForTab(browser, tab, selected_index); |
889 | 890 |
890 // Associate sessionStorage (if any) to the restored tab. | 891 // Associate sessionStorage (if any) to the restored tab. |
891 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; | 892 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; |
892 if (!tab.session_storage_persistent_id.empty()) { | 893 if (!tab.session_storage_persistent_id.empty()) { |
893 session_storage_namespace = | 894 session_storage_namespace = |
894 content::BrowserContext::GetDefaultDOMStorageContext(profile_)-> | 895 content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
895 RecreateSessionStorage(tab.session_storage_persistent_id); | 896 GetDOMStorageContext()->RecreateSessionStorage( |
| 897 tab.session_storage_persistent_id); |
896 } | 898 } |
897 | 899 |
898 WebContents* web_contents = | 900 WebContents* web_contents = |
899 chrome::AddRestoredTab(browser, | 901 chrome::AddRestoredTab(browser, |
900 tab.navigations, | 902 tab.navigations, |
901 tab_index, | 903 tab_index, |
902 selected_index, | 904 selected_index, |
903 tab.extension_app_id, | 905 tab.extension_app_id, |
904 false, // select | 906 false, // select |
905 tab.pinned, | 907 tab.pinned, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 if (active_session_restorers == NULL) | 1104 if (active_session_restorers == NULL) |
1103 return false; | 1105 return false; |
1104 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1106 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1105 active_session_restorers->begin(); | 1107 active_session_restorers->begin(); |
1106 it != active_session_restorers->end(); ++it) { | 1108 it != active_session_restorers->end(); ++it) { |
1107 if ((*it)->profile() == profile) | 1109 if ((*it)->profile() == profile) |
1108 return true; | 1110 return true; |
1109 } | 1111 } |
1110 return false; | 1112 return false; |
1111 } | 1113 } |
OLD | NEW |