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

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 519090: Changes synchronous session restore to create windows after nested... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore.cc
===================================================================
--- chrome/browser/sessions/session_restore.cc (revision 35796)
+++ chrome/browser/sessions/session_restore.cc (working copy)
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/scoped_ptr.h"
+#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
@@ -191,6 +192,7 @@
if (synchronous_) {
MessageLoop::current()->Run();
+ ProcessSessionWindows(&windows_);
delete this;
return;
}
@@ -202,6 +204,7 @@
}
~SessionRestoreImpl() {
+ STLDeleteElements(&windows_);
}
virtual void Observe(NotificationType type,
@@ -238,9 +241,6 @@
browser->window()->Show();
}
- if (synchronous_)
- MessageLoop::current()->Quit();
-
if (succeeded) {
DCHECK(tab_loader_.get());
// TabLoader delets itself when done loading.
@@ -258,6 +258,16 @@
void OnGotSession(SessionService::Handle handle,
std::vector<SessionWindow*>* windows) {
+ if (synchronous_) {
+ // See comment above windows_ as to why we don't process immediately.
+ windows_.swap(*windows);
+ MessageLoop::current()->Quit();
+ return;
+ }
+ ProcessSessionWindows(windows);
+ }
+
+ void ProcessSessionWindows(std::vector<SessionWindow*>* windows) {
if (windows->empty()) {
// Restore was unsuccessful.
FinishedTabCreation(false, false);
@@ -417,6 +427,12 @@
// Responsible for loading the tabs.
scoped_ptr<TabLoader> tab_loader_;
+ // When synchronous we run a nested message loop. To avoid creating windows
+ // from the nested message loop (which can make exiting the nested message
+ // loop take a while) we cache the SessionWindows here and create the actual
+ // windows when the nested message loop exits.
+ std::vector<SessionWindow*> windows_;
+
NotificationRegistrar registrar_;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698