1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/metrics/metrics_shutdown.h"
7 #include "base/metrics/persistent_histogram_allocator.h"
8 #include "components/metrics/clean_exit_beacon.h"
9 #include "components/prefs/pref_service.h"
13 void Shutdown(PrefService* local_state) {
14 CleanExitBeacon::EnsureCleanShutdown(local_state);
15 auto* allocator = base::GlobalHistogramAllocator::Get();
17 // Write to the persistent histogram allocator that we've exited cleanly.
18 // This is not perfect as the browser may crash after this call (or the
19 // device may lose power, which may leave the underlying pages in an
20 // inconsistent state), but this is "good" enough for debugging sake.
21 allocator->memory_allocator()->SetMemoryState(
22 base::PersistentMemoryAllocator::MemoryState::MEMORY_COMPLETED);
26 } // namespace metrics