0

[storage] add registered ExternalMountPoints debug info

The debug info can be seen at chrome://files-internals/debug.json

ChromeOS' Files app uses FileSystemURLs whose mount_type() is very often
kFileSystemTypeExternal. It also serializes FileSystemURLs as strings
for IPC (e.g. between ash and Fusebox, or ash and lacros). When
debugging the ChromeOS Files app, it can be useful to know the list of
registered ExternalMountPoints.

Bug: None
Change-Id: I350edf71e827a43b2ff72fd78f474a6a5df33cb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5097970
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Auto-Submit: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: Austin Sullivan <asully@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1234734}
This commit is contained in:
Nigel Tao
2023-12-07 22:20:57 +00:00
committed by Chromium LUCI CQ
parent 286af893f8
commit a60ad9de28
3 changed files with 39 additions and 0 deletions
chrome/browser/ash/system_web_apps/apps
storage/browser/file_system

@ -27,6 +27,7 @@
#include "extensions/browser/api/file_handlers/directory_util.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/entry_info.h"
#include "storage/browser/file_system/external_mount_points.h"
ChromeFilesInternalsUIDelegate::ChromeFilesInternalsUIDelegate(
content::WebUI* web_ui)
@ -51,6 +52,11 @@ void ChromeFilesInternalsUIDelegate::GetDebugJSON(
&file_manager::file_tasks::GetDebugJSONForKeyForExecuteFileTask,
nullptr,
},
{
"external_mount_points",
&storage::ExternalMountPoints::GetDebugJSONForKey,
nullptr,
},
{
"fusebox",
nullptr,

@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/strings/strcat.h"
#include "build/chromeos_buildflags.h"
#include "storage/browser/file_system/file_system_url.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
@ -98,6 +99,32 @@ scoped_refptr<ExternalMountPoints> ExternalMountPoints::CreateRefCounted() {
return new ExternalMountPoints();
}
// static
void ExternalMountPoints::GetDebugJSONForKey(
std::string_view key,
base::OnceCallback<void(std::pair<std::string_view, base::Value>)>
callback) {
const ExternalMountPoints* system_instance =
ExternalMountPoints::GetSystemInstance();
if (!system_instance) {
std::move(callback).Run(std::make_pair(key, base::Value()));
return;
}
base::Value::Dict dict;
{
base::AutoLock locker(system_instance->lock_);
for (const auto& pair : system_instance->instance_map_) {
const Instance* instance = pair.second.get();
dict.Set(
pair.first,
base::Value(base::StrCat({GetFileSystemTypeString(instance->type()),
" ", instance->path().AsUTF8Unsafe()})));
}
}
std::move(callback).Run(std::make_pair(key, base::Value(std::move(dict))));
}
bool ExternalMountPoints::RegisterFileSystem(
const std::string& mount_name,
FileSystemType type,

@ -13,6 +13,7 @@
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "storage/browser/file_system/mount_points.h"
#include "storage/common/file_system/file_system_mount_option.h"
#include "storage/common/file_system/file_system_types.h"
@ -44,6 +45,11 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) ExternalMountPoints
static ExternalMountPoints* GetSystemInstance();
static scoped_refptr<ExternalMountPoints> CreateRefCounted();
static void GetDebugJSONForKey(
std::string_view key,
base::OnceCallback<void(std::pair<std::string_view, base::Value>)>
callback);
ExternalMountPoints(const ExternalMountPoints&) = delete;
ExternalMountPoints& operator=(const ExternalMountPoints&) = delete;