#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/json_file_sanitizer.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/json/json_string_value_serializer.h"
#include "base/task/sequenced_task_runner.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
namespace extensions {
namespace {
std::tuple<std::string, bool, bool> ReadAndDeleteTextFile(
const base::FilePath& path) { … }
bool WriteStringToFile(const std::string& contents,
const base::FilePath& file_path) { … }
}
std::unique_ptr<JsonFileSanitizer> JsonFileSanitizer::CreateAndStart(
data_decoder::DataDecoder* decoder,
const std::set<base::FilePath>& file_paths,
Callback callback,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) { … }
JsonFileSanitizer::JsonFileSanitizer(
const std::set<base::FilePath>& file_paths,
Callback callback,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner)
: … { … }
JsonFileSanitizer::~JsonFileSanitizer() = default;
void JsonFileSanitizer::Start(data_decoder::DataDecoder* decoder) { … }
void JsonFileSanitizer::JsonFileRead(
const base::FilePath& file_path,
std::tuple<std::string, bool, bool> read_and_delete_result) { … }
void JsonFileSanitizer::JsonParsingDone(
const base::FilePath& file_path,
std::optional<base::Value> json_value,
const std::optional<std::string>& error) { … }
void JsonFileSanitizer::JsonFileWritten(const base::FilePath& file_path,
bool success) { … }
void JsonFileSanitizer::ReportSuccess() { … }
void JsonFileSanitizer::ReportError(Status status, const std::string& error) { … }
}