#include "third_party/blink/renderer/platform/bindings/parkable_string_manager.h"
#include <algorithm>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/disk_data_allocator.h"
#include "third_party/blink/renderer/platform/instrumentation/memory_pressure_listener.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
namespace blink {
struct ParkableStringManager::Statistics { … };
namespace {
bool CompressionEnabled() { … }
class OnPurgeMemoryListener : public GarbageCollected<OnPurgeMemoryListener>,
public MemoryPressureListener { … };
Vector<ParkableStringImpl*> EnumerateStrings(
const ParkableStringManager::StringMap& strings) { … }
void MoveString(ParkableStringImpl* string,
ParkableStringManager::StringMap* from,
ParkableStringManager::StringMap* to) { … }
}
const char* ParkableStringManager::kAllocatorDumpName = …;
const base::TimeDelta ParkableStringManager::kFirstParkingDelay;
ParkableStringManagerDumpProvider*
ParkableStringManagerDumpProvider::Instance() { … }
bool ParkableStringManagerDumpProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
ParkableStringManagerDumpProvider::~ParkableStringManagerDumpProvider() =
default;
ParkableStringManagerDumpProvider::ParkableStringManagerDumpProvider() =
default;
ParkableStringManager& ParkableStringManager::Instance() { … }
ParkableStringManager::~ParkableStringManager() = default;
void ParkableStringManager::SetRendererBackgrounded(bool backgrounded) { … }
void ParkableStringManager::OnRAILModeChanged(RAILMode rail_mode) { … }
bool ParkableStringManager::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd) { … }
bool ParkableStringManager::ShouldPark(const StringImpl& string) { … }
base::TimeDelta ParkableStringManager::AgingInterval() { … }
scoped_refptr<ParkableStringImpl> ParkableStringManager::Add(
scoped_refptr<StringImpl>&& string,
std::unique_ptr<ParkableStringImpl::SecureDigest> digest) { … }
void ParkableStringManager::RemoveOnMainThread(ParkableStringImpl* string) { … }
void ParkableStringManager::Remove(ParkableStringImpl* string) { … }
void ParkableStringManager::CompleteUnparkOnMainThread(
ParkableStringImpl* string,
base::TimeDelta elapsed,
base::TimeDelta disk_elapsed) { … }
void ParkableStringManager::CompleteUnpark(ParkableStringImpl* string,
base::TimeDelta elapsed,
base::TimeDelta disk_elapsed) { … }
void ParkableStringManager::OnParked(ParkableStringImpl* newly_parked_string) { … }
void ParkableStringManager::OnWrittenToDisk(
ParkableStringImpl* newly_written_string) { … }
void ParkableStringManager::OnUnparked(ParkableStringImpl* was_parked_string,
bool was_on_disk) { … }
void ParkableStringManager::ParkAll(ParkableStringImpl::ParkingMode mode) { … }
size_t ParkableStringManager::Size() const { … }
void ParkableStringManager::RecordStatisticsAfter5Minutes() const { … }
void ParkableStringManager::AgeStringsAndPark() { … }
void ParkableStringManager::ScheduleAgingTaskIfNeeded() { … }
void ParkableStringManager::PurgeMemory() { … }
ParkableStringManager::Statistics ParkableStringManager::ComputeStatistics()
const { … }
void ParkableStringManager::AssertRemoved(ParkableStringImpl* string) { … }
void ParkableStringManager::ResetForTesting() { … }
bool ParkableStringManager::IsPaused() const { … }
bool ParkableStringManager::HasPendingWork() const { … }
bool ParkableStringManager::IsOnParkedMapForTesting(
ParkableStringImpl* string) { … }
bool ParkableStringManager::IsOnDiskMapForTesting(ParkableStringImpl* string) { … }
ParkableStringManager::ParkableStringManager()
: … { … }
}