From 6c7ddd818521681f21d583dc20ee5c5f9ec8494f Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 16 Jul 2018 15:02:57 -0700 Subject: [PATCH] Remove the dependency on the Garnet zip library (#5770) --- assets/BUILD.gn | 1 - assets/zip_asset_store.cc | 8 ++++++-- assets/zip_asset_store.h | 11 +++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/assets/BUILD.gn b/assets/BUILD.gn index 28d7e5696..580ecfb6e 100644 --- a/assets/BUILD.gn +++ b/assets/BUILD.gn @@ -18,7 +18,6 @@ source_set("assets") { "$flutter_root/fml", "$flutter_root/glue", "//garnet/public/lib/fxl", - "//garnet/public/lib/zip", ] public_deps = [ diff --git a/assets/zip_asset_store.cc b/assets/zip_asset_store.cc index 532461ff3..6f1ecd65a 100644 --- a/assets/zip_asset_store.cc +++ b/assets/zip_asset_store.cc @@ -18,6 +18,10 @@ namespace blink { +void UniqueUnzipperTraits::Free(void* file) { + unzClose(file); +} + ZipAssetStore::ZipAssetStore(std::string file_path) : file_path_(std::move(file_path)) { BuildStatCache(); @@ -25,8 +29,8 @@ ZipAssetStore::ZipAssetStore(std::string file_path) ZipAssetStore::~ZipAssetStore() = default; -zip::UniqueUnzipper ZipAssetStore::CreateUnzipper() const { - return zip::UniqueUnzipper{::unzOpen2(file_path_.c_str(), nullptr)}; +UniqueUnzipper ZipAssetStore::CreateUnzipper() const { + return UniqueUnzipper{::unzOpen2(file_path_.c_str(), nullptr)}; } // |blink::AssetResolver| diff --git a/assets/zip_asset_store.h b/assets/zip_asset_store.h index 61b09474a..0854194ab 100644 --- a/assets/zip_asset_store.h +++ b/assets/zip_asset_store.h @@ -10,11 +10,18 @@ #include "flutter/assets/asset_resolver.h" #include "lib/fxl/macros.h" #include "lib/fxl/memory/ref_counted.h" -#include "lib/zip/unique_unzipper.h" #include "third_party/zlib/contrib/minizip/unzip.h" namespace blink { +struct UniqueUnzipperTraits { + static inline void* InvalidValue() { return nullptr; } + static inline bool IsValid(void* value) { return value != InvalidValue(); } + static void Free(void* file); +}; + +using UniqueUnzipper = fml::UniqueObject; + class ZipAssetStore final : public AssetResolver { public: ZipAssetStore(std::string file_path); @@ -41,7 +48,7 @@ class ZipAssetStore final : public AssetResolver { void BuildStatCache(); - zip::UniqueUnzipper CreateUnzipper() const; + UniqueUnzipper CreateUnzipper() const; FXL_DISALLOW_COPY_AND_ASSIGN(ZipAssetStore); }; -- GitLab