chromium/chrome/browser/sessions/session_service_log.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_SESSION_SERVICE_LOG_H_
#define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_LOG_H_

#include <list>

#include "base/time/time.h"

class Profile;

namespace user_prefs {
class PrefRegistrySyncable;
}

// This file contains functionality used to track interesting session restore
// events. This is primarily aimed at helping understand whether session
// restore is failing.
//
// The appropriate code calls to the various log functions. This data is
// tracked in prefs, and only a limited amount of data is kept around.

// WARNING: these values are persisted to disk, do not change.
enum class SessionServiceEventLogType {};

struct StartData {};

struct RestoreData {};

struct ExitData {};

struct WriteErrorData {};

struct RestoreInitiatedData {};

EventData;

struct SessionServiceEvent {};

// Returns the most recent events, ordered with oldest event first. In general
// the times shouldn't be compared, as it's possible for bad clocks and/or
// timezone changes to cause an earlier event to have a later time.
std::list<SessionServiceEvent> GetSessionServiceEvents(Profile* profile);

void LogSessionServiceStartEvent(Profile* profile, bool after_crash);
void LogSessionServiceExitEvent(Profile* profile,
                                int window_count,
                                int tab_count,
                                bool is_first_session_service,
                                bool did_schedule_command);
void LogSessionServiceRestoreInitiatedEvent(Profile* profile,
                                            bool synchronous,
                                            bool restore_browser);
void LogSessionServiceRestoreEvent(Profile* profile,
                                   int window_count,
                                   int tab_count,
                                   bool encountered_error_reading);
void LogSessionServiceRestoreCanceledEvent(Profile* profile);
void LogSessionServiceWriteErrorEvent(Profile* profile,
                                      bool unrecoverable_write_error);
void RemoveLastSessionServiceEventOfType(Profile* profile,
                                         SessionServiceEventLogType type);

void RegisterSessionServiceLogProfilePrefs(
    user_prefs::PrefRegistrySyncable* registry);

// This function is used internally, and is generally only exposed for testing.
void LogSessionServiceEvent(Profile* profile, const SessionServiceEvent& event);

#endif  // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_LOG_H_