Fixed flaky test. (#15177)
This commit is contained in:
@@ -11,15 +11,12 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/callback_helpers.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/task/task_traits.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
@@ -521,18 +518,17 @@ void TorControl::GetCircuitEstablishedDone(
|
||||
}
|
||||
|
||||
void TorControl::SetupPluggableTransport(
|
||||
const base::FilePath& tor,
|
||||
const base::FilePath& snowflake,
|
||||
const base::FilePath& obfs4,
|
||||
base::OnceCallback<void(bool error)> callback) {
|
||||
if (tor.empty() || snowflake.empty() || obfs4.empty())
|
||||
if (snowflake.empty() || obfs4.empty())
|
||||
return;
|
||||
|
||||
if (owner_task_runner_->RunsTasksInCurrentSequence()) {
|
||||
io_task_runner_->PostTask(
|
||||
FROM_HERE, base::BindOnce(&TorControl::SetupPluggableTransport,
|
||||
weak_ptr_factory_.GetWeakPtr(), tor,
|
||||
snowflake, obfs4, std::move(callback)));
|
||||
weak_ptr_factory_.GetWeakPtr(), snowflake,
|
||||
obfs4, std::move(callback)));
|
||||
return;
|
||||
}
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(io_sequence_checker_);
|
||||
@@ -541,21 +537,6 @@ void TorControl::SetupPluggableTransport(
|
||||
base::FilePath::FromASCII("../../").Append(snowflake);
|
||||
const auto obfs4_path = base::FilePath::FromASCII("../../").Append(obfs4);
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
// Check we can touch pluggable transport executables from the tor's working
|
||||
// dir.
|
||||
base::ThreadPool::PostTask(
|
||||
FROM_HERE, {base::MayBlock()},
|
||||
base::BindOnce(
|
||||
[](const base::FilePath& tor, const base::FilePath& snowflake_path,
|
||||
const base::FilePath& obfs4_path) {
|
||||
const auto tor_path = tor.DirName();
|
||||
DCHECK(base::PathExists(tor_path.Append(snowflake_path)));
|
||||
DCHECK(base::PathExists(tor_path.Append(obfs4_path)));
|
||||
},
|
||||
tor, snowflake_path, obfs4_path));
|
||||
#endif
|
||||
|
||||
constexpr const char kObfs4ConfigCmd[] =
|
||||
"ClientTransportPlugin=\"meek_lite,obfs2,obfs3,obfs4,scramblesuit "
|
||||
"exec %s\"";
|
||||
|
||||
@@ -93,8 +93,7 @@ class TorControl {
|
||||
void GetCircuitEstablished(
|
||||
base::OnceCallback<void(bool error, bool established)> callback);
|
||||
|
||||
void SetupPluggableTransport(const base::FilePath& tor,
|
||||
const base::FilePath& snowflake,
|
||||
void SetupPluggableTransport(const base::FilePath& snowflake,
|
||||
const base::FilePath& obfs4,
|
||||
base::OnceCallback<void(bool error)> callback);
|
||||
void SetupBridges(const std::vector<std::string>& bridges,
|
||||
|
||||
@@ -151,8 +151,7 @@ void TorLauncherFactory::SetupPluggableTransport(
|
||||
const base::FilePath& snowflake,
|
||||
const base::FilePath& obfs4) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
control_->SetupPluggableTransport(config_.binary_path, snowflake, obfs4,
|
||||
base::DoNothing());
|
||||
control_->SetupPluggableTransport(snowflake, obfs4, base::DoNothing());
|
||||
}
|
||||
|
||||
void TorLauncherFactory::SetupBridges(tor::BridgesConfig bridges_config) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "brave/components/tor/brave_tor_pluggable_transport_updater.h"
|
||||
#include "brave/components/tor/pref_names.h"
|
||||
@@ -166,6 +167,28 @@ void TorProfileServiceImpl::OnExecutableReady(const base::FilePath& path) {
|
||||
void TorProfileServiceImpl::OnPluggableTransportReady(bool success) {
|
||||
if (!success || !tor_launcher_factory_)
|
||||
return;
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
// Check we can touch pluggable transport executables from the tor's working
|
||||
// dir.
|
||||
const auto snowflake_path = base::FilePath::FromASCII("../../").Append(
|
||||
tor_pluggable_transport_updater_->GetSnowflakeExecutable());
|
||||
const auto obfs4_path = base::FilePath::FromASCII("../../").Append(
|
||||
tor_pluggable_transport_updater_->GetObfs4Executable());
|
||||
tor_pluggable_transport_updater_->GetTaskRunner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
[](const base::FilePath& tor, const base::FilePath& snowflake_path,
|
||||
const base::FilePath& obfs4_path) {
|
||||
if (tor.empty())
|
||||
return;
|
||||
const auto tor_path = tor.DirName();
|
||||
DCHECK(base::PathExists(tor_path.Append(snowflake_path)));
|
||||
DCHECK(base::PathExists(tor_path.Append(obfs4_path)));
|
||||
},
|
||||
GetTorExecutablePath(), snowflake_path, obfs4_path));
|
||||
#endif
|
||||
|
||||
OnBridgesConfigChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user