@@ -42,6 +42,8 @@ constexpr int kConnectedPeersRetryLimitSec = 120;
42
42
// The period in seconds between requests to get connected peers information.
43
43
constexpr int kConnectedPeersRetryStepSec = 1 ;
44
44
45
+ // The period in seconds when we alert user about error.
46
+ constexpr int kConnectedPeersAlertTimeoutSec = 10 ;
45
47
} // namespace
46
48
namespace ipfs {
47
49
@@ -71,7 +73,7 @@ void IPFSOnboardingPage::UseLocalNode() {
71
73
auto * prefs = user_prefs::UserPrefs::Get (context);
72
74
prefs->SetInteger (kIPFSResolveMethod ,
73
75
static_cast <int >(ipfs::IPFSResolveMethodTypes::IPFS_LOCAL));
74
-
76
+ start_time_ticks_ = base::TimeTicks::Now ();
75
77
if (!ipfs_service_->IsDaemonLaunched ()) {
76
78
ipfs_service_->LaunchDaemon (base::NullCallback ());
77
79
} else {
@@ -98,12 +100,13 @@ void IPFSOnboardingPage::OnGetConnectedPeers(
98
100
if (!success || peers.empty ()) {
99
101
base::TimeDelta delta = base::TimeTicks::Now () - start_time_ticks_;
100
102
if (delta.InSeconds () < kConnectedPeersRetryLimitSec ) {
101
- int retries = (kConnectedPeersRetryLimitSec - delta.InSeconds ()) /
102
- kConnectedPeersRetryStepSec ;
103
- RespondToPage (NO_PEERS_AVAILABLE, l10n_util::GetStringFUTF16 (
104
- IDS_IPFS_ONBOARDING_PEERS_ERROR,
105
- base::NumberToString16 (retries)));
106
-
103
+ if (delta.InSeconds () > kConnectedPeersAlertTimeoutSec ) {
104
+ int retries = (kConnectedPeersRetryLimitSec - delta.InSeconds ()) /
105
+ kConnectedPeersRetryStepSec ;
106
+ RespondToPage (NO_PEERS_AVAILABLE, l10n_util::GetStringFUTF16 (
107
+ IDS_IPFS_ONBOARDING_PEERS_ERROR,
108
+ base::NumberToString16 (retries)));
109
+ }
107
110
base::SequencedTaskRunnerHandle::Get ()->PostDelayedTask (
108
111
FROM_HERE,
109
112
base::BindOnce (&IPFSOnboardingPage::GetConnectedPeers,
@@ -137,7 +140,6 @@ bool IPFSOnboardingPage::IsLocalNodeMode() {
137
140
}
138
141
139
142
void IPFSOnboardingPage::OnIpfsLaunched (bool result, int64_t pid) {
140
- start_time_ticks_ = base::TimeTicks::Now ();
141
143
if (!result) {
142
144
ReportDaemonStopped ();
143
145
return ;
@@ -235,6 +237,9 @@ void IPFSOnboardingPage::PopulateInterstitialStrings(
235
237
load_time_data->SetString (
236
238
" retryLimitPeersText" ,
237
239
l10n_util::GetStringUTF16 (IDS_IPFS_ONBOARDING_PEERS_LIMIT_ERROR));
240
+ load_time_data->SetString (
241
+ " tryAgainText" , l10n_util::GetStringUTF16 (IDS_IPFS_ONBOARDING_TRY_AGAIN));
242
+
238
243
load_time_data->SetString (
239
244
" braveTheme" , GetThemeType (ui::NativeTheme::GetInstanceForNativeUi ()));
240
245
}
0 commit comments