Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: chrome/browser/chromeos/boot_times_loader.h

Issue 303233004: Write "logout-started" event on next boot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add exception for ScopedAllowIO. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/boot_times_loader.h
diff --git a/chrome/browser/chromeos/boot_times_loader.h b/chrome/browser/chromeos/boot_times_loader.h
index 854dccdabee2898f80009517cdd8fca85ef657b2..1df7e1c839b1e6b57311a803f69b4dd7d87c2974 100644
--- a/chrome/browser/chromeos/boot_times_loader.h
+++ b/chrome/browser/chromeos/boot_times_loader.h
@@ -17,6 +17,8 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/render_widget_host.h"
+class PrefService;
+
namespace chromeos {
// BootTimesLoader loads the bootimes of Chrome OS from the file system.
@@ -82,6 +84,12 @@ class BootTimesLoader : public content::NotificationObserver {
// Mark that WriteLogoutTimes should handle restart.
void set_restart_requested() { restart_requested_ = true; }
+ // This is called on Chrome process startup to write saved logout stats.
+ void OnChromeProcessStart();
+
+ // This saves logout-started metric to Local State.
+ void OnLogoutStarted(PrefService* state);
+
private:
// BootTimesLoader calls into the Backend on the file thread to load
// the boot times.
@@ -119,21 +127,46 @@ class BootTimesLoader : public content::NotificationObserver {
bool send_to_uma_;
};
- struct Stats {
+ class Stats {
public:
- std::string uptime;
- std::string disk;
+ // Initializes stats with current /proc values.
+ static Stats GetCurrentStats();
+
+ // Returns JSON representation.
+ std::string SerializeToString() const;
+
+ // Creates new object from JSON representation.
+ static Stats DeserializeFromString(const std::string& value);
+
+ const std::string& uptime() const { return uptime_; }
+ const std::string& disk() const { return disk_; }
+
+ // Writes "uptime in seconds" to result. (This is first field in uptime_.)
+ // Returns true on successful conversion.
+ bool UptimeDouble(double* result) const;
+
+ void RecordStats(const std::string& name) const;
+ void RecordStatsWithCallback(const std::string& name,
+ const base::Closure& callback) const;
+
+ private:
+ // Runs on BlockingPool
+ void RecordStatsImpl(const std::string& name) const;
+
+ std::string uptime_;
+ std::string disk_;
};
- static void RecordStats(
- const std::string& name, const Stats& stats);
- static Stats GetCurrentStats();
static void WriteTimes(const std::string base_name,
const std::string uma_name,
const std::string uma_prefix,
std::vector<TimeMarker> login_times);
static void AddMarker(std::vector<TimeMarker>* vector, TimeMarker marker);
+ // Clear saved logout-started metric in Local State.
+ // This method is called when logout-state was writen to file.
+ static void ClearLogoutStartedLastPreference();
+
// Used to hold the stats at main().
Stats chrome_main_stats_;
scoped_refptr<Backend> backend_;
« no previous file with comments | « PRESUBMIT.py ('k') | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698