chromium/components/sync_sessions/synced_session_tracker.cc

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

#include "components/sync_sessions/synced_session_tracker.h"

#include <algorithm>
#include <utility>

#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "components/sync/protocol/session_specifics.pb.h"
#include "components/sync/protocol/sync_enums.pb.h"
#include "components/sync_device_info/device_info_proto_enum_util.h"
#include "components/sync_sessions/sync_sessions_client.h"

namespace sync_sessions {

namespace {

// Maximum time we allow a local tab stay unmapped (i.e. closed) but not freed
// due to data not having been committed yet. After that time, the data will
// be dropped.
constexpr base::TimeDelta kMaxUnmappedButUnsyncedLocalTabAge =;
// This is a generous cap to avoid issues with situations like sync being in
// error state (e.g. auth error) during which many tabs could be opened and
// closed, and still the information would not be committed.
constexpr int kMaxUnmappedButUnsyncedLocalTabCount =;

// Helper for iterating through all tabs within a window, and all navigations
// within a tab, to find if there's a valid syncable url.
bool ShouldSyncSessionWindow(SyncSessionsClient* sessions_client,
                             const sessions::SessionWindow& window) {}

// Presentable means |foreign_session| must have syncable content.
bool IsPresentable(SyncSessionsClient* sessions_client,
                   const SyncedSession& foreign_session) {}

// Verify that tab and window IDs appear only once within a session. Intended to
// prevent http://crbug.com/360822 and crbug.com/803205.
bool IsValidSessionHeader(const sync_pb::SessionHeader& header) {}

void PopulateSyncedSessionWindowFromSpecifics(
    const std::string& session_tag,
    const sync_pb::SessionWindow& specifics,
    base::Time mtime,
    SyncedSessionWindow* synced_session_window,
    SyncedSessionTracker* tracker) {}

void PopulateSyncedSessionFromSpecifics(
    const std::string& session_tag,
    const sync_pb::SessionHeader& header_specifics,
    base::Time mtime,
    SyncedSession* synced_session,
    SyncedSessionTracker* tracker) {}

}  // namespace

SyncedSessionTracker::TrackedSession::TrackedSession() = default;

SyncedSessionTracker::TrackedSession::~TrackedSession() = default;

SyncedSessionTracker::SyncedSessionTracker(SyncSessionsClient* sessions_client)
    :{}

SyncedSessionTracker::~SyncedSessionTracker() = default;

void SyncedSessionTracker::InitLocalSession(
    const std::string& local_session_tag,
    const std::string& local_session_name,
    sync_pb::SyncEnums::DeviceType local_device_type,
    syncer::DeviceInfo::FormFactor local_device_form_factor) {}

const std::string& SyncedSessionTracker::GetLocalSessionTag() const {}

std::vector<raw_ptr<const SyncedSession, VectorExperimental>>
SyncedSessionTracker::LookupAllSessions(SessionLookup lookup) const {}

std::vector<raw_ptr<const SyncedSession, VectorExperimental>>
SyncedSessionTracker::LookupAllForeignSessions(SessionLookup lookup) const {}

std::vector<const sessions::SessionWindow*>
SyncedSessionTracker::LookupSessionWindows(
    const std::string& session_tag) const {}

const sessions::SessionTab* SyncedSessionTracker::LookupSessionTab(
    const std::string& tag,
    SessionID tab_id) const {}

std::optional<sync_pb::SyncEnums::BrowserType>
SyncedSessionTracker::LookupWindowType(const std::string& session_tag,
                                       SessionID window_id) const {}

std::set<int> SyncedSessionTracker::LookupTabNodeIds(
    const std::string& session_tag) const {}

const SyncedSession* SyncedSessionTracker::LookupLocalSession() const {}

const SyncedSession* SyncedSessionTracker::LookupSession(
    const std::string& session_tag) const {}

SyncedSession* SyncedSessionTracker::GetSession(
    const std::string& session_tag) {}

void SyncedSessionTracker::DeleteForeignSession(
    const std::string& session_tag) {}

void SyncedSessionTracker::ResetSessionTracking(
    const std::string& session_tag) {}

void SyncedSessionTracker::DeleteForeignTab(const std::string& session_tag,
                                            int tab_node_id) {}

const SyncedSessionTracker::TrackedSession*
SyncedSessionTracker::LookupTrackedSession(
    const std::string& session_tag) const {}

SyncedSessionTracker::TrackedSession*
SyncedSessionTracker::LookupTrackedSession(const std::string& session_tag) {}

SyncedSessionTracker::TrackedSession* SyncedSessionTracker::GetTrackedSession(
    const std::string& session_tag) {}

std::vector<raw_ptr<const SyncedSession, VectorExperimental>>
SyncedSessionTracker::LookupSessions(SessionLookup lookup,
                                     bool exclude_local_session) const {}

void SyncedSessionTracker::CleanupSessionImpl(
    const std::string& session_tag,
    const base::RepeatingCallback<bool(int /*tab_node_id*/)>&
        is_tab_node_unsynced_cb) {}

bool SyncedSessionTracker::IsTabUnmappedForTesting(SessionID tab_id) {}

bool SyncedSessionTracker::PutWindowInSession(const std::string& session_tag,
                                              SessionID window_id) {}

void SyncedSessionTracker::PutTabInWindow(const std::string& session_tag,
                                          SessionID window_id,
                                          SessionID tab_id) {}

void SyncedSessionTracker::OnTabNodeSeen(const std::string& session_tag,
                                         int tab_node_id,
                                         SessionID tab_id) {}

sessions::SessionTab* SyncedSessionTracker::GetTab(
    const std::string& session_tag,
    SessionID tab_id) {}

void SyncedSessionTracker::CleanupSession(const std::string& session_tag) {}

std::set<int> SyncedSessionTracker::CleanupLocalTabs(
    const base::RepeatingCallback<bool(int /*tab_node_id*/)>&
        is_tab_node_unsynced_cb) {}

int SyncedSessionTracker::LookupTabNodeFromTabId(const std::string& session_tag,
                                                 SessionID tab_id) const {}

SessionID SyncedSessionTracker::LookupTabIdFromTabNodeId(
    const std::string& session_tag,
    int tab_node_id) const {}

int SyncedSessionTracker::AssociateLocalTabWithFreeTabNode(SessionID tab_id) {}

void SyncedSessionTracker::ReassociateLocalTab(int tab_node_id,
                                               SessionID new_tab_id) {}

void SyncedSessionTracker::Clear() {}

void UpdateTrackerWithSpecifics(const sync_pb::SessionSpecifics& specifics,
                                base::Time modification_time,
                                SyncedSessionTracker* tracker) {}

void SerializeTrackerToSpecifics(
    const SyncedSessionTracker& tracker,
    const base::RepeatingCallback<void(const std::string& session_name,
                                       sync_pb::SessionSpecifics* specifics)>&
        output_cb) {}

void SerializePartialTrackerToSpecifics(
    const SyncedSessionTracker& tracker,
    const std::map<std::string, std::set<int>>& session_tag_to_node_ids,
    const base::RepeatingCallback<void(const std::string& session_name,
                                       sync_pb::SessionSpecifics* specifics)>&
        output_cb) {}

}  // namespace sync_sessions