Chromium Code Reviews| Index: content/browser/webui/shared_resources_data_source.cc |
| diff --git a/content/browser/webui/shared_resources_data_source.cc b/content/browser/webui/shared_resources_data_source.cc |
| index d9aaee7d1dc8cbb124a8de579bdfa6bf321000f4..bceaf952a2b26fdc4f44d9f3ba3e8af178805849 100644 |
| --- a/content/browser/webui/shared_resources_data_source.cc |
| +++ b/content/browser/webui/shared_resources_data_source.cc |
| @@ -6,6 +6,8 @@ |
| #include <stddef.h> |
| +#include <set> |
| + |
| #include "base/containers/hash_tables.h" |
| #include "base/files/file_path.h" |
| #include "base/logging.h" |
| @@ -46,6 +48,8 @@ const struct { |
| {"js/mojo_bindings.js", IDR_WEBUI_MOJO_BINDINGS_JS}, |
| }; |
| +const char* const kGzippedPaths[] = {"js/mojo_bindings.js"}; |
| + |
| void AddResource(const std::string& path, |
| int resource_id, |
| ResourcesMap* resources_map) { |
| @@ -86,6 +90,19 @@ int GetIdrForPath(const std::string& path) { |
| return it != resources_map.end() ? it->second : -1; |
| } |
| +const std::set<std::string>* CreateGzippedPathSet() { |
| + std::set<std::string>* result = new std::set<std::string>(); |
| + for (size_t i = 0; i < arraysize(kGzippedPaths); ++i) |
| + result->insert(std::string(kGzippedPaths[i])); |
| + return result; |
| +} |
| + |
| +const std::set<std::string>& GetGzippedPathSet() { |
| + // This pointer will be intentionally leaked on shutdown. |
| + static const std::set<std::string>* gzipped_path_set = CreateGzippedPathSet(); |
| + return *gzipped_path_set; |
| +} |
| + |
| } // namespace |
| SharedResourcesDataSource::SharedResourcesDataSource() { |
| @@ -196,4 +213,9 @@ SharedResourcesDataSource::GetAccessControlAllowOriginForOrigin( |
| return origin; |
| } |
| +bool SharedResourcesDataSource::IsGzipped(const std::string& path) const { |
| + const auto& gzipped_path_set = GetGzippedPathSet(); |
| + return gzipped_path_set.find(path) != gzipped_path_set.end(); |
|
Dan Beam
2017/06/09 01:05:28
can't this all just be
return path == "js/mojo_bi
yzshen1
2017/06/09 07:07:10
Yes. It can. :) Done.
|
| +} |
| + |
| } // namespace content |