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

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. Created 8 years, 6 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 14 matching lines...) Expand all
25 #include "chrome/browser/sessions/session_service_factory.h" 25 #include "chrome/browser/sessions/session_service_factory.h"
26 #include "chrome/browser/sessions/session_types.h" 26 #include "chrome/browser/sessions/session_types.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_navigator.h" 29 #include "chrome/browser/ui/browser_navigator.h"
30 #include "chrome/browser/ui/browser_window.h" 30 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model.h"
32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
33 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.h"
34 #include "content/public/browser/child_process_security_policy.h" 34 #include "content/public/browser/child_process_security_policy.h"
35 #include "content/public/browser/dom_storage_context.h"
35 #include "content/public/browser/navigation_controller.h" 36 #include "content/public/browser/navigation_controller.h"
36 #include "content/public/browser/notification_registrar.h" 37 #include "content/public/browser/notification_registrar.h"
37 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/render_process_host.h" 39 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/render_widget_host.h" 40 #include "content/public/browser/render_widget_host.h"
40 #include "content/public/browser/render_widget_host_view.h" 41 #include "content/public/browser/render_widget_host_view.h"
41 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
42 #include "content/public/browser/web_contents_view.h" 43 #include "content/public/browser/web_contents_view.h"
43 #include "net/base/network_change_notifier.h" 44 #include "net/base/network_change_notifier.h"
44 #include "webkit/glue/glue_serialize.h" 45 #include "webkit/glue/glue_serialize.h"
45 46
46 #if defined(OS_CHROMEOS) 47 #if defined(OS_CHROMEOS)
47 #include "chrome/browser/chromeos/boot_times_loader.h" 48 #include "chrome/browser/chromeos/boot_times_loader.h"
48 #endif 49 #endif
49 50
50 using content::NavigationController; 51 using content::NavigationController;
51 using content::RenderWidgetHost; 52 using content::RenderWidgetHost;
52 using content::WebContents; 53 using content::WebContents;
53 54
55 namespace content {
56 class SessinStorageNamespace;
57 } // namespace content
58
54 namespace { 59 namespace {
55 60
56 class SessionRestoreImpl; 61 class SessionRestoreImpl;
57 class TabLoader; 62 class TabLoader;
58 63
59 TabLoader* shared_tab_loader = NULL; 64 TabLoader* shared_tab_loader = NULL;
60 65
61 // Pointers to SessionRestoreImpls which are currently restoring the session. 66 // Pointers to SessionRestoreImpls which are currently restoring the session.
62 std::set<SessionRestoreImpl*>* active_session_restorers = NULL; 67 std::set<SessionRestoreImpl*>* active_session_restorers = NULL;
63 68
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 bool schedule_load) { 873 bool schedule_load) {
869 DCHECK(!tab.navigations.empty()); 874 DCHECK(!tab.navigations.empty());
870 int selected_index = tab.current_navigation_index; 875 int selected_index = tab.current_navigation_index;
871 selected_index = std::max( 876 selected_index = std::max(
872 0, 877 0,
873 std::min(selected_index, 878 std::min(selected_index,
874 static_cast<int>(tab.navigations.size() - 1))); 879 static_cast<int>(tab.navigations.size() - 1)));
875 880
876 RecordAppLaunchForTab(browser, tab, selected_index); 881 RecordAppLaunchForTab(browser, tab, selected_index);
877 882
883 // Associate sessionStorage (if any) to the restored tab.
884 content::SessionStorageNamespace* session_storage_namespace = NULL;
michaeln 2012/06/05 01:41:07 probably s/b a scoped_refptr<> here
marja 2012/06/06 13:37:10 Done.
885 if (!tab.session_storage_persistent_id.empty()) {
886 session_storage_namespace =
887 content::BrowserContext::GetDOMStorageContext(profile_)->
888 CreateSessionStorage(tab.session_storage_persistent_id);
889 }
890
878 WebContents* web_contents = 891 WebContents* web_contents =
879 browser->AddRestoredTab(tab.navigations, 892 browser->AddRestoredTab(tab.navigations,
880 tab_index, 893 tab_index,
881 selected_index, 894 selected_index,
882 tab.extension_app_id, 895 tab.extension_app_id,
883 false, // select 896 false, // select
884 tab.pinned, 897 tab.pinned,
885 true, 898 true,
886 NULL); 899 session_storage_namespace);
887 // Regression check: check that the tab didn't start loading right away. The 900 // Regression check: check that the tab didn't start loading right away. The
888 // focused tab will be loaded by Browser, and TabLoader will load the rest. 901 // focused tab will be loaded by Browser, and TabLoader will load the rest.
889 DCHECK(web_contents->GetController().NeedsReload()); 902 DCHECK(web_contents->GetController().NeedsReload());
890 903
891 // Set up the file access rights for the selected navigation entry. 904 // Set up the file access rights for the selected navigation entry.
892 const int id = web_contents->GetRenderProcessHost()->GetID(); 905 const int id = web_contents->GetRenderProcessHost()->GetID();
893 const int read_file_permissions = 906 const int read_file_permissions =
894 base::PLATFORM_FILE_OPEN | 907 base::PLATFORM_FILE_OPEN |
895 base::PLATFORM_FILE_READ | 908 base::PLATFORM_FILE_READ |
896 base::PLATFORM_FILE_EXCLUSIVE_READ | 909 base::PLATFORM_FILE_EXCLUSIVE_READ |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 if (active_session_restorers == NULL) 1093 if (active_session_restorers == NULL)
1081 return false; 1094 return false;
1082 for (std::set<SessionRestoreImpl*>::const_iterator it = 1095 for (std::set<SessionRestoreImpl*>::const_iterator it =
1083 active_session_restorers->begin(); 1096 active_session_restorers->begin();
1084 it != active_session_restorers->end(); ++it) { 1097 it != active_session_restorers->end(); ++it) {
1085 if ((*it)->profile() == profile) 1098 if ((*it)->profile() == profile)
1086 return true; 1099 return true;
1087 } 1100 }
1088 return false; 1101 return false;
1089 } 1102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698