diff options
author | alemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-12 16:17:27 +0000 |
---|---|---|
committer | alemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-12 16:17:27 +0000 |
commit | fa4fc43e3b8c4bdf25f95fd3b62b4c5bbaefdcb2 (patch) | |
tree | 1c4fe3e196b5057a9ca92596926c7fda02e53e49 | |
parent | c48048bdad8de22410dd5b97c40bd9c84b5cf3cb (diff) | |
download | chromium_src-fa4fc43e3b8c4bdf25f95fd3b62b4c5bbaefdcb2.zip chromium_src-fa4fc43e3b8c4bdf25f95fd3b62b4c5bbaefdcb2.tar.gz chromium_src-fa4fc43e3b8c4bdf25f95fd3b62b4c5bbaefdcb2.tar.bz2 |
Drop struct BootStat and all usage (boot stats are now sent from chromeos code).
BUG=141757
As far as I see, after migrating
BootTime.Total
BootTime.Firmware
BootTime.Kernel
BootTime.System
BootTime.Chrome
to chromeos, struct chromeos::BootTimesLoader::BootTimes becomes empty. So I've dropped it completely and all references to it.
Probably class BootTimesLoader should also be renamed as it doesn't load any times anymore, but instead reports time marks.
Please review.
Review URL: https://chromiumcodereview.appspot.com/22262004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217006 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 0 insertions, 244 deletions
diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc index 594ff42..2ef50a1 100644 --- a/chrome/browser/chromeos/boot_times_loader.cc +++ b/chrome/browser/chromeos/boot_times_loader.cc @@ -69,16 +69,6 @@ const std::string GetTabUrl(RenderWidgetHost* rwh) { return std::string(); } -void PostCallbackIfNotCanceled( - const CancelableTaskTracker::IsCanceledCallback& is_canceled_cb, - base::TaskRunner* task_runner, - const chromeos::BootTimesLoader::GetBootTimesCallback& callback, - const chromeos::BootTimesLoader::BootTimes& boot_times) { - if (is_canceled_cb.Run()) - return; - task_runner->PostTask(FROM_HERE, base::Bind(callback, boot_times)); -} - } // namespace namespace chromeos { @@ -135,152 +125,6 @@ BootTimesLoader* BootTimesLoader::Get() { return g_boot_times_loader.Pointer(); } -CancelableTaskTracker::TaskId BootTimesLoader::GetBootTimes( - const GetBootTimesCallback& callback, - CancelableTaskTracker* tracker) { - if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { - // This should only happen if Chrome is shutting down, so we don't do - // anything. - return CancelableTaskTracker::kBadTaskId; - } - - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kTestType)) { - // TODO(davemoore) This avoids boottimes for tests. This needs to be - // replaced with a mock of BootTimesLoader. - return CancelableTaskTracker::kBadTaskId; - } - - CancelableTaskTracker::IsCanceledCallback is_canceled; - CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); - - GetBootTimesCallback callback_runner = - base::Bind(&PostCallbackIfNotCanceled, - is_canceled, base::MessageLoopProxy::current(), callback); - BrowserThread::PostTask( - BrowserThread::FILE, - FROM_HERE, - base::Bind(&Backend::GetBootTimesAndRunCallback, - backend_, is_canceled, callback_runner)); - return id; -} - -// Extracts the uptime value from files located in /tmp, returning the -// value as a double in value. -static bool GetTime(const base::FilePath::StringType& log, double* value) { - base::FilePath log_dir(kLogPath); - base::FilePath log_file = log_dir.Append(log); - std::string contents; - *value = 0.0; - if (file_util::ReadFileToString(log_file, &contents)) { - size_t space_index = contents.find(' '); - size_t chars_left = - space_index != std::string::npos ? space_index : std::string::npos; - std::string value_string = contents.substr(0, chars_left); - return base::StringToDouble(value_string, value); - } - return false; -} - -// Converts double seconds to a TimeDelta object. -static base::TimeDelta SecondsToTimeDelta(double seconds) { - double ms = seconds * base::Time::kMillisecondsPerSecond; - return base::TimeDelta::FromMilliseconds(static_cast<int64>(ms)); -} - -// Reports the collected boot times to UMA if they haven't been -// reported yet and if metrics collection is enabled. -static void SendBootTimesToUMA(const BootTimesLoader::BootTimes& boot_times) { - // Checks if the times for the most recent boot event have been - // reported already to avoid sending boot time histogram samples - // every time the user logs out. - static const base::FilePath::CharType kBootTimesSent[] = - FPL("/tmp/boot-times-sent"); - base::FilePath sent(kBootTimesSent); - if (base::PathExists(sent)) - return; - - UMA_HISTOGRAM_TIMES("BootTime.Total", - SecondsToTimeDelta(boot_times.total)); - UMA_HISTOGRAM_TIMES("BootTime.Firmware", - SecondsToTimeDelta(boot_times.firmware)); - UMA_HISTOGRAM_TIMES("BootTime.Kernel", - SecondsToTimeDelta(boot_times.pre_startup)); - UMA_HISTOGRAM_TIMES("BootTime.System", - SecondsToTimeDelta(boot_times.system)); - if (boot_times.chrome > 0) { - UMA_HISTOGRAM_TIMES("BootTime.Chrome", - SecondsToTimeDelta(boot_times.chrome)); - } - - // Stores the boot times to a file in /tmp to indicate that the - // times for the most recent boot event have been reported - // already. The file will be deleted at system shutdown/reboot. - std::string boot_times_text = base::StringPrintf("total: %.2f\n" - "firmware: %.2f\n" - "kernel: %.2f\n" - "system: %.2f\n" - "chrome: %.2f\n", - boot_times.total, - boot_times.firmware, - boot_times.pre_startup, - boot_times.system, - boot_times.chrome); - file_util::WriteFile(sent, boot_times_text.data(), boot_times_text.size()); - DCHECK(base::PathExists(sent)); -} - -void BootTimesLoader::Backend::GetBootTimesAndRunCallback( - const CancelableTaskTracker::IsCanceledCallback& is_canceled_cb, - const GetBootTimesCallback& callback) { - if (is_canceled_cb.Run()) - return; - - const base::FilePath::CharType kFirmwareBootTime[] = - FPL("firmware-boot-time"); - const base::FilePath::CharType kPreStartup[] = FPL("pre-startup"); - const base::FilePath::CharType kChromeExec[] = FPL("chrome-exec"); - const base::FilePath::CharType kChromeMain[] = FPL("chrome-main"); - const base::FilePath::CharType kXStarted[] = FPL("x-started"); - const base::FilePath::CharType kLoginPromptReady[] = - FPL("login-prompt-ready"); - const base::FilePath::StringType uptime_prefix = kUptimePrefix; - - // Wait until firmware-boot-time file exists by reposting. - base::FilePath log_dir(kLogPath); - base::FilePath log_file = log_dir.Append(kFirmwareBootTime); - if (!base::PathExists(log_file)) { - BrowserThread::PostDelayedTask( - BrowserThread::FILE, - FROM_HERE, - base::Bind(&Backend::GetBootTimesAndRunCallback, - this, is_canceled_cb, callback), - base::TimeDelta::FromMilliseconds(kReadAttemptDelayMs)); - return; - } - - BootTimes boot_times; - - GetTime(kFirmwareBootTime, &boot_times.firmware); - GetTime(uptime_prefix + kPreStartup, &boot_times.pre_startup); - GetTime(uptime_prefix + kXStarted, &boot_times.x_started); - GetTime(uptime_prefix + kChromeExec, &boot_times.chrome_exec); - GetTime(uptime_prefix + kChromeMain, &boot_times.chrome_main); - GetTime(uptime_prefix + kLoginPromptReady, &boot_times.login_prompt_ready); - - boot_times.total = boot_times.firmware + boot_times.login_prompt_ready; - if (boot_times.chrome_exec > 0) { - boot_times.system = boot_times.chrome_exec - boot_times.pre_startup; - boot_times.chrome = boot_times.login_prompt_ready - boot_times.chrome_exec; - } else { - boot_times.system = boot_times.login_prompt_ready - boot_times.pre_startup; - } - - SendBootTimesToUMA(boot_times); - - callback.Run(boot_times); -} - // Appends the given buffer into the file. Returns the number of bytes // written, or -1 on error. // TODO(satorux): Move this to file_util. diff --git a/chrome/browser/chromeos/boot_times_loader.h b/chrome/browser/chromeos/boot_times_loader.h index 2312a57..2abc164 100644 --- a/chrome/browser/chromeos/boot_times_loader.h +++ b/chrome/browser/chromeos/boot_times_loader.h @@ -34,38 +34,8 @@ class BootTimesLoader : public content::NotificationObserver { BootTimesLoader(); virtual ~BootTimesLoader(); - // All fields are 0.0 if they couldn't be found. - typedef struct BootTimes { - double firmware; // Time from power button to kernel being loaded. - double pre_startup; // Time from kernel to system code being called. - double x_started; // Time X server is ready to be connected to. - double chrome_exec; // Time session manager executed Chrome. - double chrome_main; // Time chrome's main() was called. - double login_prompt_ready; // Time login (or OOB) panel is displayed. - double system; // Time system took to start chrome. - double chrome; // Time chrome took to display login panel. - double total; // Time from power button to login panel. - - BootTimes() : firmware(0), - pre_startup(0), - x_started(0), - chrome_exec(0), - chrome_main(0), - login_prompt_ready(0), - system(0), - chrome(0), - total(0) {} - } BootTimes; - static BootTimesLoader* Get(); - typedef base::Callback<void(const BootTimes&)> GetBootTimesCallback; - - // Asynchronously requests the info. - CancelableTaskTracker::TaskId GetBootTimes( - const GetBootTimesCallback& callback, - CancelableTaskTracker* tracker); - // Add a time marker for login. A timeline will be dumped to // /tmp/login-times-sent after login is done. If |send_to_uma| is true // the time between this marker and the last will be sent to UMA with @@ -113,10 +83,6 @@ class BootTimesLoader : public content::NotificationObserver { public: Backend() {} - void GetBootTimesAndRunCallback( - const CancelableTaskTracker::IsCanceledCallback& is_canceled_cb, - const GetBootTimesCallback& callback); - private: friend class base::RefCountedThreadSafe<Backend>; diff --git a/chrome/browser/chromeos/login/version_info_updater.cc b/chrome/browser/chromeos/login/version_info_updater.cc index 5d430c7..84ff2ce 100644 --- a/chrome/browser/chromeos/login/version_info_updater.cc +++ b/chrome/browser/chromeos/login/version_info_updater.cc @@ -66,11 +66,6 @@ void VersionInfoUpdater::StartUpdate(bool is_official_build) { base::Bind(&VersionInfoUpdater::OnVersion, weak_pointer_factory_.GetWeakPtr()), &tracker_); - boot_times_loader_.GetBootTimes( - base::Bind(is_official_build ? &VersionInfoUpdater::OnBootTimesNoop - : &VersionInfoUpdater::OnBootTimes, - weak_pointer_factory_.GetWeakPtr()), - &tracker_); } else { UpdateVersionLabel(); } @@ -131,39 +126,6 @@ void VersionInfoUpdater::OnVersion(const std::string& version) { UpdateVersionLabel(); } -void VersionInfoUpdater::OnBootTimesNoop( - const BootTimesLoader::BootTimes& boot_times) {} - -void VersionInfoUpdater::OnBootTimes( - const BootTimesLoader::BootTimes& boot_times) { - const char* kBootTimesNoChromeExec = - "Non-firmware boot took %.2f seconds (kernel %.2fs, system %.2fs)"; - const char* kBootTimesChromeExec = - "Non-firmware boot took %.2f seconds " - "(kernel %.2fs, system %.2fs, chrome %.2fs)"; - std::string boot_times_text; - - if (boot_times.chrome > 0) { - boot_times_text = - base::StringPrintf( - kBootTimesChromeExec, - boot_times.total, - boot_times.pre_startup, - boot_times.system, - boot_times.chrome); - } else { - boot_times_text = - base::StringPrintf( - kBootTimesNoChromeExec, - boot_times.total, - boot_times.pre_startup, - boot_times.system); - } - // Use UTF8ToWide once this string is localized. - if (delegate_) - delegate_->OnBootTimesLabelTextUpdated(boot_times_text); -} - void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { UpdateEnterpriseInfo(); } diff --git a/chrome/browser/chromeos/login/version_info_updater.h b/chrome/browser/chromeos/login/version_info_updater.h index 29d3ff61..376e85a 100644 --- a/chrome/browser/chromeos/login/version_info_updater.h +++ b/chrome/browser/chromeos/login/version_info_updater.h @@ -30,10 +30,6 @@ class VersionInfoUpdater : public policy::CloudPolicyStore::Observer, virtual void OnOSVersionLabelTextUpdated( const std::string& os_version_label_text) = 0; - // Called when boot times label should be updated. - virtual void OnBootTimesLabelTextUpdated( - const std::string& boot_times_label_text) = 0; - // Called when the enterprise info notice should be updated. virtual void OnEnterpriseInfoUpdated( const std::string& enterprise_info) = 0; @@ -71,10 +67,6 @@ class VersionInfoUpdater : public policy::CloudPolicyStore::Observer, // Callback from chromeos::VersionLoader giving the version. void OnVersion(const std::string& version); - // Callback from chromeos::InfoLoader giving the boot times. - void OnBootTimes(const BootTimesLoader::BootTimes& boot_times); - // Null callback from chromeos::InfoLoader. - void OnBootTimesNoop(const BootTimesLoader::BootTimes& boot_times); // Handles asynchronously loading the version. VersionLoader version_loader_; diff --git a/chrome/browser/resources/chromeos/login/version.html b/chrome/browser/resources/chromeos/login/version.html index 26eed1b4..0f01a5d 100644 --- a/chrome/browser/resources/chromeos/login/version.html +++ b/chrome/browser/resources/chromeos/login/version.html @@ -1,4 +1,3 @@ <div id="version-labels" hidden> <div id="version"></div> - <div id="boot-times"></div> </div> diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index ef91bc0..5e8041a 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc @@ -272,11 +272,6 @@ void CoreOobeHandler::OnOSVersionLabelTextUpdated( UpdateLabel("version", os_version_label_text); } -void CoreOobeHandler::OnBootTimesLabelTextUpdated( - const std::string& boot_times_label_text) { - UpdateLabel("boot-times", boot_times_label_text); -} - void CoreOobeHandler::OnEnterpriseInfoUpdated( const std::string& message_text) { CallJS("setEnterpriseInfo", message_text); diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h index 7b67f47..43a3d2f 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h @@ -44,8 +44,6 @@ class CoreOobeHandler : public BaseScreenHandler, // VersionInfoUpdater::Delegate implementation: virtual void OnOSVersionLabelTextUpdated( const std::string& os_version_label_text) OVERRIDE; - virtual void OnBootTimesLabelTextUpdated( - const std::string& boot_times_label_text) OVERRIDE; virtual void OnEnterpriseInfoUpdated( const std::string& message_text) OVERRIDE; |