Skip to content

Commit

Permalink
Last tuning.
Browse files Browse the repository at this point in the history
  • Loading branch information
boocmp committed Aug 3, 2022
1 parent 340df6f commit 7c79edb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
10 changes: 9 additions & 1 deletion browser/resources/settings/brave_tor_page/brave_tor_subpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@ class SettingsBraveTorPageElement extends SettingBraveTorPageElementBase {
}

isUsingBridgesChanged_(value) {
this.useBridges_ = value ? Usage.USE_BUILT_IN : Usage.NOT_USED
if (value) {
if (this.loadedConfig_.use_bridges != Usage.NOT_USED) {
this.useBridges_ = this.loadedConfig_.use_bridges
} else {
this.useBridges_ = Usage.USE_BUILT_IN
}
} else {
this.useBridges_ = Usage.NOT_USED
}
}

onBuiltInBridgesSelect_(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif

namespace {
constexpr const auto kStuckPeriod = base::Seconds(15);
constexpr const auto kStuckPeriod = base::Seconds(30);
}

BravePrivateNewTabPageHandler::BravePrivateNewTabPageHandler(
Expand Down Expand Up @@ -141,7 +141,7 @@ void BravePrivateNewTabPageHandler::GoToBraveSupport() {
void BravePrivateNewTabPageHandler::OnTorCircuitEstablished(bool result) {
stuck_timer_.Stop();
if (page_) {
page_.get()->OnTorCircuitGetStuck(!result);
page_.get()->OnTorCircuitGetStuck(!result && stuck_timer_.IsRunning());
page_.get()->OnTorCircuitEstablished(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BravePrivateNewTabPageHandler
raw_ptr<TorLauncherFactory> tor_launcher_factory_ = nullptr;
#endif
// Timer for detecting a Tor connection failuer. It starts at each connection
// event and shots when the time between events exceeds 15 seconds.
// event and shots when the time between events exceeds kStuckPeriod seconds.
base::OneShotTimer stuck_timer_;

mojo::Receiver<brave_private_new_tab::mojom::PageHandler> receiver_;
Expand Down
7 changes: 5 additions & 2 deletions components/tor/tor_profile_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@ void TorProfileServiceImpl::OnBridgesConfigChanged() {
return;

if (!tor_pluggable_transport_updater_->IsReady()) {
if (config.use_bridges != tor::BridgesConfig::Usage::kNotUsed)
if (config.use_bridges != tor::BridgesConfig::Usage::kNotUsed) {
tor_pluggable_transport_updater_->Register();
return;
return;
} else {
tor_pluggable_transport_updater_->Unregister();
}
}
if (config.use_bridges == tor::BridgesConfig::Usage::kNotUsed) {
tor_pluggable_transport_updater_->Unregister();
Expand Down

0 comments on commit 7c79edb

Please sign in to comment.