Skip to content

Commit

Permalink
Update indexeddb-internals to generate grd files
Browse files Browse the repository at this point in the history
Updates the indexeddb-internals page to generate grd files
automatically instead of listing them manually.

Bug: 1132403
Change-Id: I404db7d75490b17159b52d78edeb0145ac73dd5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3834942
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Commit-Queue: Nathan Memmott <memmott@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1042346}
  • Loading branch information
Nathan Memmott authored and Chromium LUCI CQ committed Sep 1, 2022
1 parent af073b7 commit 9d35597
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 30 deletions.
2 changes: 2 additions & 0 deletions chrome/chrome_paks.gni
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ template("chrome_extra_paks") {
"$root_gen_dir/components/autofill/core/browser/autofill_address_rewriter_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/content/indexed_db_resources.pak",
"$root_gen_dir/content/quota_internals_resources.pak",
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
"$root_gen_dir/net/net_resources.pak",
Expand All @@ -119,6 +120,7 @@ template("chrome_extra_paks") {
"//components/optimization_guide/optimization_guide_internals/resources",
"//components/resources",
"//content:content_resources",
"//content/browser/resources/indexed_db:resources",
"//content/browser/resources/quota:resources",
"//mojo/public/js:resources",
"//net:net_resources",
Expand Down
50 changes: 24 additions & 26 deletions content/browser/indexed_db/indexed_db_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "base/task/thread_pool.h"
#include "base/threading/platform_thread.h"
#include "base/values.h"
#include "content/grit/dev_ui_content_resources.h"
#include "content/grit/indexed_db_resources.h"
#include "content/grit/indexed_db_resources_map.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -45,11 +46,9 @@ IndexedDBInternalsUI::IndexedDBInternalsUI(WebUI* web_ui)
network::mojom::CSPDirectiveName::TrustedTypes,
"trusted-types jstemplate;");
source->UseStringsJs();
source->AddResourcePath("indexeddb_internals.js",
IDR_INDEXED_DB_INTERNALS_JS);
source->AddResourcePath("indexeddb_internals.css",
IDR_INDEXED_DB_INTERNALS_CSS);
source->SetDefaultResource(IDR_INDEXED_DB_INTERNALS_HTML);
source->AddResourcePaths(
base::make_span(kIndexedDbResources, kIndexedDbResourcesSize));
source->AddResourcePath("", IDR_INDEXED_DB_INDEXEDDB_INTERNALS_HTML);
}

IndexedDBInternalsUI::~IndexedDBInternalsUI() = default;
Expand Down Expand Up @@ -84,26 +83,25 @@ void IndexedDBInternalsHandler::GetAllBuckets(const base::Value::List& args) {
BrowserContext* browser_context =
web_ui()->GetWebContents()->GetBrowserContext();

browser_context->ForEachStoragePartition(
base::BindRepeating(
[](base::WeakPtr<IndexedDBInternalsHandler> handler,
StoragePartition* partition) {
if (!handler)
return;
auto& control = partition->GetIndexedDBControl();
control.GetAllBucketsDetails(base::BindOnce(
[](base::WeakPtr<IndexedDBInternalsHandler> handler,
base::FilePath partition_path, bool incognito,
base::Value::List info_list) {
if (!handler)
return;

handler->OnBucketsReady(
info_list, incognito ? base::FilePath() : partition_path);
},
handler, partition->GetPath()));
},
weak_factory_.GetWeakPtr()));
browser_context->ForEachStoragePartition(base::BindRepeating(
[](base::WeakPtr<IndexedDBInternalsHandler> handler,
StoragePartition* partition) {
if (!handler)
return;
auto& control = partition->GetIndexedDBControl();
control.GetAllBucketsDetails(base::BindOnce(
[](base::WeakPtr<IndexedDBInternalsHandler> handler,
base::FilePath partition_path, bool incognito,
base::Value::List info_list) {
if (!handler)
return;

handler->OnBucketsReady(
info_list, incognito ? base::FilePath() : partition_path);
},
handler, partition->GetPath()));
},
weak_factory_.GetWeakPtr()));
}

void IndexedDBInternalsHandler::OnBucketsReady(
Expand Down
5 changes: 4 additions & 1 deletion content/browser/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
# found in the LICENSE file.

group("resources") {
public_deps = [ "quota:resources" ]
public_deps = [
"indexed_db:resources",
"quota:resources",
]
}
34 changes: 34 additions & 0 deletions content/browser/resources/indexed_db/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 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.
import("//chrome/common/features.gni")
import("//tools/grit/grit_rule.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

grit("resources") {
defines = chrome_grit_defines

# These arguments are needed since the grd is generated at build time.
enable_input_discovery_for_gn_analyze = false
source = "$target_gen_dir/resources.grd"
deps = [ ":build_grd" ]

outputs = [
"grit/indexed_db_resources.h",
"grit/indexed_db_resources_map.cc",
"grit/indexed_db_resources_map.h",
"indexed_db_resources.pak",
]
output_dir = "$root_gen_dir/content"
}

generate_grd("build_grd") {
grd_prefix = "indexed_db"
out_grd = "$target_gen_dir/resources.grd"
input_files_base_dir = rebase_path(".", "//")
input_files = [
"indexeddb_internals.css",
"indexeddb_internals.html",
"indexeddb_internals.js",
]
}
3 changes: 0 additions & 3 deletions content/dev_ui_content_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ files that belong there instead.
<include name="IDR_GPU_INTERNALS_INFO_VIEW_TABLE_ROW_HTML_JS" file="${root_gen_dir}/content/browser/resources/gpu/info_view_table_row.html.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_GPU_INTERNALS_INFO_VIEW_TABLE_ROW_JS" file="browser/resources/gpu/info_view_table_row.js" type="BINDATA" />
<include name="IDR_GPU_VULKAN_INFO_JS" file="browser/resources/gpu/vulkan_info.js" type="BINDATA" />
<include name="IDR_INDEXED_DB_INTERNALS_HTML" file="browser/resources/indexed_db/indexeddb_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_INDEXED_DB_INTERNALS_JS" file="browser/resources/indexed_db/indexeddb_internals.js" type="BINDATA" />
<include name="IDR_INDEXED_DB_INTERNALS_CSS" file="browser/resources/indexed_db/indexeddb_internals.css" type="BINDATA" />
<include name="IDR_NETWORK_ERROR_LISTING_HTML" file="browser/resources/net/network_errors_listing.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_NETWORK_ERROR_LISTING_JS" file="browser/resources/net/network_errors_listing.js" type="BINDATA" />
<include name="IDR_NETWORK_ERROR_LISTING_CSS" file="browser/resources/net/network_errors_listing.css" type="BINDATA" />
Expand Down
4 changes: 4 additions & 0 deletions tools/gritsettings/resource_ids.spec
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@
"components/resources/dev_ui_components_resources.grd": {
"includes": [2560],
},
"<(SHARED_INTERMEDIATE_DIR)/content/browser/resources/indexed_db/resources.grd": {
"META": {"sizes": {"includes": [10]}},
"includes": [2570],
},
"<(SHARED_INTERMEDIATE_DIR)/content/browser/resources/media/resources.grd": {
"META": {"sizes": {"includes": [10],}},
"includes": [2580],
Expand Down

0 comments on commit 9d35597

Please sign in to comment.