Commit a223d957 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Shorten delay before mounting SMB share

Currently, we wait until the first batch of shares is returned from host
discovery before attempting to Mount a share so that name resolution can
be performed. This change switches to using the GatherSharesInNetwork method that
takes a HostDiscoveryResponse callback so that the delay is shortened.

Bug: chromium:757625
Change-Id: I22cf5fd48bdcc633fa4d7f2f08b1e6f7e10af764
Reviewed-on: https://chromium-review.googlesource.com/1211947
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590069}
parent 0f12b028
...@@ -92,17 +92,22 @@ void SmbHandler::HandleStartDiscovery(const base::ListValue* args) { ...@@ -92,17 +92,22 @@ void SmbHandler::HandleStartDiscovery(const base::ListValue* args) {
return; return;
} }
service->GatherSharesInNetwork(base::BindRepeating( service->GatherSharesInNetwork(
&SmbHandler::HandleGatherSharesResponse, weak_ptr_factory_.GetWeakPtr())); base::BindOnce(&SmbHandler::HandleDiscoveryDone,
weak_ptr_factory_.GetWeakPtr()),
base::BindRepeating(&SmbHandler::HandleGatherSharesResponse,
weak_ptr_factory_.GetWeakPtr()));
} }
void SmbHandler::HandleGatherSharesResponse( void SmbHandler::HandleDiscoveryDone() {
const std::vector<smb_client::SmbUrl>& shares_gathered) {
host_discovery_done_ = true; host_discovery_done_ = true;
if (!stored_mount_call_.is_null()) { if (!stored_mount_call_.is_null()) {
std::move(stored_mount_call_).Run(); std::move(stored_mount_call_).Run();
} }
}
void SmbHandler::HandleGatherSharesResponse(
const std::vector<smb_client::SmbUrl>& shares_gathered) {
AllowJavascript(); AllowJavascript();
FireWebUIListener("on-shares-found", BuildShareList(shares_gathered)); FireWebUIListener("on-shares-found", BuildShareList(shares_gathered));
} }
......
...@@ -42,6 +42,9 @@ class SmbHandler : public ::settings::SettingsPageUIHandler { ...@@ -42,6 +42,9 @@ class SmbHandler : public ::settings::SettingsPageUIHandler {
void HandleGatherSharesResponse( void HandleGatherSharesResponse(
const std::vector<smb_client::SmbUrl>& shares_gathered); const std::vector<smb_client::SmbUrl>& shares_gathered);
// Callback handler that indicates discovery is complete.
void HandleDiscoveryDone();
bool host_discovery_done_ = false; bool host_discovery_done_ = false;
base::OnceClosure stored_mount_call_; base::OnceClosure stored_mount_call_;
Profile* const profile_; Profile* const profile_;
......
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