#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/breadcrumbs/core/breadcrumb_persistent_storage_manager.h"
#include <string.h>
#include <string>
#include "base/containers/adapters.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/functional/bind.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "components/breadcrumbs/core/breadcrumb_manager.h"
#include "components/breadcrumbs/core/breadcrumb_persistent_storage_util.h"
namespace breadcrumbs {
namespace {
const char kEventSeparator[] = …;
constexpr auto kMinDelayBetweenWrites = …;
void DoWriteEventsToFile(const base::FilePath& file_path,
const size_t position,
const std::string& events,
const bool append) { … }
std::string DoGetStoredEvents(const base::FilePath& file_path) { … }
std::string GetEvents() { … }
}
BreadcrumbPersistentStorageManager::BreadcrumbPersistentStorageManager(
const base::FilePath& directory,
base::RepeatingCallback<bool()> is_metrics_enabled_callback,
base::OnceClosure initialization_done_callback)
: … { … }
BreadcrumbPersistentStorageManager::~BreadcrumbPersistentStorageManager() =
default;
void BreadcrumbPersistentStorageManager::Initialize(
base::OnceClosure initialization_done_callback,
const std::string& previous_session_events) { … }
void BreadcrumbPersistentStorageManager::Write(const std::string& events,
bool append) { … }
void BreadcrumbPersistentStorageManager::EventAdded(const std::string& event) { … }
bool BreadcrumbPersistentStorageManager::CheckForFileConsent() { … }
void BreadcrumbPersistentStorageManager::WriteEvents(
base::OnceClosure done_callback) { … }
}