Skip to content

Commit

Permalink
Shorten delay before mounting SMB share
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Scott Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#590069}
  • Loading branch information
Bailey Berro authored and Commit Bot committed Sep 10, 2018
1 parent 0f12b02 commit a223d95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,22 @@ void SmbHandler::HandleStartDiscovery(const base::ListValue* args) {
return;
}

service->GatherSharesInNetwork(base::BindRepeating(
&SmbHandler::HandleGatherSharesResponse, weak_ptr_factory_.GetWeakPtr()));
service->GatherSharesInNetwork(
base::BindOnce(&SmbHandler::HandleDiscoveryDone,
weak_ptr_factory_.GetWeakPtr()),
base::BindRepeating(&SmbHandler::HandleGatherSharesResponse,
weak_ptr_factory_.GetWeakPtr()));
}

void SmbHandler::HandleGatherSharesResponse(
const std::vector<smb_client::SmbUrl>& shares_gathered) {
void SmbHandler::HandleDiscoveryDone() {
host_discovery_done_ = true;
if (!stored_mount_call_.is_null()) {
std::move(stored_mount_call_).Run();
}
}

void SmbHandler::HandleGatherSharesResponse(
const std::vector<smb_client::SmbUrl>& shares_gathered) {
AllowJavascript();
FireWebUIListener("on-shares-found", BuildShareList(shares_gathered));
}
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/webui/settings/chromeos/smb_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class SmbHandler : public ::settings::SettingsPageUIHandler {
void HandleGatherSharesResponse(
const std::vector<smb_client::SmbUrl>& shares_gathered);

// Callback handler that indicates discovery is complete.
void HandleDiscoveryDone();

bool host_discovery_done_ = false;
base::OnceClosure stored_mount_call_;
Profile* const profile_;
Expand Down

0 comments on commit a223d95

Please sign in to comment.