From 89589cc3d644b3f96ddc70c92068d6ccb8411ca3 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sat, 11 Dec 2021 13:17:19 -0800 Subject: [PATCH] Separate archive_location into its own TU. --- impeller/archivist/BUILD.gn | 2 + impeller/archivist/archivable.h | 12 ++ impeller/archivist/archive.cc | 17 +- impeller/archivist/archive.h | 193 +---------------- .../archivist/archive_class_registration.cc | 6 +- .../archivist/archive_class_registration.h | 3 +- impeller/archivist/archive_database.cc | 12 +- impeller/archivist/archive_database.h | 5 +- impeller/archivist/archive_location.cc | 11 + impeller/archivist/archive_location.h | 198 ++++++++++++++++++ impeller/archivist/archive_statement.cc | 6 +- impeller/archivist/archive_statement.h | 46 +++- impeller/archivist/archive_transaction.cc | 4 +- impeller/archivist/archive_vector.cc | 2 + impeller/archivist/archivist_fixture.cc | 2 + impeller/archivist/archivist_unittests.cc | 13 +- 16 files changed, 300 insertions(+), 232 deletions(-) create mode 100644 impeller/archivist/archive_location.cc create mode 100644 impeller/archivist/archive_location.h diff --git a/impeller/archivist/BUILD.gn b/impeller/archivist/BUILD.gn index 3a409fb2e3a96..48e7324ec5135 100644 --- a/impeller/archivist/BUILD.gn +++ b/impeller/archivist/BUILD.gn @@ -19,6 +19,8 @@ impeller_component("archivist") { "archive_class_registration.h", "archive_database.cc", "archive_database.h", + "archive_location.cc", + "archive_location.h", "archive_statement.cc", "archive_statement.h", "archive_transaction.cc", diff --git a/impeller/archivist/archivable.h b/impeller/archivist/archivable.h index 88b766fe6466b..04cd7bdc74a8f 100644 --- a/impeller/archivist/archivable.h +++ b/impeller/archivist/archivable.h @@ -5,9 +5,21 @@ #pragma once #include +#include +#include namespace impeller { +struct ArchiveDef { + using Member = uint64_t; + using Members = std::vector; + + const ArchiveDef* isa = nullptr; + const std::string table_name; + const bool auto_key = true; + const Members members; +}; + class ArchiveLocation; //------------------------------------------------------------------------------ diff --git a/impeller/archivist/archive.cc b/impeller/archivist/archive.cc index 25e3d1d25e99b..7e0cd83ef56ae 100644 --- a/impeller/archivist/archive.cc +++ b/impeller/archivist/archive.cc @@ -9,6 +9,7 @@ #include "flutter/fml/logging.h" #include "impeller/archivist/archive_class_registration.h" #include "impeller/archivist/archive_database.h" +#include "impeller/archivist/archive_location.h" #include "impeller/archivist/archive_statement.h" #include "impeller/archivist/archive_vector.h" @@ -22,14 +23,14 @@ Archive::~Archive() { << "There must be no pending transactions"; } -bool Archive::IsReady() const { - return database_->IsReady(); +bool Archive::IsValid() const { + return database_->IsValid(); } bool Archive::ArchiveInstance(const ArchiveDef& definition, const Archivable& archivable, int64_t& lastInsertIDOut) { - if (!IsReady()) { + if (!IsValid()) { return false; } @@ -44,7 +45,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition, auto statement = registration->GetInsertStatement(); - if (!statement.IsReady() || !statement.Reset()) { + if (!statement.IsValid() || !statement.Reset()) { /* * Must be able to reset the statement for a new write */ @@ -73,7 +74,7 @@ bool Archive::ArchiveInstance(const ArchiveDef& definition, return false; } - if (statement.Run() != ArchiveStatement::Result::kDone) { + if (statement.Execute() != ArchiveStatement::Result::kDone) { return false; } @@ -108,7 +109,7 @@ bool Archive::UnarchiveInstance(const ArchiveDef& definition, size_t Archive::UnarchiveInstances(const ArchiveDef& definition, Archive::UnarchiveStep stepper, Archivable::ArchiveName name) { - if (!IsReady()) { + if (!IsValid()) { return 0; } @@ -123,7 +124,7 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition, auto statement = registration->GetQueryStatement(isQueryingSingle); - if (!statement.IsReady() || !statement.Reset()) { + if (!statement.IsValid() || !statement.Reset()) { return 0; } @@ -150,7 +151,7 @@ size_t Archive::UnarchiveInstances(const ArchiveDef& definition, size_t itemsRead = 0; - while (statement.Run() == ArchiveStatement::Result::kRow) { + while (statement.Execute() == ArchiveStatement::Result::kRow) { itemsRead++; /* diff --git a/impeller/archivist/archive.h b/impeller/archivist/archive.h index 930813e03c01c..5fc7aa0add96d 100644 --- a/impeller/archivist/archive.h +++ b/impeller/archivist/archive.h @@ -11,24 +11,11 @@ #include "flutter/fml/macros.h" #include "impeller/archivist/archivable.h" -#include "impeller/base/allocation.h" namespace impeller { class ArchiveLocation; -class ArchiveClassRegistration; class ArchiveDatabase; -class ArchiveStatement; - -struct ArchiveDef { - using Member = uint64_t; - using Members = std::vector; - - const ArchiveDef* isa = nullptr; - const std::string table_name; - const bool auto_key = true; - const Members members; -}; static const Archivable::ArchiveName ArchiveNameAuto = 0; @@ -38,7 +25,7 @@ class Archive { ~Archive(); - bool IsReady() const; + bool IsValid() const; template ::value>> @@ -83,182 +70,4 @@ class Archive { FML_DISALLOW_COPY_AND_ASSIGN(Archive); }; -class ArchiveLocation { - public: - template ::value>> - bool Write(ArchiveDef::Member member, T item) { - return WriteIntegral(member, static_cast(item)); - } - - bool Write(ArchiveDef::Member member, double item); - - bool Write(ArchiveDef::Member member, const std::string& item); - - bool Write(ArchiveDef::Member member, const Allocation& allocation); - - template ::value>> - bool WriteArchivable(ArchiveDef::Member member, const T& other) { - const ArchiveDef& otherDef = T::ArchiveDefinition; - return Write(member, otherDef, other); - } - - template ::value>> - bool WriteEnum(ArchiveDef::Member member, const T& item) { - return WriteIntegral(member, static_cast(item)); - } - - template ::value>> - bool Write(ArchiveDef::Member member, const std::vector& items) { - /* - * All items in the vector are individually encoded and their keys noted - */ - std::vector members; - members.reserve(items.size()); - - const ArchiveDef& itemDefinition = T::ArchiveDefinition; - for (const auto& item : items) { - int64_t added = 0; - bool result = context_.ArchiveInstance(itemDefinition, item, added); - if (!result) { - return false; - } - members.emplace_back(added); - } - - /* - * The keys are flattened into the vectors table. Write to that table - */ - auto vectorInsert = WriteVectorKeys(std::move(members)); - - if (!vectorInsert.first) { - return false; - } - - return WriteIntegral(member, vectorInsert.second); - } - - template ::value && - std::is_base_of::value>> - bool WriteSuper(const Current& thiz) { - std::string oldClass = current_class_; - current_class_ = Super::ArchiveDefinition.className; - auto success = thiz.Super::serialize(*this); - current_class_ = oldClass; - return success; - } - - template ::value>> - bool Read(ArchiveDef::Member member, T& item) { - int64_t decoded = 0; - auto result = ReadIntegral(member, decoded); - item = static_cast(decoded); - return result; - } - - bool Read(ArchiveDef::Member member, double& item); - - bool Read(ArchiveDef::Member member, std::string& item); - - bool Read(ArchiveDef::Member member, Allocation& allocation); - - template ::value>> - bool ReadArchivable(ArchiveDef::Member member, T& other) { - const ArchiveDef& otherDef = T::ArchiveDefinition; - return decode(member, otherDef, other); - } - - template ::value>> - bool ReadEnum(ArchiveDef::Member member, T& item) { - int64_t desugared = 0; - if (ReadIntegral(member, desugared)) { - item = static_cast(desugared); - return true; - } - return false; - } - - template ::value>> - bool Read(ArchiveDef::Member member, std::vector& items) { - /* - * From the member, find the foreign key of the vector - */ - int64_t vectorForeignKey = 0; - if (!ReadIntegral(member, vectorForeignKey)) { - return false; - } - - /* - * Get vector keys - */ - std::vector keys; - if (!ReadVectorKeys(vectorForeignKey, keys)) { - return false; - } - - const ArchiveDef& otherDef = T::ArchiveDefinition; - for (const auto& key : keys) { - items.emplace_back(); - - if (!context_.UnarchiveInstance(otherDef, key, items.back())) { - return false; - } - } - - return true; - } - - template ::value && - std::is_base_of::value>> - bool ReadSuper(Current& thiz) { - std::string oldClass = current_class_; - current_class_ = Super::ArchiveDefinition.className; - auto success = thiz.Super::deserialize(*this); - current_class_ = oldClass; - return success; - } - - Archivable::ArchiveName Name() const; - - private: - Archive& context_; - ArchiveStatement& statement_; - const ArchiveClassRegistration& registration_; - Archivable::ArchiveName name_; - std::string current_class_; - - friend class Archive; - - ArchiveLocation(Archive& context, - ArchiveStatement& statement, - const ArchiveClassRegistration& registration, - Archivable::ArchiveName name); - - bool WriteIntegral(ArchiveDef::Member member, int64_t item); - - bool ReadIntegral(ArchiveDef::Member member, int64_t& item); - - std::pair WriteVectorKeys(std::vector&& members); - - bool ReadVectorKeys(Archivable::ArchiveName name, - std::vector& members); - - bool Write(ArchiveDef::Member member, - const ArchiveDef& otherDef, - const Archivable& other); - - bool Read(ArchiveDef::Member member, - const ArchiveDef& otherDef, - Archivable& other); - - FML_DISALLOW_COPY_AND_ASSIGN(ArchiveLocation); -}; - } // namespace impeller diff --git a/impeller/archivist/archive_class_registration.cc b/impeller/archivist/archive_class_registration.cc index 36f16bfa251f9..288e301db521f 100644 --- a/impeller/archivist/archive_class_registration.cc +++ b/impeller/archivist/archive_class_registration.cc @@ -45,7 +45,7 @@ size_t ArchiveClassRegistration::GetMemberCount() const { return member_count_; } -bool ArchiveClassRegistration::IsReady() const { +bool ArchiveClassRegistration::IsValid() const { return is_ready_; } @@ -98,7 +98,7 @@ bool ArchiveClassRegistration::CreateTable(bool autoIncrement) { auto statement = database_.CreateStatement(stream.str()); - if (!statement.IsReady()) { + if (!statement.IsValid()) { return false; } @@ -106,7 +106,7 @@ bool ArchiveClassRegistration::CreateTable(bool autoIncrement) { return false; } - return statement.Run() == ArchiveStatement::Result::kDone; + return statement.Execute() == ArchiveStatement::Result::kDone; } ArchiveStatement ArchiveClassRegistration::GetQueryStatement( diff --git a/impeller/archivist/archive_class_registration.h b/impeller/archivist/archive_class_registration.h index 94bfddf8bd7fd..f9f34b8d29932 100644 --- a/impeller/archivist/archive_class_registration.h +++ b/impeller/archivist/archive_class_registration.h @@ -6,6 +6,7 @@ #include "flutter/fml/macros.h" #include "impeller/archivist/archive.h" +#include "impeller/archivist/archive_statement.h" namespace impeller { @@ -19,7 +20,7 @@ class ArchiveClassRegistration { size_t GetMemberCount() const; - bool IsReady() const; + bool IsValid() const; ArchiveStatement GetInsertStatement() const; diff --git a/impeller/archivist/archive_database.cc b/impeller/archivist/archive_database.cc index df174a508128d..d58a7acbc7c41 100644 --- a/impeller/archivist/archive_database.cc +++ b/impeller/archivist/archive_database.cc @@ -35,21 +35,21 @@ ArchiveDatabase::ArchiveDatabase(const std::string& filename) { begin_transaction_stmt_ = std::unique_ptr( new ArchiveStatement(database_, "BEGIN TRANSACTION;")); - if (!begin_transaction_stmt_->IsReady()) { + if (!begin_transaction_stmt_->IsValid()) { return; } end_transaction_stmt_ = std::unique_ptr( new ArchiveStatement(database_, "END TRANSACTION;")); - if (!end_transaction_stmt_->IsReady()) { + if (!end_transaction_stmt_->IsValid()) { return; } rollback_transaction_stmt_ = std::unique_ptr( new ArchiveStatement(database_, "ROLLBACK TRANSACTION;")); - if (!rollback_transaction_stmt_->IsReady()) { + if (!rollback_transaction_stmt_->IsValid()) { return; } @@ -60,7 +60,7 @@ ArchiveDatabase::~ArchiveDatabase() { ::sqlite3_close(DB_HANDLE); } -bool ArchiveDatabase::IsReady() const { +bool ArchiveDatabase::IsValid() const { return ready_; } @@ -73,7 +73,7 @@ static inline const ArchiveClassRegistration* RegistrationIfReady( if (registration == nullptr) { return nullptr; } - return registration->IsReady() ? registration : nullptr; + return registration->IsValid() ? registration : nullptr; } const ArchiveClassRegistration* ArchiveDatabase::GetRegistrationForDefinition( @@ -95,7 +95,7 @@ const ArchiveClassRegistration* ArchiveDatabase::GetRegistrationForDefinition( registrations_.emplace(definition.table_name, std::move(registration)); /* - * If the new class registation is ready, return it to the caller. + * If the new class registration is ready, return it to the caller. */ return res.second ? RegistrationIfReady((*(res.first)).second.get()) : nullptr; diff --git a/impeller/archivist/archive_database.h b/impeller/archivist/archive_database.h index 3f66d8414ee32..ed1b4480170f1 100644 --- a/impeller/archivist/archive_database.h +++ b/impeller/archivist/archive_database.h @@ -16,13 +16,16 @@ class ArchiveStatement; class ArchiveClassRegistration; struct ArchiveDef; +//------------------------------------------------------------------------------ +/// @brief A handle to the underlying database connection for an archive. +/// class ArchiveDatabase { public: ArchiveDatabase(const std::string& filename); ~ArchiveDatabase(); - bool IsReady() const; + bool IsValid() const; int64_t GetLastInsertRowID(); diff --git a/impeller/archivist/archive_location.cc b/impeller/archivist/archive_location.cc new file mode 100644 index 0000000000000..308444047ec54 --- /dev/null +++ b/impeller/archivist/archive_location.cc @@ -0,0 +1,11 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "impeller/archivist/archive_location.h" + +namespace impeller { + +// + +} // namespace impeller diff --git a/impeller/archivist/archive_location.h b/impeller/archivist/archive_location.h new file mode 100644 index 0000000000000..adf6fcd80f3ae --- /dev/null +++ b/impeller/archivist/archive_location.h @@ -0,0 +1,198 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once + +#include + +#include "flutter/fml/macros.h" +#include "impeller/archivist/archivable.h" +#include "impeller/archivist/archive.h" +#include "impeller/base/allocation.h" + +namespace impeller { + +class Archive; +class ArchiveClassRegistration; +class ArchiveStatement; + +class ArchiveLocation { + public: + template ::value>> + bool Write(ArchiveDef::Member member, T item) { + return WriteIntegral(member, static_cast(item)); + } + + bool Write(ArchiveDef::Member member, double item); + + bool Write(ArchiveDef::Member member, const std::string& item); + + bool Write(ArchiveDef::Member member, const Allocation& allocation); + + template ::value>> + bool WriteArchivable(ArchiveDef::Member member, const T& other) { + const ArchiveDef& otherDef = T::ArchiveDefinition; + return Write(member, otherDef, other); + } + + template ::value>> + bool WriteEnum(ArchiveDef::Member member, const T& item) { + return WriteIntegral(member, static_cast(item)); + } + + template ::value>> + bool Write(ArchiveDef::Member member, const std::vector& items) { + /* + * All items in the vector are individually encoded and their keys noted + */ + std::vector members; + members.reserve(items.size()); + + const ArchiveDef& itemDefinition = T::ArchiveDefinition; + for (const auto& item : items) { + int64_t added = 0; + bool result = context_.ArchiveInstance(itemDefinition, item, added); + if (!result) { + return false; + } + members.emplace_back(added); + } + + /* + * The keys are flattened into the vectors table. Write to that table + */ + auto vectorInsert = WriteVectorKeys(std::move(members)); + + if (!vectorInsert.first) { + return false; + } + + return WriteIntegral(member, vectorInsert.second); + } + + template ::value && + std::is_base_of::value>> + bool WriteSuper(const Current& thiz) { + std::string oldClass = current_class_; + current_class_ = Super::ArchiveDefinition.className; + auto success = thiz.Super::serialize(*this); + current_class_ = oldClass; + return success; + } + + template ::value>> + bool Read(ArchiveDef::Member member, T& item) { + int64_t decoded = 0; + auto result = ReadIntegral(member, decoded); + item = static_cast(decoded); + return result; + } + + bool Read(ArchiveDef::Member member, double& item); + + bool Read(ArchiveDef::Member member, std::string& item); + + bool Read(ArchiveDef::Member member, Allocation& allocation); + + template ::value>> + bool ReadArchivable(ArchiveDef::Member member, T& other) { + const ArchiveDef& otherDef = T::ArchiveDefinition; + return decode(member, otherDef, other); + } + + template ::value>> + bool ReadEnum(ArchiveDef::Member member, T& item) { + int64_t desugared = 0; + if (ReadIntegral(member, desugared)) { + item = static_cast(desugared); + return true; + } + return false; + } + + template ::value>> + bool Read(ArchiveDef::Member member, std::vector& items) { + /* + * From the member, find the foreign key of the vector + */ + int64_t vectorForeignKey = 0; + if (!ReadIntegral(member, vectorForeignKey)) { + return false; + } + + /* + * Get vector keys + */ + std::vector keys; + if (!ReadVectorKeys(vectorForeignKey, keys)) { + return false; + } + + const ArchiveDef& otherDef = T::ArchiveDefinition; + for (const auto& key : keys) { + items.emplace_back(); + + if (!context_.UnarchiveInstance(otherDef, key, items.back())) { + return false; + } + } + + return true; + } + + template ::value && + std::is_base_of::value>> + bool ReadSuper(Current& thiz) { + std::string oldClass = current_class_; + current_class_ = Super::ArchiveDefinition.className; + auto success = thiz.Super::deserialize(*this); + current_class_ = oldClass; + return success; + } + + Archivable::ArchiveName Name() const; + + private: + Archive& context_; + ArchiveStatement& statement_; + const ArchiveClassRegistration& registration_; + Archivable::ArchiveName name_; + std::string current_class_; + + friend class Archive; + + ArchiveLocation(Archive& context, + ArchiveStatement& statement, + const ArchiveClassRegistration& registration, + Archivable::ArchiveName name); + + bool WriteIntegral(ArchiveDef::Member member, int64_t item); + + bool ReadIntegral(ArchiveDef::Member member, int64_t& item); + + std::pair WriteVectorKeys(std::vector&& members); + + bool ReadVectorKeys(Archivable::ArchiveName name, + std::vector& members); + + bool Write(ArchiveDef::Member member, + const ArchiveDef& otherDef, + const Archivable& other); + + bool Read(ArchiveDef::Member member, + const ArchiveDef& otherDef, + Archivable& other); + + FML_DISALLOW_COPY_AND_ASSIGN(ArchiveLocation); +}; + +} // namespace impeller diff --git a/impeller/archivist/archive_statement.cc b/impeller/archivist/archive_statement.cc index de4bec087aa5e..976ab47a8e894 100644 --- a/impeller/archivist/archive_statement.cc +++ b/impeller/archivist/archive_statement.cc @@ -37,7 +37,7 @@ ArchiveStatement::~ArchiveStatement() { } } -bool ArchiveStatement::IsReady() const { +bool ArchiveStatement::IsValid() const { return ready_; } @@ -62,7 +62,7 @@ static constexpr int ToParam(size_t index) { static constexpr int ToColumn(size_t index) { /* - * sqlite columns begin from 1 + * sqlite columns begin from 0 */ return static_cast(index); } @@ -165,7 +165,7 @@ bool ArchiveStatement::ReadValue(size_t index, Allocation& item) { return true; } -ArchiveStatement::Result ArchiveStatement::Run() { +ArchiveStatement::Result ArchiveStatement::Execute() { switch (::sqlite3_step(STATEMENT_HANDLE)) { case SQLITE_DONE: return Result::kDone; diff --git a/impeller/archivist/archive_statement.h b/impeller/archivist/archive_statement.h index d60be1b4be677..35abbb1d73a3c 100644 --- a/impeller/archivist/archive_statement.h +++ b/impeller/archivist/archive_statement.h @@ -11,14 +11,48 @@ namespace impeller { +//------------------------------------------------------------------------------ +/// @brief Represents a read/write query to an archive database. Statements +/// are expensive to create and must be cached for as long as +/// possible. +/// class ArchiveStatement { public: ~ArchiveStatement(); ArchiveStatement(ArchiveStatement&& message); - bool IsReady() const; + bool IsValid() const; + enum class Result { + //-------------------------------------------------------------------------- + /// The statement is done executing. + /// + kDone, + //-------------------------------------------------------------------------- + /// The statement found a row of information ready for reading. + /// + kRow, + //-------------------------------------------------------------------------- + /// Statement execution was a failure. + /// + kFailure, + }; + + //---------------------------------------------------------------------------- + /// @brief Execute the given statement with the provided data. + /// + /// @return Is the execution was succeessful. + /// + [[nodiscard]] Result Execute(); + + //---------------------------------------------------------------------------- + /// @brief All writes after the last successfull `Run` call are reset. + /// Since statements are expensive to create, reset them for new + /// writes instead of creating new statements. + /// + /// @return If the statement writes were reset. + /// bool Reset(); bool WriteValue(size_t index, const std::string& item); @@ -45,21 +79,13 @@ class ArchiveStatement { size_t GetColumnCount(); - enum class Result { - kDone, - kRow, - kFailure, - }; - - [[nodiscard]] Result Run(); - private: void* statement_handle_ = nullptr; bool ready_ = false; friend class ArchiveDatabase; - ArchiveStatement(void* db, const std::string& statememt); + ArchiveStatement(void* db, const std::string& statement); bool BindIntegral(size_t index, int64_t item); diff --git a/impeller/archivist/archive_transaction.cc b/impeller/archivist/archive_transaction.cc index 18d00bff96c1a..bc546ff88f266 100644 --- a/impeller/archivist/archive_transaction.cc +++ b/impeller/archivist/archive_transaction.cc @@ -17,7 +17,7 @@ ArchiveTransaction::ArchiveTransaction(int64_t& transactionCount, rollback_stmt_(rollbackStatement), transaction_count_(transactionCount) { if (transaction_count_ == 0) { - cleanup_ = beginStatement.Run() == ArchiveStatement::Result::kDone; + cleanup_ = beginStatement.Execute() == ArchiveStatement::Result::kDone; } transaction_count_++; } @@ -38,7 +38,7 @@ ArchiveTransaction::~ArchiveTransaction() { FML_CHECK(transaction_count_ != 0); if (transaction_count_ == 1 && cleanup_) { - auto res = successful_ ? end_stmt_.Run() : rollback_stmt_.Run(); + auto res = successful_ ? end_stmt_.Execute() : rollback_stmt_.Execute(); FML_CHECK(res == ArchiveStatement::Result::kDone) << "Must be able to commit the nested transaction"; } diff --git a/impeller/archivist/archive_vector.cc b/impeller/archivist/archive_vector.cc index 2589cc3dd73fc..bf561d77004f2 100644 --- a/impeller/archivist/archive_vector.cc +++ b/impeller/archivist/archive_vector.cc @@ -6,6 +6,8 @@ #include +#include "impeller/archivist/archive_location.h" + namespace impeller { ArchiveVector::ArchiveVector(std::vector&& keys) diff --git a/impeller/archivist/archivist_fixture.cc b/impeller/archivist/archivist_fixture.cc index 302bb7470a466..7a80634114315 100644 --- a/impeller/archivist/archivist_fixture.cc +++ b/impeller/archivist/archivist_fixture.cc @@ -27,6 +27,8 @@ void ArchivistFixture::SetUp() { } void ArchivistFixture::TearDown() { + // TODO: Tear this down. For now, I am inspecting the files for readability of + // schema. // DeleteArchiveFile(); } diff --git a/impeller/archivist/archivist_unittests.cc b/impeller/archivist/archivist_unittests.cc index eb247a98a64e8..19fbdcf72cfad 100644 --- a/impeller/archivist/archivist_unittests.cc +++ b/impeller/archivist/archivist_unittests.cc @@ -8,6 +8,7 @@ #include "flutter/fml/macros.h" #include "flutter/testing/testing.h" #include "impeller/archivist/archive.h" +#include "impeller/archivist/archive_location.h" #include "impeller/archivist/archivist_fixture.h" namespace impeller { @@ -55,24 +56,24 @@ using ArchiveTest = ArchivistFixture; TEST_F(ArchiveTest, SimpleInitialization) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); } TEST_F(ArchiveTest, AddStorageClass) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); } TEST_F(ArchiveTest, AddData) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); Sample sample; ASSERT_TRUE(archive.Write(sample)); } TEST_F(ArchiveTest, AddDataMultiple) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); for (size_t i = 0; i < 100; i++) { Sample sample(i + 1); @@ -82,7 +83,7 @@ TEST_F(ArchiveTest, AddDataMultiple) { TEST_F(ArchiveTest, ReadData) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); size_t count = 50; @@ -105,7 +106,7 @@ TEST_F(ArchiveTest, ReadData) { TEST_F(ArchiveTest, ReadDataWithNames) { Archive archive(GetArchiveFileName().c_str()); - ASSERT_TRUE(archive.IsReady()); + ASSERT_TRUE(archive.IsValid()); size_t count = 8;