blob: 196136a5389d26167d16b1e0777d1b31036c6ce1 [file] [log] [blame]
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_INDEXED_DB_INSTANCE_BACKING_STORE_UTIL_H_
#define CONTENT_BROWSER_INDEXED_DB_INSTANCE_BACKING_STORE_UTIL_H_
#include "base/values.h"
#include "content/browser/indexed_db/instance/backing_store.h"
namespace content::indexed_db {
// Translates a database into a base::Value. It's intended that this fully
// captures the observable state/contents of the database. Some internal state
// might not be observable via this interface, including
//
// * records that exist in the database, but aren't associated with object
// stores described in the metadata, e.g. if a deletion left behind records
// * internal bookkeeping, e.g. tombstones for LevelDB or blob references for
// SQLite
//
// Currently, blob contents are ignored and only blob metadata is factored into
// the output.
//
// NB: the entire DB is loaded into a DictValue which can consume a lot of
// memory! To cut down on total memory requirements, all values and longer keys
// will be hashed. However a database with millions of records could still
// be problematic. If/when it's necessary to run this on production databases,
// further compression will be required.
//
// For now, this function is a utility for testing only. In the future, it's
// likely that this will be used for verifying database migrations in
// production.
base::DictValue DumpDatabase(BackingStore::Database& db);
} // namespace content::indexed_db
#endif // CONTENT_BROWSER_INDEXED_DB_INSTANCE_BACKING_STORE_UTIL_H_