#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
+#include "base/debug/alias.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/metrics/histogram.h"
-#include "base/platform_file.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
// Called when a tab goes away or a load completes.
void HandleTabClosedOrLoaded(NavigationController* controller);
+ // TODO(sky): remove. For debugging 368236.
+ void CheckNotObserving(NavigationController* controller);
+
content::NotificationRegistrar registrar_;
// Current delay before a new tab is loaded. See class description for
}
void TabLoader::ScheduleLoad(NavigationController* controller) {
+ CheckNotObserving(controller);
DCHECK(controller);
DCHECK(find(tabs_to_load_.begin(), tabs_to_load_.end(), controller) ==
tabs_to_load_.end());
}
void TabLoader::TabIsLoading(NavigationController* controller) {
+ CheckNotObserving(controller);
DCHECK(controller);
DCHECK(find(tabs_loading_.begin(), tabs_loading_.end(), controller) ==
tabs_loading_.end());
}
}
+void TabLoader::CheckNotObserving(NavigationController* controller) {
+ const bool in_tabs_to_load =
+ find(tabs_to_load_.begin(), tabs_to_load_.end(), controller) !=
+ tabs_to_load_.end();
+ const bool in_tabs_loading =
+ find(tabs_loading_.begin(), tabs_loading_.end(), controller) !=
+ tabs_loading_.end();
+ const bool observing =
+ registrar_.IsRegistered(
+ this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::Source<WebContents>(controller->GetWebContents())) ||
+ registrar_.IsRegistered(
+ this, content::NOTIFICATION_LOAD_STOP,
+ content::Source<NavigationController>(controller)) ||
+ registrar_.IsRegistered(
+ this, content::NOTIFICATION_LOAD_START,
+ content::Source<NavigationController>(controller));
+ base::debug::Alias(&in_tabs_to_load);
+ base::debug::Alias(&in_tabs_loading);
+ base::debug::Alias(&observing);
+ CHECK(!in_tabs_to_load && !in_tabs_loading && !observing);
+}
+
// SessionRestoreImpl ---------------------------------------------------------
// SessionRestoreImpl is responsible for fetching the set of tabs to create
host_desktop_type_));
if (urls_to_open_.empty()) {
// No tab browsers were created and no URLs were supplied on the command
- // line. Add an empty URL, which is treated as opening the users home
- // page.
- urls_to_open_.push_back(GURL());
+ // line. Open the new tab page.
+ urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL));
}
AppendURLsToBrowser(browser, urls_to_open_);
browser->window()->Show();
// Loads are scheduled for each restored tab unless the tab is going to
// be selected as ShowBrowser() will load the selected tab.
- bool is_not_selected_tab = (i != selected_tab_index);
+ bool is_selected_tab = (i == selected_tab_index);
WebContents* restored_tab =
- RestoreTab(tab, i, browser, is_not_selected_tab);
+ RestoreTab(tab, i, browser, is_selected_tab);
// RestoreTab can return NULL if |tab| doesn't have valid data.
if (!restored_tab)
continue;
// If this isn't the selected tab, there's nothing else to do.
- if (is_not_selected_tab)
+ if (!is_selected_tab)
continue;
ShowBrowser(
browser,
browser->tab_strip_model()->GetIndexOfWebContents(restored_tab));
+ // TODO(sky): remove. For debugging 368236.
+ CHECK_EQ(browser->tab_strip_model()->GetActiveWebContents(),
+ restored_tab);
tab_loader_->TabIsLoading(&browser->tab_strip_model()
->GetActiveWebContents()
->GetController());
for (int i = 0; i < static_cast<int>(window.tabs.size()); ++i) {
const SessionTab& tab = *(window.tabs[i]);
// Always schedule loads as we will not be calling ShowBrowser().
- RestoreTab(tab, tab_index_offset + i, browser, true);
+ RestoreTab(tab, tab_index_offset + i, browser, false);
}
}
}
// |tab_index| is ignored for pinned tabs which will always be pushed behind
// the last existing pinned tab.
- // |schedule_load| will let |tab_loader_| know that it should schedule this
- // tab for loading.
+ // |tab_loader_| will schedule this tab for loading if |is_selected_tab| is
+ // false.
WebContents* RestoreTab(const SessionTab& tab,
const int tab_index,
Browser* browser,
- bool schedule_load) {
+ bool is_selected_tab) {
// It's possible (particularly for foreign sessions) to receive a tab
// without valid navigations. In that case, just skip it.
// See crbug.com/154129.
*file);
}
- if (schedule_load)
+ if (!is_selected_tab)
tab_loader_->ScheduleLoad(&web_contents->GetController());
return web_contents;
}