#include "components/reporting/storage/storage.h"
#include <cstdint>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/containers/adapters.h"
#include "base/containers/flat_set.h"
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/platform_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/thread_annotations.h"
#include "base/types/expected.h"
#include "components/reporting/compression/compression_module.h"
#include "components/reporting/encryption/encryption_module_interface.h"
#include "components/reporting/encryption/primitives.h"
#include "components/reporting/encryption/verification.h"
#include "components/reporting/proto/synced/record.pb.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/storage/storage_configuration.h"
#include "components/reporting/storage/storage_queue.h"
#include "components/reporting/storage/storage_uploader_interface.h"
#include "components/reporting/util/file.h"
#include "components/reporting/util/reporting_errors.h"
#include "components/reporting/util/status.h"
#include "components/reporting/util/status_macros.h"
#include "components/reporting/util/statusor.h"
#include "components/reporting/util/task_runner_context.h"
#include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h"
namespace reporting {
namespace {
constexpr base::FilePath::CharType kEncryptionKeyFilePrefix[] = …);
constexpr int32_t kEncryptionKeyMaxFileSize = …;
}
class Storage::QueueUploaderInterface : public UploaderInterface { … };
class Storage::KeyDelivery { … };
class Storage::KeyInStorage { … };
void Storage::Create(
const StorageOptions& options,
UploaderInterface::AsyncStartUploaderCb async_start_upload_cb,
scoped_refptr<EncryptionModuleInterface> encryption_module,
scoped_refptr<CompressionModule> compression_module,
base::OnceCallback<void(StatusOr<scoped_refptr<Storage>>)> completion_cb) { … }
Storage::Storage(const StorageOptions& options,
scoped_refptr<EncryptionModuleInterface> encryption_module,
scoped_refptr<CompressionModule> compression_module,
UploaderInterface::AsyncStartUploaderCb async_start_upload_cb)
: … { … }
Storage::~Storage() = default;
void Storage::Write(Priority priority,
Record record,
base::OnceCallback<void(Status)> completion_cb) { … }
void Storage::Confirm(SequenceInformation sequence_information,
bool force,
base::OnceCallback<void(Status)> completion_cb) { … }
void Storage::Flush(Priority priority,
base::OnceCallback<void(Status)> completion_cb) { … }
void Storage::UpdateEncryptionKey(SignedEncryptionInfo signed_encryption_key) { … }
void Storage::AsyncGetQueueAndProceed(
Priority priority,
base::OnceCallback<void(scoped_refptr<StorageQueue>,
base::OnceCallback<void(Status)>)> queue_action,
base::OnceCallback<void(Status)> completion_cb) { … }
StatusOr<scoped_refptr<StorageQueue>> Storage::GetQueue(
Priority priority) const { … }
void Storage::RegisterCompletionCallback(base::OnceClosure callback) { … }
}