Commit fb05ab74 authored by Joel Hockey's avatar Joel Hockey Committed by Chromium LUCI CQ

Avoid SharePath call when launching app with shared path

If a path is already shared, we can avoid the extra seneschal dbus call.

This code was originally written before GuestOsSharePath::IsPathShared()
was available.

Change-Id: Ia92dcad3e3202f40606a0e8b7620e0ea76847c58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596472
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Commit-Queue: Jason Lin <lxj@google.com>
Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarJason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#838587}
parent 1788d58d
...@@ -177,6 +177,9 @@ void LaunchApplication( ...@@ -177,6 +177,9 @@ void LaunchApplication(
crostini_tracker->OnAppLaunchRequested(app_id, display_id); crostini_tracker->OnAppLaunchRequested(app_id, display_id);
auto* share_path = guest_os::GuestOsSharePath::GetForProfile(profile);
const auto vm_name = registration.VmName();
// Share any paths not in crostini. The user will see the spinner while this // Share any paths not in crostini. The user will see the spinner while this
// is happening. // is happening.
std::vector<base::FilePath> paths_to_share; std::vector<base::FilePath> paths_to_share;
...@@ -196,7 +199,8 @@ void LaunchApplication( ...@@ -196,7 +199,8 @@ void LaunchApplication(
"Cannot share file with crostini: " + url.DebugString()); "Cannot share file with crostini: " + url.DebugString());
} }
if (url.mount_filesystem_id() != if (url.mount_filesystem_id() !=
file_manager::util::GetCrostiniMountPointName(profile)) { file_manager::util::GetCrostiniMountPointName(profile) &&
!share_path->IsPathShared(vm_name, url.path())) {
paths_to_share.push_back(url.path()); paths_to_share.push_back(url.path());
} }
launch_args.push_back(path.value()); launch_args.push_back(path.value());
...@@ -207,8 +211,7 @@ void LaunchApplication( ...@@ -207,8 +211,7 @@ void LaunchApplication(
display_id, std::move(launch_args), display_id, std::move(launch_args),
std::move(callback), true, ""); std::move(callback), true, "");
} else { } else {
const auto vm_name = registration.VmName(); share_path->SharePaths(
guest_os::GuestOsSharePath::GetForProfile(profile)->SharePaths(
vm_name, std::move(paths_to_share), /*persist=*/false, vm_name, std::move(paths_to_share), /*persist=*/false,
base::BindOnce(OnSharePathForLaunchApplication, profile, app_id, base::BindOnce(OnSharePathForLaunchApplication, profile, app_id,
std::move(registration), display_id, std::move(registration), display_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment