#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/syslog_logging.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/services/storage/dom_storage/local_storage_impl.h"
#include "components/services/storage/dom_storage/session_storage_impl.h"
#include "components/services/storage/public/mojom/partition.mojom.h"
#include "components/services/storage/public/mojom/storage_policy_update.mojom.h"
#include "components/services/storage/public/mojom/storage_usage_info.mojom.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/session_storage_usage_info.h"
#include "content/public/browser/storage_usage_info.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "storage/browser/quota/special_storage_policy.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
namespace content {
namespace {
void AdaptSessionStorageUsageInfo(
DOMStorageContextWrapper::GetSessionStorageUsageCallback callback,
std::vector<storage::mojom::SessionStorageUsageInfoPtr> usage) { … }
void AdaptStorageUsageInfo(
DOMStorageContext::GetLocalStorageUsageCallback callback,
std::vector<storage::mojom::StorageUsageInfoPtr> usage) { … }
}
scoped_refptr<DOMStorageContextWrapper> DOMStorageContextWrapper::Create(
StoragePartitionImpl* partition,
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy) { … }
DOMStorageContextWrapper::DOMStorageContextWrapper(
StoragePartitionImpl* partition)
: … { … }
DOMStorageContextWrapper::~DOMStorageContextWrapper() { … }
storage::mojom::SessionStorageControl*
DOMStorageContextWrapper::GetSessionStorageControl() { … }
storage::mojom::LocalStorageControl*
DOMStorageContextWrapper::GetLocalStorageControl() { … }
void DOMStorageContextWrapper::GetLocalStorageUsage(
GetLocalStorageUsageCallback callback) { … }
void DOMStorageContextWrapper::GetSessionStorageUsage(
GetSessionStorageUsageCallback callback) { … }
void DOMStorageContextWrapper::DeleteLocalStorage(
const blink::StorageKey& storage_key,
base::OnceClosure callback) { … }
void DOMStorageContextWrapper::PerformLocalStorageCleanup(
base::OnceClosure callback) { … }
void DOMStorageContextWrapper::DeleteSessionStorage(
const SessionStorageUsageInfo& usage_info,
base::OnceClosure callback) { … }
void DOMStorageContextWrapper::PerformSessionStorageCleanup(
base::OnceClosure callback) { … }
scoped_refptr<SessionStorageNamespace>
DOMStorageContextWrapper::RecreateSessionStorage(
const std::string& namespace_id) { … }
void DOMStorageContextWrapper::StartScavengingUnusedSessionStorage() { … }
void DOMStorageContextWrapper::SetForceKeepSessionState() { … }
void DOMStorageContextWrapper::Shutdown() { … }
void DOMStorageContextWrapper::Flush() { … }
void DOMStorageContextWrapper::OpenLocalStorage(
const blink::StorageKey& storage_key,
std::optional<blink::LocalFrameToken> local_frame_token,
mojo::PendingReceiver<blink::mojom::StorageArea> receiver,
ChildProcessSecurityPolicyImpl::Handle security_policy_handle,
mojo::ReportBadMessageCallback bad_message_callback) { … }
void DOMStorageContextWrapper::BindNamespace(
const std::string& namespace_id,
mojo::ReportBadMessageCallback bad_message_callback,
mojo::PendingReceiver<blink::mojom::SessionStorageNamespace> receiver) { … }
void DOMStorageContextWrapper::BindStorageArea(
const blink::StorageKey& storage_key,
std::optional<blink::LocalFrameToken> local_frame_token,
const std::string& namespace_id,
mojo::PendingReceiver<blink::mojom::StorageArea> receiver,
ChildProcessSecurityPolicyImpl::Handle security_policy_handle,
mojo::ReportBadMessageCallback bad_message_callback) { … }
bool DOMStorageContextWrapper::IsRequestValid(
const StorageType type,
const blink::StorageKey& storage_key,
std::optional<blink::LocalFrameToken> local_frame_token,
ChildProcessSecurityPolicyImpl::Handle security_policy_handle,
mojo::ReportBadMessageCallback bad_message_callback) { … }
void DOMStorageContextWrapper::RecoverFromStorageServiceCrash() { … }
void DOMStorageContextWrapper::MaybeBindSessionStorageControl() { … }
void DOMStorageContextWrapper::MaybeBindLocalStorageControl() { … }
scoped_refptr<SessionStorageNamespaceImpl>
DOMStorageContextWrapper::MaybeGetExistingNamespace(
const std::string& namespace_id) const { … }
void DOMStorageContextWrapper::AddNamespace(
const std::string& namespace_id,
SessionStorageNamespaceImpl* session_namespace) { … }
void DOMStorageContextWrapper::RemoveNamespace(
const std::string& namespace_id) { … }
void DOMStorageContextWrapper::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { … }
void DOMStorageContextWrapper::PurgeMemory(PurgeOption purge_option) { … }
void DOMStorageContextWrapper::OnStartupUsageRetrieved(
std::vector<storage::mojom::StorageUsageInfoPtr> usage) { … }
void DOMStorageContextWrapper::ApplyPolicyUpdates(
std::vector<storage::mojom::StoragePolicyUpdatePtr> policy_updates) { … }
}