Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/app_mode/app_launch_utils.h" | 5 #include "chrome/browser/chromeos/app_mode/app_launch_utils.h" |
| 6 | 6 |
| 7 #include "base/timer/timer.h" | 7 #include "base/timer/timer.h" |
| 8 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 8 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 9 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" | 9 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 void Start() { | 24 void Start() { |
| 25 startup_app_launcher_->AddObserver(this); | 25 startup_app_launcher_->AddObserver(this); |
| 26 startup_app_launcher_->Initialize(); | 26 startup_app_launcher_->Initialize(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 virtual ~AppLaunchManager() {} | 30 virtual ~AppLaunchManager() {} |
| 31 | 31 |
| 32 void Cleanup() { delete this; } | 32 void Cleanup() { delete this; } |
| 33 | 33 |
| 34 void OnNetworkWaitTimedout() { | |
| 35 DCHECK(waiting_for_network_); | |
| 36 LOG(ERROR) << "Timed out while waiting for network during app launch."; | |
| 37 OnLaunchFailed(KioskAppLaunchError::UNABLE_TO_INSTALL); | |
| 38 } | |
| 39 | |
| 40 // StartupAppLauncher::Observer overrides: | 34 // StartupAppLauncher::Observer overrides: |
| 41 virtual void OnLoadingOAuthFile() OVERRIDE {} | 35 virtual void OnLoadingOAuthFile() OVERRIDE {} |
| 42 virtual void OnInitializingTokenService() OVERRIDE {} | 36 virtual void OnInitializingTokenService() OVERRIDE {} |
| 43 | 37 |
| 44 virtual void OnInitializingNetwork() OVERRIDE { | 38 virtual void OnInitializingNetwork() OVERRIDE { |
| 45 waiting_for_network_ = true; | 39 // This is on crash-restart path and assumes network is online. |
| 46 const int kMaxNetworkWaitSeconds = 5 * 60; | 40 startup_app_launcher_->ContinueWithNetworkReady(); |
|
zel
2013/11/20 19:21:21
what if we crashed before we managed to connect to
Tim Song
2013/11/21 01:12:17
When we are waiting on the network in the splash s
xiyuan
2013/11/21 22:39:39
Talked to zel and we probably would get rid of the
| |
| 47 network_wait_timer_.Start( | |
| 48 FROM_HERE, | |
| 49 base::TimeDelta::FromSeconds(kMaxNetworkWaitSeconds), | |
| 50 this, &AppLaunchManager::OnNetworkWaitTimedout); | |
| 51 } | 41 } |
| 52 | 42 |
| 53 virtual void OnInstallingApp() OVERRIDE { | 43 virtual void OnInstallingApp() OVERRIDE { |
| 54 waiting_for_network_ = false; | 44 waiting_for_network_ = false; |
| 55 network_wait_timer_.Stop(); | 45 network_wait_timer_.Stop(); |
| 56 } | 46 } |
| 57 | 47 |
| 58 virtual void OnReadyToLaunch() OVERRIDE { | 48 virtual void OnReadyToLaunch() OVERRIDE { |
| 59 startup_app_launcher_->LaunchApp(); | 49 startup_app_launcher_->LaunchApp(); |
| 60 } | 50 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 72 | 62 |
| 73 DISALLOW_COPY_AND_ASSIGN(AppLaunchManager); | 63 DISALLOW_COPY_AND_ASSIGN(AppLaunchManager); |
| 74 }; | 64 }; |
| 75 | 65 |
| 76 void LaunchAppOrDie(Profile* profile, const std::string& app_id) { | 66 void LaunchAppOrDie(Profile* profile, const std::string& app_id) { |
| 77 // AppLaunchManager manages its own lifetime. | 67 // AppLaunchManager manages its own lifetime. |
| 78 (new AppLaunchManager(profile, app_id))->Start(); | 68 (new AppLaunchManager(profile, app_id))->Start(); |
| 79 } | 69 } |
| 80 | 70 |
| 81 } // namespace chromeos | 71 } // namespace chromeos |
| OLD | NEW |