Commit 8113ead9 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

kiosk: Fix StartupAppLauncher::LaunchApp crash.

Speculative fix. This crash happens if we have pending
OnReadyToLaunch job after CleanUp is being called. The only
possible cause seems to be user manually cancels the launch
while the OnReadyToLaunch job is pending. Use timer for the
job and cancels it in CleanUp to fix the crash.

BUG=331105

Review URL: https://codereview.chromium.org/127183002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243726 0039d316-1c4b-4281-b951-d872f2087c98
parent 6204657c
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
...@@ -219,6 +218,7 @@ void AppLaunchController::OnProfileLoadFailed( ...@@ -219,6 +218,7 @@ void AppLaunchController::OnProfileLoadFailed(
void AppLaunchController::CleanUp() { void AppLaunchController::CleanUp() {
kiosk_profile_loader_.reset(); kiosk_profile_loader_.reset();
startup_app_launcher_.reset(); startup_app_launcher_.reset();
splash_wait_timer_.Stop();
if (host_) if (host_)
host_->Finalize(); host_->Finalize();
...@@ -326,6 +326,9 @@ void AppLaunchController::OnReadyToLaunch() { ...@@ -326,6 +326,9 @@ void AppLaunchController::OnReadyToLaunch() {
if (!webui_visible_) if (!webui_visible_)
return; return;
if (splash_wait_timer_.IsRunning())
return;
const int64 time_taken_ms = (base::TimeTicks::Now() - const int64 time_taken_ms = (base::TimeTicks::Now() -
base::TimeTicks::FromInternalValue(launch_splash_start_time_)). base::TimeTicks::FromInternalValue(launch_splash_start_time_)).
InMilliseconds(); InMilliseconds();
...@@ -333,12 +336,12 @@ void AppLaunchController::OnReadyToLaunch() { ...@@ -333,12 +336,12 @@ void AppLaunchController::OnReadyToLaunch() {
// Enforce that we show app install splash screen for some minimum amount // Enforce that we show app install splash screen for some minimum amount
// of time. // of time.
if (!skip_splash_wait_ && time_taken_ms < kAppInstallSplashScreenMinTimeMS) { if (!skip_splash_wait_ && time_taken_ms < kAppInstallSplashScreenMinTimeMS) {
content::BrowserThread::PostDelayedTask( splash_wait_timer_.Start(
content::BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&AppLaunchController::OnReadyToLaunch, AsWeakPtr()),
base::TimeDelta::FromMilliseconds( base::TimeDelta::FromMilliseconds(
kAppInstallSplashScreenMinTimeMS - time_taken_ms)); kAppInstallSplashScreenMinTimeMS - time_taken_ms),
this,
&AppLaunchController::OnReadyToLaunch);
return; return;
} }
...@@ -355,7 +358,8 @@ void AppLaunchController::OnLaunchSucceeded() { ...@@ -355,7 +358,8 @@ void AppLaunchController::OnLaunchSucceeded() {
} }
void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) { void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) {
LOG(ERROR) << "Kiosk launch failed. Will now shut down."; LOG(ERROR) << "Kiosk launch failed. Will now shut down."
<< ", error=" << error;
DCHECK_NE(KioskAppLaunchError::NONE, error); DCHECK_NE(KioskAppLaunchError::NONE, error);
// Saves the error and ends the session to go back to login screen. // Saves the error and ends the session to go back to login screen.
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h" #include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
...@@ -32,8 +30,7 @@ class UserManager; ...@@ -32,8 +30,7 @@ class UserManager;
// coordinating loading the kiosk profile, launching the app, and // coordinating loading the kiosk profile, launching the app, and
// updating the splash screen UI. // updating the splash screen UI.
class AppLaunchController class AppLaunchController
: public base::SupportsWeakPtr<AppLaunchController>, : public AppLaunchSplashScreenActor::Delegate,
public AppLaunchSplashScreenActor::Delegate,
public KioskProfileLoader::Delegate, public KioskProfileLoader::Delegate,
public StartupAppLauncher::Delegate, public StartupAppLauncher::Delegate,
public AppLaunchSigninScreen::Delegate, public AppLaunchSigninScreen::Delegate,
...@@ -122,6 +119,9 @@ class AppLaunchController ...@@ -122,6 +119,9 @@ class AppLaunchController
bool webui_visible_; bool webui_visible_;
bool launcher_ready_; bool launcher_ready_;
// A timer to ensure the app splash is shown for a minimum amount of time.
base::OneShotTimer<AppLaunchController> splash_wait_timer_;
base::OneShotTimer<AppLaunchController> network_wait_timer_; base::OneShotTimer<AppLaunchController> network_wait_timer_;
bool waiting_for_network_; bool waiting_for_network_;
bool network_wait_timedout_; bool network_wait_timedout_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment