Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: content/browser/webui/shared_resources_data_source.cc

Issue 2931983002: Mojo JS bindings: specify compress="gzip" for bindings JS files in .grd. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/webui/shared_resources_data_source.h ('k') | ui/webui/resources/webui_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/webui/shared_resources_data_source.h ('k') | ui/webui/resources/webui_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698