From 4c9f40a320ba8011a81737e5e945378ac71b9d40 Mon Sep 17 00:00:00 2001 From: Joshua Seaton Date: Fri, 20 Jul 2018 10:53:27 -0700 Subject: [PATCH] [fml] Remove unused ResourceMapping code. (#5811) ResourceMapping-related code is no longer used.Moreover, there is an ASan related-error in ResourceMappingDarwin: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8940466063445826656/+/steps/test_results/0/steps/s___out_release-x64_host_tests_dart_schema_tests/0/logs/stdio/0 --- fml/BUILD.gn | 2 -- fml/icu_util.cc | 9 ------ fml/mapping.h | 4 --- fml/platform/darwin/resource_mapping_darwin.h | 31 ------------------- .../darwin/resource_mapping_darwin.mm | 25 --------------- fml/platform/posix/mapping_posix.cc | 19 ------------ fml/platform/win/mapping_win.cc | 10 ------ travis/licenses_golden/licenses_flutter | 2 -- 8 files changed, 102 deletions(-) delete mode 100644 fml/platform/darwin/resource_mapping_darwin.h delete mode 100644 fml/platform/darwin/resource_mapping_darwin.mm diff --git a/fml/BUILD.gn b/fml/BUILD.gn index 0e561b87c..0551319ea 100644 --- a/fml/BUILD.gn +++ b/fml/BUILD.gn @@ -77,8 +77,6 @@ source_set("fml") { "platform/darwin/paths_darwin.mm", "platform/darwin/platform_version.h", "platform/darwin/platform_version.mm", - "platform/darwin/resource_mapping_darwin.h", - "platform/darwin/resource_mapping_darwin.mm", "platform/darwin/scoped_block.h", "platform/darwin/scoped_block.mm", "platform/darwin/scoped_nsobject.h", diff --git a/fml/icu_util.cc b/fml/icu_util.cc index 98da2880a..03082886e 100644 --- a/fml/icu_util.cc +++ b/fml/icu_util.cc @@ -38,15 +38,6 @@ class ICUContext { return true; } - // Check to see if the mapping is in the resources bundle. - if (PlatformHasResourcesBundle()) { - auto resource = GetResourceMapping(icu_data_path); - if (resource != nullptr && resource->GetSize() != 0) { - mapping_ = std::move(resource); - return true; - } - } - // Check if the mapping can by directly accessed via a file path. In this // case, the data file needs to be next to the executable. auto directory = fml::paths::GetExecutableDirectoryPath(); diff --git a/fml/mapping.h b/fml/mapping.h index 465a66239..e3d840dc8 100644 --- a/fml/mapping.h +++ b/fml/mapping.h @@ -29,10 +29,6 @@ class Mapping { FML_DISALLOW_COPY_AND_ASSIGN(Mapping); }; -bool PlatformHasResourcesBundle(); - -std::unique_ptr GetResourceMapping(const std::string& resource_name); - class FileMapping : public Mapping { public: FileMapping(const std::string& path, bool executable = false); diff --git a/fml/platform/darwin/resource_mapping_darwin.h b/fml/platform/darwin/resource_mapping_darwin.h deleted file mode 100644 index 4cbc158b9..000000000 --- a/fml/platform/darwin/resource_mapping_darwin.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 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_FML_PLATFORM_DARWIN_RESOURCE_MAPPING_DARWIN_H_ -#define FLUTTER_FML_PLATFORM_DARWIN_RESOURCE_MAPPING_DARWIN_H_ - -#include "flutter/fml/macros.h" -#include "flutter/fml/mapping.h" - -namespace fml { - -class ResourceMappingDarwin : public Mapping { - public: - ResourceMappingDarwin(const std::string& resource); - - ~ResourceMappingDarwin() override; - - size_t GetSize() const override; - - const uint8_t* GetMapping() const override; - - private: - FileMapping actual_; - - FML_DISALLOW_COPY_AND_ASSIGN(ResourceMappingDarwin); -}; - -} // namespace fml - -#endif // FLUTTER_FML_PLATFORM_DARWIN_RESOURCE_MAPPING_DARWIN_H_ diff --git a/fml/platform/darwin/resource_mapping_darwin.mm b/fml/platform/darwin/resource_mapping_darwin.mm deleted file mode 100644 index 3ee100121..000000000 --- a/fml/platform/darwin/resource_mapping_darwin.mm +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 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/fml/platform/darwin/resource_mapping_darwin.h" - -#include - -namespace fml { - -ResourceMappingDarwin::ResourceMappingDarwin(const std::string& resource) - : actual_([[[NSBundle mainBundle] pathForResource:@(resource.c_str()) ofType:nil] UTF8String], - false) {} - -ResourceMappingDarwin::~ResourceMappingDarwin() = default; - -size_t ResourceMappingDarwin::GetSize() const { - return actual_.GetSize(); -} - -const uint8_t* ResourceMappingDarwin::GetMapping() const { - return actual_.GetMapping(); -} - -} // namespace fml diff --git a/fml/platform/posix/mapping_posix.cc b/fml/platform/posix/mapping_posix.cc index b9f8fe5de..e1dbdedbb 100644 --- a/fml/platform/posix/mapping_posix.cc +++ b/fml/platform/posix/mapping_posix.cc @@ -15,31 +15,12 @@ #include "flutter/fml/eintr_wrapper.h" #include "flutter/fml/unique_fd.h" -#if OS_MACOSX - -#include "flutter/fml/platform/darwin/resource_mapping_darwin.h" -using PlatformResourceMapping = fml::ResourceMappingDarwin; - -#else - -using PlatformResourceMapping = fml::FileMapping; - -#endif - namespace fml { Mapping::Mapping() = default; Mapping::~Mapping() = default; -bool PlatformHasResourcesBundle() { - return !std::is_same::value; -} - -std::unique_ptr GetResourceMapping(const std::string& resource_name) { - return std::make_unique(resource_name); -} - FileMapping::FileMapping(const std::string& path, bool executable) : FileMapping( fml::UniqueFD{FML_HANDLE_EINTR(::open(path.c_str(), O_RDONLY))}, diff --git a/fml/platform/win/mapping_win.cc b/fml/platform/win/mapping_win.cc index 9dd5dcf6f..096173587 100644 --- a/fml/platform/win/mapping_win.cc +++ b/fml/platform/win/mapping_win.cc @@ -13,22 +13,12 @@ #include "flutter/fml/file.h" #include "flutter/fml/platform/win/wstring_conversion.h" -using PlatformResourceMapping = fml::FileMapping; - namespace fml { Mapping::Mapping() = default; Mapping::~Mapping() = default; -bool PlatformHasResourcesBundle() { - return !std::is_same::value; -} - -std::unique_ptr GetResourceMapping(const std::string& resource_name) { - return std::make_unique(resource_name); -} - FileMapping::FileMapping(const std::string& path, bool executable) : FileMapping(OpenFile(path.c_str(), executable ? OpenPermission::kExecute diff --git a/travis/licenses_golden/licenses_flutter b/travis/licenses_golden/licenses_flutter index 3cdcba8d4..993951299 100644 --- a/travis/licenses_golden/licenses_flutter +++ b/travis/licenses_golden/licenses_flutter @@ -51,8 +51,6 @@ FILE: ../../../flutter/fml/platform/darwin/message_loop_darwin.mm FILE: ../../../flutter/fml/platform/darwin/paths_darwin.mm FILE: ../../../flutter/fml/platform/darwin/platform_version.h FILE: ../../../flutter/fml/platform/darwin/platform_version.mm -FILE: ../../../flutter/fml/platform/darwin/resource_mapping_darwin.h -FILE: ../../../flutter/fml/platform/darwin/resource_mapping_darwin.mm FILE: ../../../flutter/fml/platform/darwin/scoped_block.mm FILE: ../../../flutter/fml/platform/darwin/scoped_nsobject.h FILE: ../../../flutter/fml/platform/darwin/scoped_nsobject.mm -- GitLab