chromium/third_party/leveldatabase/leveldb_chrome.cc

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

#include "third_party/leveldatabase/leveldb_chrome.h"

#include <memory>
#include <set>
#include <vector>

#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
#include "util/mutexlock.h"

MemoryPressureLevel;
MemoryAllocatorDump;
MemoryDumpArgs;
MemoryDumpProvider;
ProcessMemoryDump;
Cache;
NewLRUCache;

namespace leveldb_chrome {

namespace {

size_t DefaultBlockCacheSize() {}

std::string GetDumpNameForMemEnv(const leveldb::Env* memenv) {}

// Singleton owning resources shared by Chrome's leveldb databases.
class Globals {};

class ChromeMemEnv : public leveldb::EnvWrapper {};

void Globals::DumpAllTrackedEnvs(const MemoryDumpArgs& dump_args,
                                 ProcessMemoryDump* pmd) {}

// Delete all files in a |directory| using using the provided |env|.
// Note, this is not recursive as it is only called to delete files in an
// in-memory Env's filesystem.
leveldb::Status RemoveEnvDirectory(const std::string& directory,
                                   leveldb::Env* env) {}

// This is an empty `Cache`, suitable for use as a block cache for in-memory
// databases. It will not function in contexts where `Cache` is expected to
// behave consistently, i.e. where `Insert()` is expected to return a non-null
// value that can be handled by `Lookup()` or `Value()`. The block cache in
// particular does not have this requirement.
class NoOpBlockCache : public Cache {};

}  // namespace

// Returns a separate (from the default) block cache for use by web APIs.
// This must be used when opening the databases accessible to Web-exposed APIs,
// so rogue pages can't mount a denial of service attack by hammering the block
// cache. Without separate caches, such an attack might slow down Chrome's UI to
// the point where the user can't close the offending page's tabs.
Cache* GetSharedWebBlockCache() {}

Cache* GetSharedBrowserBlockCache() {}

Cache* GetSharedInMemoryBlockCache() {}

bool IsMemEnv(const leveldb::Env* env) {}

std::unique_ptr<leveldb::Env> NewMemEnv(const std::string& name,
                                        leveldb::Env* base_env) {}

bool ParseFileName(const std::string& filename,
                   uint64_t* number,
                   leveldb::FileType* type) {}

bool CorruptClosedDBForTesting(const base::FilePath& db_path) {}

bool PossiblyValidDB(const base::FilePath& db_path, leveldb::Env* env) {}

leveldb::Status DeleteDB(const base::FilePath& db_path,
                         const leveldb::Options& options) {}

MemoryAllocatorDump* GetEnvAllocatorDump(ProcessMemoryDump* pmd,
                                         leveldb::Env* tracked_memenv) {}

void DumpAllTrackedEnvs(ProcessMemoryDump* pmd) {}

}  // namespace leveldb_chrome