Skip to content

Commit

Permalink
Add more conditions to reload when --reload-killed-tab option is used.
Browse files Browse the repository at this point in the history
BUG=NONE
TEST=compiles


Review URL: https://chromiumcodereview.appspot.com/11342055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165831 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
simon.hong81@gmail.com committed Nov 3, 2012
1 parent a655da9 commit b6975b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Clinton Staley <clintstaley@chromium.org>
Devlin Cronin <rdevlin.cronin@gmail.com>
Junmin Zhu <junmin.zhu@intel.com>
Cem Kocagil <cem.kocagil@gmail.com>
Simon Hong <simon.hong81@gmail.com>
YoungKi Hong <simon.hong81@gmail.com>
Lu Guanqun <guanqun.lu@gmail.com>
François Beaufort <beaufort.francois@gmail.com>
Eriq Augustine <eriq.augustine@gmail.com>
Expand Down
38 changes: 20 additions & 18 deletions chrome/browser/ui/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ chrome::HostDesktopType kDefaultHostDesktopType =
chrome::HOST_DESKTOP_TYPE_NATIVE;
#endif

bool ShouldReloadCrashedTab(WebContents* contents) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kReloadKilledTabs))
return false;

base::TerminationStatus crashed_status = contents->GetCrashedStatus();

return crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED;
}

} // namespace

Expand Down Expand Up @@ -645,13 +656,8 @@ void Browser::OnWindowActivated() {
// On some platforms we want to automatically reload tabs that are
// killed when the user selects them.
WebContents* contents = chrome::GetActiveWebContents(this);
if (contents && contents->GetCrashedStatus() ==
base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kReloadKilledTabs)) {
chrome::Reload(this, CURRENT_TAB);
}
}
if (contents && ShouldReloadCrashedTab(contents))
chrome::Reload(this, CURRENT_TAB);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1076,17 +1082,13 @@ void Browser::ActiveTabChanged(TabContents* old_contents,
// On some platforms we want to automatically reload tabs that are
// killed when the user selects them.
bool did_reload = false;
if (user_gesture && new_contents->web_contents()->GetCrashedStatus() ==
base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) {
LOG(WARNING) << "Reloading killed tab at " << index;
static int reload_count = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
chrome::Reload(this, CURRENT_TAB);
did_reload = true;
}
if (user_gesture && ShouldReloadCrashedTab(new_contents->web_contents())) {
LOG(WARNING) << "Reloading killed tab at " << index;
static int reload_count = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
chrome::Reload(this, CURRENT_TAB);
did_reload = true;
}

// Discarded tabs always get reloaded.
Expand Down

0 comments on commit b6975b9

Please sign in to comment.