diff --git a/assets/BUILD.gn b/assets/BUILD.gn index 28d7e569659f15026c8c52fa6cd765a44cd506ae..7247a2f3d00fc6e7300a1679329416b04bdf7c19 100644 --- a/assets/BUILD.gn +++ b/assets/BUILD.gn @@ -9,8 +9,6 @@ source_set("assets") { "asset_resolver.h", "directory_asset_bundle.cc", "directory_asset_bundle.h", - "zip_asset_store.cc", - "zip_asset_store.h", ] deps = [ @@ -18,11 +16,6 @@ source_set("assets") { "$flutter_root/fml", "$flutter_root/glue", "//garnet/public/lib/fxl", - "//garnet/public/lib/zip", - ] - - public_deps = [ - "//third_party/zlib:minizip", ] public_configs = [ "$flutter_root:config" ] diff --git a/assets/asset_manager.cc b/assets/asset_manager.cc index fcbe71b11a9ff1a02daff87544b3e80c471cae47..cdbe007a5ad0ff33c61914dbf2e4eb5609b12c90 100644 --- a/assets/asset_manager.cc +++ b/assets/asset_manager.cc @@ -5,7 +5,6 @@ #include "flutter/assets/asset_manager.h" #include "flutter/assets/directory_asset_bundle.h" -#include "flutter/assets/zip_asset_store.h" #include "flutter/glue/trace_event.h" #include "lib/fxl/files/path.h" diff --git a/assets/zip_asset_store.cc b/assets/zip_asset_store.cc deleted file mode 100644 index 1b9216bd34530ec1d6408e6a1ca8aea55f266faa..0000000000000000000000000000000000000000 --- a/assets/zip_asset_store.cc +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2016 The Chromium 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 "flutter/assets/zip_asset_store.h" -#include "lib/fxl/build_config.h" - -#include - -#if !defined(OS_WIN) -#include -#endif - -#include -#include - -#include "flutter/glue/trace_event.h" - -namespace blink { - -ZipAssetStore::ZipAssetStore(std::string file_path) - : file_path_(std::move(file_path)) { - BuildStatCache(); -} - -ZipAssetStore::~ZipAssetStore() = default; - -zip::UniqueUnzipper ZipAssetStore::CreateUnzipper() const { - return zip::UniqueUnzipper{::unzOpen2(file_path_.c_str(), nullptr)}; -} - -// |blink::AssetResolver| -bool ZipAssetStore::IsValid() const { - return stat_cache_.size() > 0; -} - -// |blink::AssetResolver| -bool ZipAssetStore::GetAsBuffer(const std::string& asset_name, - std::vector* data) const { - TRACE_EVENT0("flutter", "ZipAssetStore::GetAsBuffer"); - auto found = stat_cache_.find(asset_name); - - if (found == stat_cache_.end()) { - return false; - } - - auto unzipper = CreateUnzipper(); - - if (!unzipper.is_valid()) { - return false; - } - - int result = UNZ_OK; - - result = unzGoToFilePos(unzipper.get(), &(found->second.file_pos)); - if (result != UNZ_OK) { - FXL_LOG(WARNING) << "unzGetCurrentFileInfo failed, error=" << result; - return false; - } - - result = unzOpenCurrentFile(unzipper.get()); - if (result != UNZ_OK) { - FXL_LOG(WARNING) << "unzOpenCurrentFile failed, error=" << result; - return false; - } - - data->resize(found->second.uncompressed_size); - int total_read = 0; - while (total_read < static_cast(data->size())) { - int bytes_read = unzReadCurrentFile( - unzipper.get(), data->data() + total_read, data->size() - total_read); - if (bytes_read <= 0) { - return false; - } - total_read += bytes_read; - } - - return true; -} - -void ZipAssetStore::BuildStatCache() { - TRACE_EVENT0("flutter", "ZipAssetStore::BuildStatCache"); - - auto unzipper = CreateUnzipper(); - - if (!unzipper.is_valid()) { - return; - } - - if (unzGoToFirstFile(unzipper.get()) != UNZ_OK) { - return; - } - - do { - int result = UNZ_OK; - - // Get the current file name. - unz_file_info file_info = {}; - char file_name[255]; - result = unzGetCurrentFileInfo(unzipper.get(), &file_info, file_name, - sizeof(file_name), nullptr, 0, nullptr, 0); - if (result != UNZ_OK) { - continue; - } - - if (file_info.uncompressed_size == 0) { - continue; - } - - // Get the current file position. - unz_file_pos file_pos = {}; - result = unzGetFilePos(unzipper.get(), &file_pos); - if (result != UNZ_OK) { - continue; - } - - std::string file_name_key(file_name, file_info.size_filename); - CacheEntry entry(file_pos, file_info.uncompressed_size); - stat_cache_.emplace(std::move(file_name_key), std::move(entry)); - - } while (unzGoToNextFile(unzipper.get()) == UNZ_OK); -} - -} // namespace blink diff --git a/assets/zip_asset_store.h b/assets/zip_asset_store.h deleted file mode 100644 index 558678e25bc08f8ac3f7f3780d3730fc2e09b893..0000000000000000000000000000000000000000 --- a/assets/zip_asset_store.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_ASSETS_ZIP_ASSET_STORE_H_ -#define FLUTTER_ASSETS_ZIP_ASSET_STORE_H_ - -#include - -#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 { - -class ZipAssetStore final : public AssetResolver { - public: - ZipAssetStore(std::string file_path); - - ~ZipAssetStore() override; - - private: - struct CacheEntry { - unz_file_pos file_pos; - size_t uncompressed_size; - CacheEntry(unz_file_pos p_file_pos, size_t p_uncompressed_size) - : file_pos(p_file_pos), uncompressed_size(p_uncompressed_size) {} - }; - - std::string file_path_; - mutable std::map stat_cache_; - - // |blink::AssetResolver| - bool IsValid() const override; - - // |blink::AssetResolver| - bool GetAsBuffer(const std::string& asset_name, - std::vector* data) const override; - - void BuildStatCache(); - - zip::UniqueUnzipper CreateUnzipper() const; - - FXL_DISALLOW_COPY_AND_ASSIGN(ZipAssetStore); -}; - -} // namespace blink - -#endif // FLUTTER_ASSETS_ZIP_ASSET_STORE_H_ diff --git a/shell/common/run_configuration.cc b/shell/common/run_configuration.cc index 7fb385fb4d9dc351f4e51fb15fdaaa6294f8365d..8a2080ed79999e15fbb270a5481fb74e0cc8cec6 100644 --- a/shell/common/run_configuration.cc +++ b/shell/common/run_configuration.cc @@ -7,7 +7,6 @@ #include #include "flutter/assets/directory_asset_bundle.h" -#include "flutter/assets/zip_asset_store.h" #include "flutter/fml/file.h" #include "flutter/runtime/dart_vm.h" @@ -24,9 +23,6 @@ RunConfiguration RunConfiguration::InferFromSettings( std::make_unique(fml::OpenFile( settings.assets_path.c_str(), fml::OpenPermission::kRead, true))); - asset_manager->PushBack( - std::make_unique(settings.flx_path)); - return {IsolateConfiguration::InferFromSettings(settings, asset_manager), asset_manager}; } diff --git a/travis/licenses_golden/licenses_flutter b/travis/licenses_golden/licenses_flutter index 53d6bdc4ce7f87b1b0ec2528547a710c5efbd984..f44f0cf2094198b897f3203cfcf6bfce2d3e2634 100644 --- a/travis/licenses_golden/licenses_flutter +++ b/travis/licenses_golden/licenses_flutter @@ -322,8 +322,6 @@ ORIGIN: ../../../flutter/assets/directory_asset_bundle.cc + ../../../LICENSE TYPE: LicenseType.bsd FILE: ../../../flutter/assets/directory_asset_bundle.cc FILE: ../../../flutter/assets/directory_asset_bundle.h -FILE: ../../../flutter/assets/zip_asset_store.cc -FILE: ../../../flutter/assets/zip_asset_store.h FILE: ../../../flutter/common/settings.cc FILE: ../../../flutter/common/settings.h FILE: ../../../flutter/flow/export_node.cc