Chromium Code Reviews| 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_ |