chromium/content/browser/indexed_db/indexed_db_bucket_context.h

// Copyright 2019 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_INDEXED_DB_BUCKET_CONTEXT_H_
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BUCKET_CONTEXT_H_

#include <stdint.h>

#include <memory>
#include <queue>
#include <string>

#include "base/containers/flat_map.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/trace_event/memory_dump_provider.h"
#include "components/services/storage/indexed_db/locks/partitioned_lock_manager.h"
#include "components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_factory.h"
#include "components/services/storage/privileged/cpp/bucket_client_info.h"
#include "components/services/storage/privileged/mojom/indexed_db_client_state_checker.mojom.h"
#include "components/services/storage/privileged/mojom/indexed_db_control_test.mojom.h"
#include "components/services/storage/privileged/mojom/indexed_db_internals_types.mojom.h"
#include "components/services/storage/public/cpp/buckets/bucket_info.h"
#include "components/services/storage/public/cpp/quota_error_or.h"
#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "components/services/storage/public/mojom/file_system_access_context.mojom.h"
#include "content/browser/indexed_db/indexed_db_data_loss_info.h"
#include "content/browser/indexed_db/indexed_db_database_error.h"
#include "content/browser/indexed_db/indexed_db_external_object.h"
#include "content/browser/indexed_db/indexed_db_task_helper.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/src/include/leveldb/status.h"

namespace storage {
class QuotaManagerProxy;
}

namespace content {
class IndexedDBBackingStore;
class IndexedDBBucketContextHandle;
class IndexedDBDatabase;
class IndexedDBDataItemReader;
class IndexedDBPreCloseTaskQueue;

// IndexedDBBucketContext manages the per-bucket IndexedDB state, and other
// important context like the backing store and lock manager.
//
// IndexedDBBucketContext will keep its backing store around while any of these
// is true:
// * There are handles referencing the bucket context,
// * There are outstanding blob references to this database's blob files, or
// * The bucket context is in-memory (i.e. an incognito profile).
//
// When these qualities are no longer true, `RunTasks()` will invoke
// `ResetBackingStore()`, which returns `this` to an uninitialized state.
//
// TODO(crbug.com/40279485): it's intended that each bucket gets its own
// IndexedDB task runner. To facilitate IndexedDB code running on multiple task
// runners, `IndexedDBBucketContext` is in the process of becoming the single
// point of communication between classes running on the main task runner, such
// as `IndexedDBContextImpl`, and those that pertain to a specific bucket and
// therefore run on a bucket's IDB task runner, such as `IndexedDBDatabase` or
// `IndexedDBCursor`.
class CONTENT_EXPORT IndexedDBBucketContext
    : public blink::mojom::IDBFactory,
      public base::trace_event::MemoryDumpProvider {};

}  // namespace content

#endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BUCKET_CONTEXT_H_