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

Unified Diff: components/metrics/clean_exit_beacon.h

Issue 558683002: Extract the handling of the clean exit beacon from MetricsService. The extracted implementation sup… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback. Created 6 years, 3 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: components/metrics/clean_exit_beacon.h
diff --git a/components/metrics/clean_exit_beacon.h b/components/metrics/clean_exit_beacon.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e5f6a08a4b72a93bf6895c3015536645cdb4a6a
--- /dev/null
+++ b/components/metrics/clean_exit_beacon.h
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_METRICS_CLEAN_EXIT_BEACON_H_
+#define COMPONENTS_METRICS_CLEAN_EXIT_BEACON_H_
+
+#include "base/macros.h"
+
+#if defined(OS_WIN)
Alexei Svitkine (slow) 2014/09/11 15:23:28 Nit: Remove ifdef. You don't have it in metrics_se
erikwright (departed) 2014/09/11 19:00:29 Done.
+#include "base/strings/string16.h"
+#endif
+
+class PrefService;
+class PrefRegistrySimple;
+
+// Reads and updates a beacon used to detect whether the previous browser
+// process exited cleanly.
+class CleanExitBeacon {
+ public:
+ // Instantiates a CleanExitBeacon whose value is stored in |local_state|.
+ // |local_state| must be fully initialized.
+ // A PrefRegistrySimple corresponding to |local_state| must have previously
+ // been passed to RegisterPrefs.
+ // On Windows, |backup_registry_key| is used to store a backup of the beacon.
+ CleanExitBeacon(
+#if defined(OS_WIN)
+ const base::string16& backup_registry_key,
+#endif
+ PrefService* local_state);
+
+ ~CleanExitBeacon();
+
+ // Registers preferences used by this class in |registry|.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ // Returns the original value of the beacon.
+ bool exited_cleanly() { return initial_value_; }
Alexei Svitkine (slow) 2014/09/11 15:23:28 Nit: const
erikwright (departed) 2014/09/11 19:00:29 Done.
+
+ // Writes the provided beacon value.
+ void WriteBeaconValue(bool exited_cleanly);
+
+ private:
+ PrefService* const local_state_;
+ const bool initial_value_;
+#if defined(OS_WIN)
+ const base::string16 backup_registry_key_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(CleanExitBeacon);
+};
+
+#endif // COMPONENTS_METRICS_CLEAN_EXIT_BEACON_H_

Powered by Google App Engine
This is Rietveld 408576698