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

Unified Diff: chrome/browser/performance_monitor/performance_monitor.h

Issue 10703078: Add Unclean Exit Watching to CPM (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_crash_event_watching
Patch Set: Created 8 years, 6 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
Index: chrome/browser/performance_monitor/performance_monitor.h
diff --git a/chrome/browser/performance_monitor/performance_monitor.h b/chrome/browser/performance_monitor/performance_monitor.h
index 673cb89bd8948401327c75138ad2f14ed49f8f36..63912d827a89ddd48529d9132988bad8acee826b 100644
--- a/chrome/browser/performance_monitor/performance_monitor.h
+++ b/chrome/browser/performance_monitor/performance_monitor.h
@@ -10,6 +10,7 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
+#include "base/timer.h"
#include "chrome/browser/performance_monitor/database.h"
#include "chrome/browser/performance_monitor/event.h"
#include "content/public/browser/notification_details.h"
@@ -54,6 +55,10 @@ class PerformanceMonitor : public content::NotificationObserver {
private:
friend struct DefaultSingletonTraits<PerformanceMonitor>;
+ FRIEND_TEST_ALL_PREFIXES(PerformanceMonitorUncleanExitBrowserTest,
+ OneProfileUncleanExit);
+ FRIEND_TEST_ALL_PREFIXES(PerformanceMonitorUncleanExitBrowserTest,
+ TwoProfileUncleanExit);
PerformanceMonitor();
virtual ~PerformanceMonitor();
@@ -67,6 +72,15 @@ class PerformanceMonitor : public content::NotificationObserver {
// Register for the apprioriate notifications as a NotificationObserver.
void RegisterForNotifications();
+ // Checks for whether the previous profiles closed uncleanly; this method
+ // should only be called once per run in order to avoid duplication of events
+ // (exceptions made for testing purposes where we construct the environment).
+ void CheckForUncleanExit();
+
+ // Find the last active time for the profile and insert the event into the
+ // database.
+ void AddUncleanExitEvent(std::string profile_name);
+
// Gets the corresponding value of |key| from the database, and then runs
// |callback| with that value as a parameter.
void GetStateValueOnBackgroundThread(
@@ -79,6 +93,15 @@ class PerformanceMonitor : public content::NotificationObserver {
void AddEventOnBackgroundThread(scoped_ptr<Event> event);
+ // Update the database record of the last time the active profiles were
+ // running; this is used in determining when an unclean exit occurred.
+ void UpdateLiveProfiles();
+ void UpdateLiveProfilesHelper(
+ scoped_ptr<std::set<std::string> > active_profiles, std::string time);
+
+ // Perform any collections that are done on a timed basis.
+ void DoTimedCollections();
+
// The location at which the database files are stored; if empty, the database
// will default to '<user_data_dir>/performance_monitor_dbs'.
FilePath database_path_;
@@ -87,6 +110,8 @@ class PerformanceMonitor : public content::NotificationObserver {
content::NotificationRegistrar registrar_;
+ base::RepeatingTimer<PerformanceMonitor> timer_;
+
DISALLOW_COPY_AND_ASSIGN(PerformanceMonitor);
};

Powered by Google App Engine
This is Rietveld 408576698