chromium/chrome/browser/sessions/exit_type_service.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SESSIONS_EXIT_TYPE_SERVICE_H_
#define CHROME_BROWSER_SESSIONS_EXIT_TYPE_SERVICE_H_

#include <memory>
#include <optional>
#include <vector>

#include "base/callback_list.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "components/keyed_service/core/keyed_service.h"

class Profile;

enum class ExitType {};

class CrashedLock;

// ExitTypeService tracks the exit status of the last and current time Chrome
// was run. In the case of a crash, the last exit type may persist across
// multiple restarts. Consider the following sequence:
// 1. Chrome crashes
// 2. User opens chrome and does not close session crashed bubble.
// 3. User restarts chrome.
// At this point, the last exit type is still `kCrashed`. This is done to ensure
// the user has the opportunity to restore after a crash and does not lose data.
// Also note that there are a number of subtle cases that trigger 2. For
// example, chrome is launched in the background, or chrome is launched in
// incognito mode.
//
// The following actions are treated as acknowledging the crash:
// . A new browser is created outside of startup flow. While the crash bubble
//   may still be visible, assume that if the user created the browser the user
//   no longer cares about the previous session data.
// . No more locks are outstanding (corresponds to no crash bubbles).
class ExitTypeService : public KeyedService {};

#endif  // CHROME_BROWSER_SESSIONS_EXIT_TYPE_SERVICE_H_