#include "content/browser/web_database/web_database_host_impl.h"
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "components/services/storage/public/cpp/buckets/bucket_info.h"
#include "components/services/storage/public/cpp/buckets/constants.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "storage/browser/database/database_tracker.h"
#include "storage/browser/database/database_util.h"
#include "storage/browser/database/vfs_backend.h"
#include "storage/browser/quota/quota_manager.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/common/database/database_identifier.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
#include "third_party/sqlite/sqlite3.h"
#include "url/origin.h"
DatabaseUtil;
QuotaManager;
VfsBackend;
namespace content {
namespace {
const int kNumDeleteRetries = …;
const int kDelayDeleteRetryMs = …;
void ValidateOriginOnUIThread(
int process_id,
const url::Origin& origin,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceClosure success_callback,
mojo::ReportBadMessageCallback error_callback) { … }
}
WebDatabaseHostImpl::WebDatabaseHostImpl(
int process_id,
scoped_refptr<storage::DatabaseTracker> db_tracker)
: … { … }
WebDatabaseHostImpl::~WebDatabaseHostImpl() { … }
void WebDatabaseHostImpl::Create(
int process_id,
scoped_refptr<storage::DatabaseTracker> db_tracker,
mojo::PendingReceiver<blink::mojom::WebDatabaseHost> receiver) { … }
void WebDatabaseHostImpl::OpenFile(const std::u16string& vfs_file_name,
int32_t desired_flags,
OpenFileCallback callback) { … }
void WebDatabaseHostImpl::OpenFileValidated(const std::u16string& vfs_file_name,
int32_t desired_flags,
OpenFileCallback callback) { … }
void WebDatabaseHostImpl::OpenFileWithBucketCreated(
const std::u16string& vfs_file_name,
int32_t desired_flags,
OpenFileCallback callback,
storage::QuotaErrorOr<storage::BucketInfo> bucket) { … }
void WebDatabaseHostImpl::DeleteFile(const std::u16string& vfs_file_name,
bool sync_dir,
DeleteFileCallback callback) { … }
void WebDatabaseHostImpl::GetFileAttributes(
const std::u16string& vfs_file_name,
GetFileAttributesCallback callback) { … }
void WebDatabaseHostImpl::GetFileAttributesValidated(
const std::u16string& vfs_file_name,
GetFileAttributesCallback callback) { … }
void WebDatabaseHostImpl::GetSpaceAvailable(
const url::Origin& origin,
GetSpaceAvailableCallback callback) { … }
void WebDatabaseHostImpl::GetSpaceAvailableValidated(
const url::Origin& origin,
GetSpaceAvailableCallback callback) { … }
void WebDatabaseHostImpl::DatabaseDeleteFile(
const std::u16string& vfs_file_name,
bool sync_dir,
DeleteFileCallback callback,
int reschedule_count) { … }
void WebDatabaseHostImpl::Opened(const url::Origin& origin,
const std::u16string& database_name,
const std::u16string& database_description) { … }
void WebDatabaseHostImpl::OpenedValidated(
const url::Origin& origin,
const std::u16string& database_name,
const std::u16string& database_description) { … }
void WebDatabaseHostImpl::Modified(const url::Origin& origin,
const std::u16string& database_name) { … }
void WebDatabaseHostImpl::ModifiedValidated(
const url::Origin& origin,
const std::u16string& database_name) { … }
void WebDatabaseHostImpl::Closed(const url::Origin& origin,
const std::u16string& database_name) { … }
void WebDatabaseHostImpl::ClosedValidated(const url::Origin& origin,
const std::u16string& database_name) { … }
void WebDatabaseHostImpl::HandleSqliteError(const url::Origin& origin,
const std::u16string& database_name,
int32_t error) { … }
void WebDatabaseHostImpl::OnDatabaseSizeChanged(
const std::string& origin_identifier,
const std::u16string& database_name,
int64_t database_size) { … }
void WebDatabaseHostImpl::OnDatabaseScheduledForDeletion(
const std::string& origin_identifier,
const std::u16string& database_name) { … }
blink::mojom::WebDatabase& WebDatabaseHostImpl::GetWebDatabase() { … }
void WebDatabaseHostImpl::ValidateOrigin(const url::Origin& origin,
base::OnceClosure callback) { … }
void WebDatabaseHostImpl::ValidateOrigin(const std::u16string& vfs_file_name,
base::OnceClosure callback) { … }
}