Merge pull request #14888 from brave/clang-tidy-make-unique-II

[CodeHealth] Clang-tidy make_unique modernise II
This commit is contained in:
Brian Clifton
2022-08-30 12:04:04 -07:00
committed by GitHub
51 changed files with 242 additions and 202 deletions
@@ -5,6 +5,7 @@
#include "components/translate/core/browser/translate_manager.h"
#include <memory>
#include <utility>
#include "base/memory/raw_ptr.h"
@@ -173,10 +174,8 @@ TEST_F(TranslateManagerTest, CanManuallyTranslate_WithoutAPIKey) {
EXPECT_FALSE(::google_apis::HasAPIKeyConfigured());
TranslateManager::SetIgnoreMissingKeyForTesting(false);
translate_manager_.reset(new translate::TranslateManager(
&mock_translate_client_,
&mock_translate_ranker_,
&mock_language_model_));
translate_manager_ = std::make_unique<translate::TranslateManager>(
&mock_translate_client_, &mock_translate_ranker_, &mock_language_model_);
prefs_.SetBoolean(translate::prefs::kOfferTranslateEnabled, true);
ON_CALL(mock_translate_client_, IsTranslatableURL(GURL::EmptyGURL()))
@@ -195,10 +194,8 @@ TEST_F(TranslateManagerTest, CanManuallyTranslate_WithAPIKey) {
EXPECT_TRUE(::google_apis::HasAPIKeyConfigured());
TranslateManager::SetIgnoreMissingKeyForTesting(false);
translate_manager_.reset(new translate::TranslateManager(
&mock_translate_client_,
&mock_translate_ranker_,
&mock_language_model_));
translate_manager_ = std::make_unique<translate::TranslateManager>(
&mock_translate_client_, &mock_translate_ranker_, &mock_language_model_);
prefs_.SetBoolean(translate::prefs::kOfferTranslateEnabled, true);
ON_CALL(mock_translate_client_, IsTranslatableURL(GURL::EmptyGURL()))
@@ -5,6 +5,7 @@
#include "brave/components/api_request_helper/api_request_helper.h"
#include <memory>
#include <utility>
#include "base/callback.h"
@@ -35,9 +36,9 @@ class ApiRequestHelperUnitTest : public testing::Test {
: shared_url_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
api_request_helper_.reset(new APIRequestHelper(
api_request_helper_ = std::make_unique<APIRequestHelper>(
net::NetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
shared_url_loader_factory_));
shared_url_loader_factory_);
}
~ApiRequestHelperUnitTest() override = default;
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/path_service.h"
#include "brave/browser/binance/binance_service_factory.h"
#include "brave/components/binance/browser/binance_service.h"
@@ -229,8 +231,8 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
void ResetHTTPSServer(
const net::EmbeddedTestServer::HandleRequestCallback& callback) {
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(callback);
ASSERT_TRUE(https_server_->Start());
@@ -259,7 +261,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -288,7 +290,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
expected_total_fee_ = expected_total_fee;
expected_total_amount_ = expected_total_amount;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -309,7 +311,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
}
expected_balances_ = expected_balances;
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -332,7 +334,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
expected_address_ = expected_address;
expected_tag_ = expected_tag;
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -351,7 +353,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
}
expected_success_ = expected_success;
expected_error_message_ = expected_error_message;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -369,7 +371,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_assets_with_sub_ = expected_assets;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -391,7 +393,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_success_ = success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -408,7 +410,7 @@ class BinanceAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_networks_ = expected_networks;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -5,6 +5,7 @@
#include "brave/components/brave_federated/brave_federated_service.h"
#include <memory>
#include <utility>
#include "base/logging.h"
@@ -58,13 +59,13 @@ void BraveFederatedService::Init() {
base::FilePath db_path(
browser_context_path_.AppendASCII("data_store.sqlite"));
data_store_service_.reset(new DataStoreService(db_path));
data_store_service_ = std::make_unique<DataStoreService>(db_path);
data_store_service_->Init();
eligibility_service_.reset(new EligibilityService());
eligibility_service_ = std::make_unique<EligibilityService>();
operational_patterns_.reset(
new OperationalPatterns(prefs_, url_loader_factory_));
operational_patterns_ =
std::make_unique<OperationalPatterns>(prefs_, url_loader_factory_);
MaybeStartOperationalPatterns();
}
@@ -4,6 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <map>
#include <memory>
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ptr.h"
@@ -86,7 +87,7 @@ class RewardsServiceTest : public testing::Test {
RewardsServiceFactory::GetForProfile(profile()));
ASSERT_TRUE(RewardsServiceFactory::GetInstance());
ASSERT_TRUE(rewards_service());
observer_.reset(new MockRewardsServiceObserver);
observer_ = std::make_unique<MockRewardsServiceObserver>();
rewards_service_->AddObserver(observer_.get());
}
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include <utility>
#include "base/strings/stringprintf.h"
@@ -265,7 +266,7 @@ void RewardsBrowserTestContribution::WaitForPendingTipToBeSaved() {
return;
}
wait_for_pending_tip_saved_loop_.reset(new base::RunLoop);
wait_for_pending_tip_saved_loop_ = std::make_unique<base::RunLoop>();
wait_for_pending_tip_saved_loop_->Run();
}
@@ -287,7 +288,7 @@ void RewardsBrowserTestContribution::WaitForTipReconcileCompleted() {
return;
}
wait_for_tip_completed_loop_.reset(new base::RunLoop);
wait_for_tip_completed_loop_ = std::make_unique<base::RunLoop>();
wait_for_tip_completed_loop_->Run();
}
@@ -376,7 +377,7 @@ void RewardsBrowserTestContribution::WaitForRecurringTipToBeSaved() {
return;
}
wait_for_recurring_tip_saved_loop_.reset(new base::RunLoop);
wait_for_recurring_tip_saved_loop_ = std::make_unique<base::RunLoop>();
wait_for_recurring_tip_saved_loop_->Run();
}
@@ -401,7 +402,7 @@ void RewardsBrowserTestContribution::WaitForMultipleTipReconcileCompleted(
return;
}
wait_for_multiple_tip_completed_loop_.reset(new base::RunLoop);
wait_for_multiple_tip_completed_loop_ = std::make_unique<base::RunLoop>();
wait_for_multiple_tip_completed_loop_->Run();
}
@@ -413,7 +414,7 @@ void RewardsBrowserTestContribution::WaitForMultipleACReconcileCompleted(
return;
}
wait_for_multiple_ac_completed_loop_.reset(new base::RunLoop);
wait_for_multiple_ac_completed_loop_ = std::make_unique<base::RunLoop>();
wait_for_multiple_ac_completed_loop_->Run();
}
@@ -422,7 +423,7 @@ void RewardsBrowserTestContribution::WaitForACReconcileCompleted() {
return;
}
wait_for_ac_completed_loop_.reset(new base::RunLoop);
wait_for_ac_completed_loop_ = std::make_unique<base::RunLoop>();
wait_for_ac_completed_loop_->Run();
}
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include <utility>
#include "brave/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.h"
@@ -31,7 +32,7 @@ void RewardsBrowserTestPromotion::WaitForPromotionInitialization() {
return;
}
wait_for_initialization_loop_.reset(new base::RunLoop);
wait_for_initialization_loop_ = std::make_unique<base::RunLoop>();
wait_for_initialization_loop_->Run();
}
@@ -54,7 +55,7 @@ void RewardsBrowserTestPromotion::WaitForPromotionFinished(
return;
}
wait_for_finished_loop_.reset(new base::RunLoop);
wait_for_finished_loop_ = std::make_unique<base::RunLoop>();
wait_for_finished_loop_->Run();
}
@@ -81,7 +82,7 @@ void RewardsBrowserTestPromotion::WaitForUnblindedTokensReady() {
return;
}
wait_for_unblinded_tokens_loop_.reset(new base::RunLoop);
wait_for_unblinded_tokens_loop_ = std::make_unique<base::RunLoop>();
wait_for_unblinded_tokens_loop_->Run();
}
@@ -53,8 +53,8 @@ class RewardsBrowserTest : public InProcessBrowserTest {
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -49,8 +49,8 @@ class RewardsContributionBrowserTest : public InProcessBrowserTest {
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -42,8 +42,8 @@ class RewardsFlagBrowserTest : public InProcessBrowserTest {
brave_rewards::RewardsFlags::SetForceParsingForTesting(true);
// HTTP resolver
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -88,7 +88,7 @@ class RewardsFlagBrowserTest : public InProcessBrowserTest {
void ResetWaitForCallback() {
callback_called_ = false;
wait_for_callback_.reset(new base::RunLoop);
wait_for_callback_ = std::make_unique<base::RunLoop>();
}
void WaitForCallback() {
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
@@ -49,8 +51,8 @@ class RewardsNotificationBrowserTest
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -156,7 +158,7 @@ class RewardsNotificationBrowserTest
return;
}
wait_for_add_notification_loop_.reset(new base::RunLoop);
wait_for_add_notification_loop_ = std::make_unique<base::RunLoop>();
wait_for_add_notification_loop_->Run();
}
@@ -165,7 +167,7 @@ class RewardsNotificationBrowserTest
return;
}
wait_for_delete_notification_loop_.reset(new base::RunLoop);
wait_for_delete_notification_loop_ = std::make_unique<base::RunLoop>();
wait_for_delete_notification_loop_->Run();
}
@@ -174,7 +176,8 @@ class RewardsNotificationBrowserTest
return;
}
wait_for_insufficient_notification_loop_.reset(new base::RunLoop);
wait_for_insufficient_notification_loop_ =
std::make_unique<base::RunLoop>();
wait_for_insufficient_notification_loop_->Run();
}
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
@@ -38,8 +40,8 @@ class RewardsPromotionBrowserTest : public InProcessBrowserTest {
std::make_unique<RewardsBrowserTestContextHelper>(browser());
// HTTP resolver
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
@@ -39,8 +41,8 @@ class RewardsPublisherBrowserTest : public InProcessBrowserTest {
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/base64.h"
#include "base/containers/flat_map.h"
#include "base/files/file_util.h"
@@ -51,8 +53,8 @@ class RewardsStateBrowserTest : public InProcessBrowserTest {
InProcessBrowserTest::SetUpOnMainThread();
// HTTP resolver
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&rewards_browsertest_util::HandleRequest));
@@ -5,6 +5,8 @@
#include "brave/components/brave_search/renderer/brave_search_render_frame_observer.h"
#include <memory>
#include "brave/components/brave_search/common/brave_search_utils.h"
#include "brave/components/brave_search/renderer/brave_search_default_js_handler.h"
#include "content/public/renderer/render_frame.h"
@@ -42,8 +44,8 @@ void BraveSearchRenderFrameObserver::DidCreateScriptContext(
}
if (!native_javascript_handle_) {
native_javascript_handle_.reset(new BraveSearchDefaultJSHandler(
render_frame(), can_always_set_default));
native_javascript_handle_ = std::make_unique<BraveSearchDefaultJSHandler>(
render_frame(), can_always_set_default);
} else {
native_javascript_handle_->ResetRemote(render_frame());
}
@@ -110,8 +110,8 @@ AssetRatioService::~AssetRatioService() = default;
void AssetRatioService::SetAPIRequestHelperForTesting(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
api_request_helper_.reset(new api_request_helper::APIRequestHelper(
GetNetworkTrafficAnnotationTag(), url_loader_factory));
api_request_helper_ = std::make_unique<api_request_helper::APIRequestHelper>(
GetNetworkTrafficAnnotationTag(), url_loader_factory);
}
mojo::PendingRemote<mojom::AssetRatioService> AssetRatioService::MakeRemote() {
@@ -60,8 +60,8 @@ class AssetRatioServiceUnitTest : public testing::Test {
: shared_url_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
asset_ratio_service_.reset(
new AssetRatioService(shared_url_loader_factory_));
asset_ratio_service_ =
std::make_unique<AssetRatioService>(shared_url_loader_factory_);
}
~AssetRatioServiceUnitTest() override = default;
@@ -50,8 +50,8 @@ class EthBlockTrackerUnitTest : public testing::Test {
&url_loader_factory_)) {}
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new brave_wallet::JsonRpcService(shared_url_loader_factory_, &prefs_));
json_rpc_service_ = std::make_unique<brave_wallet::JsonRpcService>(
shared_url_loader_factory_, &prefs_);
}
std::string GetResponseString() const {
return "{\"id\":1,\"jsonrpc\":\"2.0\",\"result\":\"" +
@@ -238,12 +238,12 @@ class EthTxManagerUnitTest : public testing::Test {
}));
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
keyring_service_.reset(
new KeyringService(json_rpc_service_.get(), &prefs_));
tx_service_.reset(new TxService(json_rpc_service_.get(),
keyring_service_.get(), &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
keyring_service_ =
std::make_unique<KeyringService>(json_rpc_service_.get(), &prefs_);
tx_service_ = std::make_unique<TxService>(json_rpc_service_.get(),
keyring_service_.get(), &prefs_);
base::RunLoop run_loop;
json_rpc_service_->SetNetwork(brave_wallet::mojom::kLocalhostChainId,
@@ -2110,7 +2110,7 @@ TEST_F(EthTxManagerUnitTest, MakeERC721TransferFromDataTxType) {
mojom::TransactionType::ERC721SafeTransferFrom));
run_loop->Run();
run_loop.reset(new base::RunLoop());
run_loop = std::make_unique<base::RunLoop>();
eth_tx_manager()->MakeERC721TransferFromData(
"0xBFb30a082f650C2A15D0632f0e87bE4F8e64460f",
"0xBFb30a082f650C2A15D0632f0e87bE4F8e64460a", "0xf",
@@ -2120,7 +2120,7 @@ TEST_F(EthTxManagerUnitTest, MakeERC721TransferFromDataTxType) {
run_loop->Run();
// Invalid token ID should fail.
run_loop.reset(new base::RunLoop());
run_loop = std::make_unique<base::RunLoop>();
eth_tx_manager()->MakeERC721TransferFromData(
"0xBFb30a082f650C2A15D0632f0e87bE4F8e64460f",
"0xBFb30a082f650C2A15D0632f0e87bE4F8e64460a", "1", contract_transfer_from,
@@ -5,6 +5,7 @@
#include "brave/components/brave_wallet/browser/eth_tx_state_manager.h"
#include <memory>
#include <utility>
#include "base/run_loop.h"
@@ -41,10 +42,10 @@ class EthTxStateManagerUnitTest : public testing::Test {
protected:
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, GetPrefs()));
eth_tx_state_manager_.reset(
new EthTxStateManager(GetPrefs(), json_rpc_service_.get()));
json_rpc_service_ = std::make_unique<JsonRpcService>(
shared_url_loader_factory_, GetPrefs());
eth_tx_state_manager_ = std::make_unique<EthTxStateManager>(
GetPrefs(), json_rpc_service_.get());
}
void SetNetwork(const std::string& chain_id) {
@@ -54,9 +54,9 @@ class FilBlockTrackerUnitTest : public testing::Test {
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
tracker_.reset(new FilBlockTracker(json_rpc_service_.get()));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
tracker_ = std::make_unique<FilBlockTracker>(json_rpc_service_.get());
}
std::string GetResponseString() const {
@@ -4,6 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "brave/components/brave_wallet/browser/fil_tx_manager.h"
#include <memory>
#include <unordered_map>
#include <utility>
@@ -74,12 +75,12 @@ class FilTxManagerUnitTest : public testing::Test {
brave_wallet::features::kBraveWalletFilecoinFeature);
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
keyring_service_.reset(
new KeyringService(json_rpc_service_.get(), &prefs_));
tx_service_.reset(new TxService(json_rpc_service_.get(),
keyring_service_.get(), &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
keyring_service_ =
std::make_unique<KeyringService>(json_rpc_service_.get(), &prefs_);
tx_service_ = std::make_unique<TxService>(json_rpc_service_.get(),
keyring_service_.get(), &prefs_);
base::RunLoop run_loop;
json_rpc_service_->SetNetwork(brave_wallet::mojom::kLocalhostChainId,
@@ -5,6 +5,7 @@
#include "brave/components/brave_wallet/browser/fil_tx_state_manager.h"
#include <memory>
#include <utility>
#include <vector>
@@ -34,10 +35,10 @@ class FilTxStateManagerUnitTest : public testing::Test {
protected:
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, GetPrefs()));
fil_tx_state_manager_.reset(
new FilTxStateManager(GetPrefs(), json_rpc_service_.get()));
json_rpc_service_ = std::make_unique<JsonRpcService>(
shared_url_loader_factory_, GetPrefs());
fil_tx_state_manager_ = std::make_unique<FilTxStateManager>(
GetPrefs(), json_rpc_service_.get());
}
void SetNetwork(const std::string& chain_id) {
@@ -345,8 +345,8 @@ class JsonRpcServiceUnitTest : public testing::Test {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
brave_wallet::RegisterProfilePrefsForMigration(prefs_.registry());
ipfs::IpfsService::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
SetNetwork(mojom::kLocalhostChainId, mojom::CoinType::ETH);
SetNetwork(mojom::kLocalhostChainId, mojom::CoinType::SOL);
SetNetwork(mojom::kLocalhostChainId, mojom::CoinType::FIL);
@@ -58,9 +58,9 @@ class SolanaBlockTrackerUnitTest : public testing::Test {
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
tracker_.reset(new SolanaBlockTracker(json_rpc_service_.get()));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
tracker_ = std::make_unique<SolanaBlockTracker>(json_rpc_service_.get());
}
std::string GetResponseString() const {
@@ -51,10 +51,10 @@ class SolanaTransactionUnitTest : public testing::Test {
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
keyring_service_.reset(
new KeyringService(json_rpc_service_.get(), &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
keyring_service_ =
std::make_unique<KeyringService>(json_rpc_service_.get(), &prefs_);
}
~SolanaTransactionUnitTest() override = default;
@@ -5,6 +5,7 @@
#include "brave/components/brave_wallet/browser/solana_tx_manager.h"
#include <memory>
#include <utility>
#include "base/base64.h"
@@ -64,12 +65,12 @@ class SolanaTxManagerUnitTest : public testing::Test {
SetInterceptor(latest_blockhash1_, last_valid_block_height1_, tx_hash1_, "",
false, last_valid_block_height1_);
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
keyring_service_.reset(
new KeyringService(json_rpc_service_.get(), &prefs_));
tx_service_.reset(new TxService(json_rpc_service_.get(),
keyring_service_.get(), &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
keyring_service_ =
std::make_unique<KeyringService>(json_rpc_service_.get(), &prefs_);
tx_service_ = std::make_unique<TxService>(json_rpc_service_.get(),
keyring_service_.get(), &prefs_);
CreateWallet();
AddAccount();
}
@@ -5,6 +5,7 @@
#include "brave/components/brave_wallet/browser/solana_tx_state_manager.h"
#include <memory>
#include <utility>
#include <vector>
@@ -37,10 +38,10 @@ class SolanaTxStateManagerUnitTest : public testing::Test {
protected:
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, GetPrefs()));
solana_tx_state_manager_.reset(
new SolanaTxStateManager(GetPrefs(), json_rpc_service_.get()));
json_rpc_service_ = std::make_unique<JsonRpcService>(
shared_url_loader_factory_, GetPrefs());
solana_tx_state_manager_ = std::make_unique<SolanaTxStateManager>(
GetPrefs(), json_rpc_service_.get());
}
void SetNetwork(const std::string& chain_id) {
@@ -104,10 +104,10 @@ class SwapServiceUnitTest : public testing::Test {
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
swap_service_.reset(
new SwapService(shared_url_loader_factory_, json_rpc_service_.get()));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
swap_service_ = std::make_unique<SwapService>(shared_url_loader_factory_,
json_rpc_service_.get());
}
~SwapServiceUnitTest() override = default;
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "brave/components/brave_wallet/browser/tx_state_manager.h"
#include "base/run_loop.h"
@@ -80,13 +82,13 @@ class TxStateManagerUnitTest : public testing::Test {
protected:
void SetUp() override {
brave_wallet::RegisterProfilePrefs(prefs_.registry());
json_rpc_service_.reset(
new JsonRpcService(shared_url_loader_factory_, &prefs_));
json_rpc_service_ =
std::make_unique<JsonRpcService>(shared_url_loader_factory_, &prefs_);
// The only different between each coin type's tx state manager in these
// base functions are their pref paths, so here we just use
// EthTxStateManager to test common methods in TxStateManager.
tx_state_manager_.reset(
new EthTxStateManager(&prefs_, json_rpc_service_.get()));
tx_state_manager_ =
std::make_unique<EthTxStateManager>(&prefs_, json_rpc_service_.get());
}
void SetNetwork(const std::string& chain_id, mojom::CoinType coin) {
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/feature_list.h"
#include "base/path_service.h"
#include "brave/browser/brave_content_browser_client.h"
@@ -97,9 +99,9 @@ class BraveContentSettingsAgentImplBrowserTest : public InProcessBrowserTest {
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
content_client_.reset(new ChromeContentClient);
content_client_ = std::make_unique<ChromeContentClient>();
content::SetContentClient(content_client_.get());
browser_content_client_.reset(new BraveContentBrowserClient());
browser_content_client_ = std::make_unique<BraveContentBrowserClient>();
content::SetBrowserClientForTesting(browser_content_client_.get());
host_resolver()->AddRule("*", "127.0.0.1");
@@ -5,6 +5,7 @@
#include "brave/components/cosmetic_filters/renderer/cosmetic_filters_js_render_frame_observer.h"
#include <memory>
#include <utility>
#include "base/bind.h"
@@ -73,7 +74,7 @@ void CosmeticFiltersJsRenderFrameObserver::DidStartNavigation(
void CosmeticFiltersJsRenderFrameObserver::ReadyToCommitNavigation(
blink::WebDocumentLoader* document_loader) {
ready_.reset(new base::OneShotEvent());
ready_ = std::make_unique<base::OneShotEvent>();
// invalidate weak pointers on navigation so we don't get callbacks from the
// previous url load
weak_factory_.InvalidateWeakPtrs();
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/path_service.h"
#include "brave/browser/crypto_dot_com/crypto_dot_com_service_factory.h"
#include "brave/components/constants/brave_paths.h"
@@ -180,8 +182,8 @@ class CryptoDotComAPIBrowserTest : public InProcessBrowserTest {
void ResetHTTPSServer(
const net::EmbeddedTestServer::HandleRequestCallback& callback) {
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(callback);
ASSERT_TRUE(https_server_->Start());
@@ -201,7 +203,7 @@ class CryptoDotComAPIBrowserTest : public InProcessBrowserTest {
expected_ticker_info_ = info;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -219,7 +221,7 @@ class CryptoDotComAPIBrowserTest : public InProcessBrowserTest {
expected_chart_data_ = data;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -237,7 +239,7 @@ class CryptoDotComAPIBrowserTest : public InProcessBrowserTest {
expected_pairs_ = pairs;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -255,7 +257,7 @@ class CryptoDotComAPIBrowserTest : public InProcessBrowserTest {
expected_rankings_ = rankings;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include <string>
#include "base/bind.h"
@@ -76,8 +77,8 @@ class DeAmpBrowserTest : public InProcessBrowserTest {
void SetUpOnMainThread() override {
mock_cert_verifier_.mock_cert_verifier()->set_default_result(net::OK);
host_resolver()->AddRule("*", "127.0.0.1");
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
prefs_ = browser()->profile()->GetPrefs();
content::SetupCrossSiteRedirector(https_server_.get());
@@ -240,8 +241,8 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, SimpleDeAmp) {
EXPECT_EQ(web_contents()->GetLastCommittedURL(), simple);
// Now go to an AMP page
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->RegisterRequestHandler(
base::BindRepeating(HandleRequest, kTestCanonicalPage, GetTestAmpBody()));
ASSERT_TRUE(https_server_->Start());
@@ -269,8 +270,8 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, CanonicalLinkOutsideChunkWithinMax) {
EXPECT_EQ(web_contents()->GetLastCommittedURL(), simple);
// Now go to an AMP page
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->RegisterRequestHandler(
base::BindRepeating(HandleRequest, kTestCanonicalPage, amp_body_large));
ASSERT_TRUE(https_server_->Start());
@@ -299,8 +300,8 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, CanonicalLinkOutsideChunkOutsideMax) {
EXPECT_EQ(web_contents()->GetLastCommittedURL(), simple);
// Now go to an AMP page
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->RegisterRequestHandler(
base::BindRepeating(HandleRequest, kTestCanonicalPage, amp_body_large));
ASSERT_TRUE(https_server_->Start());
@@ -439,8 +440,8 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, AmpURLNotStoredInHistory) {
NavigateToURLAndWaitForRedirects(simple, simple);
// Now go to an AMP page
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->RegisterRequestHandler(
base::BindRepeating(HandleRequest, kTestCanonicalPage, GetTestAmpBody()));
ASSERT_TRUE(https_server_->Start());
@@ -452,8 +453,8 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, AmpURLNotStoredInHistory) {
// Go to another AMP page
const std::string another_canonical_page = "/simple_canonical2.html";
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->RegisterRequestHandler(base::BindRepeating(
HandleRequest, another_canonical_page, GetTestAmpBody()));
ASSERT_TRUE(https_server_->Start());
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/path_service.h"
#include "brave/browser/gemini/gemini_service_factory.h"
#include "brave/components/constants/brave_paths.h"
@@ -163,8 +165,8 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
void ResetHTTPSServer(
const net::EmbeddedTestServer::HandleRequestCallback& callback) {
https_server_.reset(new net::EmbeddedTestServer(
net::test_server::EmbeddedTestServer::TYPE_HTTPS));
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(callback);
ASSERT_TRUE(https_server_->Start());
@@ -193,7 +195,7 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -202,7 +204,7 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -235,7 +237,7 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
expected_quantity_ = expected_quantity;
expected_total_price_ = expected_total_price;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -257,7 +259,7 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
}
expected_balances_ = expected_balances;
expected_success_ = expected_success;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -273,7 +275,7 @@ class GeminiAPIBrowserTest : public InProcessBrowserTest {
return;
}
expected_address_ = expected_address;
wait_for_request_.reset(new base::RunLoop);
wait_for_request_ = std::make_unique<base::RunLoop>();
wait_for_request_->Run();
}
@@ -5,6 +5,7 @@
#include "brave/components/ipfs/import/ipfs_import_worker_base.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
@@ -67,7 +68,7 @@ IpfsImportWorkerBase::IpfsImportWorkerBase(
key_to_publish_(key),
weak_factory_(this) {
DCHECK(endpoint.is_valid());
data_.reset(new ipfs::ImportedData());
data_ = std::make_unique<ipfs::ImportedData>();
}
IpfsImportWorkerBase::~IpfsImportWorkerBase() = default;
+1 -1
View File
@@ -23,7 +23,7 @@ class IPFSP3ATest : public testing::Test {
void SetUp() override {
auto* registry = pref_service_.registry();
IpfsService::RegisterProfilePrefs(registry);
histogram_tester_.reset(new base::HistogramTester);
histogram_tester_ = std::make_unique<base::HistogramTester>();
}
PrefService* GetPrefs() { return &pref_service_; }
@@ -6,6 +6,7 @@
#include "brave/components/ntp_background_images/browser/ntp_background_images_service.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
@@ -211,8 +212,8 @@ void NTPBackgroundImagesService::CheckSuperReferralComponent() {
prefs::kNewTabPageCachedSuperReferralComponentData);
if (!cached_data.empty()) {
DVLOG(2) << __func__ << ": Initialized SR Data from cache.";
sr_images_data_.reset(
new NTPSponsoredImagesData(cached_data, sr_installed_dir_));
sr_images_data_ = std::make_unique<NTPSponsoredImagesData>(
cached_data, sr_installed_dir_);
}
return;
}
@@ -468,8 +469,8 @@ void NTPBackgroundImagesService::OnComponentReady(
void NTPBackgroundImagesService::OnGetComponentJsonData(
const std::string& json_string) {
bi_images_data_.reset(
new NTPBackgroundImagesData(json_string, bi_installed_dir_));
bi_images_data_ =
std::make_unique<NTPBackgroundImagesData>(json_string, bi_installed_dir_);
for (auto& observer : observer_list_) {
observer.OnUpdated(bi_images_data_.get());
@@ -502,8 +503,8 @@ void NTPBackgroundImagesService::OnGetSponsoredComponentJsonData(
local_pref_->SetBoolean(
prefs::kNewTabPageGetInitialSRComponentInProgress,
false);
sr_images_data_.reset(
new NTPSponsoredImagesData(json_string, sr_installed_dir_));
sr_images_data_ = std::make_unique<NTPSponsoredImagesData>(
json_string, sr_installed_dir_);
// |initial_sr_component_info_| has proper data only for initial component
// downloading. After that, it's empty. In test, it's also empty.
if (initial_sr_component_info_.is_dict()) {
@@ -513,8 +514,8 @@ void NTPBackgroundImagesService::OnGetSponsoredComponentJsonData(
local_pref_->SetString(prefs::kNewTabPageCachedSuperReferralComponentData,
json_string);
} else {
si_images_data_.reset(
new NTPSponsoredImagesData(json_string, si_installed_dir_));
si_images_data_ = std::make_unique<NTPSponsoredImagesData>(
json_string, si_installed_dir_);
}
if (is_super_referral && !sr_images_data_->IsValid()) {
@@ -234,7 +234,8 @@ class NTPBackgroundImagesServiceTest : public testing::Test {
}
void Init() {
service_.reset(new TestNTPBackgroundImagesService(nullptr, &pref_service_));
service_ = std::make_unique<TestNTPBackgroundImagesService>(nullptr,
&pref_service_);
service_->Init();
}
@@ -28,9 +28,10 @@ class NTPBackgroundImagesSourceTest : public testing::Test {
auto* registry = local_pref_.registry();
NTPBackgroundImagesService::RegisterLocalStatePrefs(registry);
brave::RegisterPrefsForBraveReferralsService(registry);
service_.reset(new NTPBackgroundImagesService(nullptr, &local_pref_));
source_.reset(new NTPSponsoredImagesSource(service_.get()));
bg_source_.reset(new NTPBackgroundImagesSource(service_.get()));
service_ =
std::make_unique<NTPBackgroundImagesService>(nullptr, &local_pref_);
source_ = std::make_unique<NTPSponsoredImagesSource>(service_.get());
bg_source_ = std::make_unique<NTPBackgroundImagesSource>(service_.get());
local_pref_.Set(prefs::kNewTabPageCachedSuperReferralComponentInfo,
base::Value(base::Value::Type::DICTIONARY));
}
@@ -264,14 +264,14 @@ TEST_F(NTPBackgroundImagesViewCounterTest, BINotActiveInitially) {
TEST_F(NTPBackgroundImagesViewCounterTest, SINotActiveWithBadData) {
// Set some bad data explicitly.
service_->si_images_data_.reset(new NTPSponsoredImagesData);
service_->sr_images_data_.reset(new NTPSponsoredImagesData);
service_->si_images_data_ = std::make_unique<NTPSponsoredImagesData>();
service_->sr_images_data_ = std::make_unique<NTPSponsoredImagesData>();
EXPECT_FALSE(view_counter_->IsBrandedWallpaperActive());
}
TEST_F(NTPBackgroundImagesViewCounterTest, BINotActiveWithBadData) {
// Set some bad data explicitly.
service_->bi_images_data_.reset(new NTPBackgroundImagesData);
service_->bi_images_data_ = std::make_unique<NTPBackgroundImagesData>();
EXPECT_FALSE(view_counter_->IsBackgroundWallpaperActive());
}
@@ -382,7 +382,7 @@ TEST_F(NTPBackgroundImagesViewCounterTest, ModelTest) {
view_counter_->RegisterPageView();
EXPECT_EQ(expected_count, view_counter_->model_.count_to_branded_wallpaper_);
service_->sr_images_data_.reset(new NTPSponsoredImagesData);
service_->sr_images_data_ = std::make_unique<NTPSponsoredImagesData>();
view_counter_->OnSuperReferralEnded();
EXPECT_FALSE(view_counter_->model_.always_show_branded_wallpaper_);
EXPECT_EQ(expected_count, view_counter_->model_.count_to_branded_wallpaper_);
@@ -30,9 +30,7 @@ class NTPWidgetUtilsRegionUtilTest : public testing::Test {
}
protected:
void SetUp() override {
profile_.reset(new TestingProfile());
}
void SetUp() override { profile_ = std::make_unique<TestingProfile>(); }
void TearDown() override {
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
+1 -1
View File
@@ -136,7 +136,7 @@ void BraveP3AService::Init(
InitMessageMeta();
// Init log store.
log_store_.reset(new BraveP3ALogStore(this, local_state_));
log_store_ = std::make_unique<BraveP3ALogStore>(this, local_state_);
log_store_->LoadPersistedUnsentLogs();
// Store values that were recorded between calling constructor and |Init()|.
for (const auto& entry : histogram_values_) {
@@ -30,7 +30,7 @@ class SidebarServiceTest : public testing::Test,
void TearDown() override { service_->RemoveObserver(this); }
void InitService() {
service_.reset(new SidebarService(&prefs_));
service_ = std::make_unique<SidebarService>(&prefs_);
service_->AddObserver(this);
}
+10 -8
View File
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include "brave/components/tor/tor_control.h"
#include "base/callback_helpers.h"
@@ -123,7 +125,7 @@ TEST(TorControlTest, ReadLine) {
},
std::move(control)));
control.reset(new TorControl(delegate.AsWeakPtr(), io_task_runner));
control = std::make_unique<TorControl>(delegate.AsWeakPtr(), io_task_runner);
EXPECT_CALL(delegate, OnTorRawMid("250", "SOCKSPORT=9050")).Times(1);
EXPECT_CALL(delegate, OnTorRawEnd("250", "OK")).Times(1);
io_task_runner->PostTask(
@@ -135,7 +137,7 @@ TEST(TorControlTest, ReadLine) {
std::move(control)));
// Test Async:
control.reset(new TorControl(delegate.AsWeakPtr(), io_task_runner));
control = std::make_unique<TorControl>(delegate.AsWeakPtr(), io_task_runner);
using tor::TorControlEvent;
EXPECT_CALL(delegate, OnTorRawAsync("650", "FAKEVENT WHAT")).Times(1);
EXPECT_CALL(delegate, OnTorRawAsync("650", "NETWORK_LIVENESS UP")).Times(1);
@@ -212,7 +214,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
EXPECT_TRUE(is_called);
is_called = false;
established.reset(new std::string("1"));
established = std::make_unique<std::string>("1");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
@@ -227,7 +229,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
// --- Error cases ---
is_called = false;
established.reset(new std::string("iambrave"));
established = std::make_unique<std::string>("iambrave");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
@@ -241,7 +243,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
EXPECT_TRUE(is_called);
is_called = false;
established.reset(new std::string(""));
established = std::make_unique<std::string>("");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
@@ -255,7 +257,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
EXPECT_TRUE(is_called);
is_called = false;
established.reset(new std::string("1"));
established = std::make_unique<std::string>("1");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
@@ -269,7 +271,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
EXPECT_TRUE(is_called);
is_called = false;
established.reset(new std::string("1"));
established = std::make_unique<std::string>("1");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
@@ -283,7 +285,7 @@ TEST(TorControlTest, GetCircuitEstablishedDone) {
EXPECT_TRUE(is_called);
is_called = false;
established.reset(new std::string("1"));
established = std::make_unique<std::string>("1");
control->GetCircuitEstablishedDone(
std::move(established),
base::BindOnce(
+25 -24
View File
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include <utility>
#include "base/base_paths.h"
@@ -95,21 +96,21 @@ TEST_F(TorFileWatcherTest, EatControlCookie) {
EXPECT_EQ(time.ToJsTime(), 0u);
// control_auth_cookie is a folder
tor_file_watcher.reset(new TorFileWatcher(test_data_dir()));
tor_file_watcher = std::make_unique<TorFileWatcher>(test_data_dir());
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlCookie(cookie, time));
EXPECT_EQ(cookie.size(), 0u);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII("empty_auth_cookies")));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII("empty_auth_cookies"));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlCookie(cookie, time));
EXPECT_EQ(cookie.size(), 0u);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII("auth_cookies_too_long")));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII("auth_cookies_too_long"));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlCookie(cookie, time));
EXPECT_EQ(cookie.size(), 0u);
@@ -121,8 +122,8 @@ TEST_F(TorFileWatcherTest, EatControlCookie) {
0x90, 0x94, 0x44, 0xa4, 0x3d, 0x30, 0xd5, 0xa9, 0x19, 0xef};
unsigned int expected_auth_cookie_len = 32;
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII("normal_auth_cookies")));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII("normal_auth_cookies"));
tor_file_watcher->polling_ = true;
EXPECT_TRUE(tor_file_watcher->EatControlCookie(cookie, time));
EXPECT_EQ(std::memcmp(cookie.data(), expected_auth_cookie,
@@ -145,57 +146,57 @@ TEST_F(TorFileWatcherTest, EatControlPort) {
EXPECT_EQ(time.ToJsTime(), 0u);
// controlport is a folder
tor_file_watcher.reset(new TorFileWatcher(test_data_dir()));
tor_file_watcher = std::make_unique<TorFileWatcher>(test_data_dir());
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII("empty_controlport")));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII("empty_controlport"));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kInvalidControlport)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kInvalidControlport));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(new TorFileWatcher(
test_data_dir().AppendASCII(kValidControlportNotLocalhost)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kValidControlportNotLocalhost));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kControlportMax)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kControlportMax));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kControlportTooLong)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kControlportTooLong));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, -1);
EXPECT_EQ(time.ToJsTime(), 0u);
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kControlportOverflow)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kControlportOverflow));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, 65536);
EXPECT_EQ(time.ToJsTime(), 0u);
port = -1;
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kInvalidControlPortEnd)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kInvalidControlPortEnd));
tor_file_watcher->polling_ = true;
EXPECT_FALSE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, 0);
@@ -204,8 +205,8 @@ TEST_F(TorFileWatcherTest, EatControlPort) {
port = -1;
time = base::Time();
tor_file_watcher.reset(
new TorFileWatcher(test_data_dir().AppendASCII(kNormalControlport)));
tor_file_watcher = std::make_unique<TorFileWatcher>(
test_data_dir().AppendASCII(kNormalControlport));
tor_file_watcher->polling_ = true;
EXPECT_TRUE(tor_file_watcher->EatControlPort(port, time));
EXPECT_EQ(port, 5566);
@@ -5,6 +5,7 @@
#include "brave/renderer/brave_wallet/brave_wallet_render_frame_observer.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
@@ -65,8 +66,8 @@ void BraveWalletRenderFrameObserver::DidCreateScriptContext(
render_frame()->GetWebFrame()->MainWorldScriptContext(),
"ethereum")) {
if (!js_ethereum_provider_) {
js_ethereum_provider_.reset(new JSEthereumProvider(
render_frame(), dynamic_params.brave_use_native_ethereum_wallet));
js_ethereum_provider_ = std::make_unique<JSEthereumProvider>(
render_frame(), dynamic_params.brave_use_native_ethereum_wallet);
}
js_ethereum_provider_->AddJavaScriptObjectToFrame(
context, dynamic_params.allow_overwrite_window_ethereum_provider,
@@ -5,6 +5,7 @@
#include "brave/utility/importer/brave_profile_import_impl.h"
#include <memory>
#include <utility>
#include "base/bind.h"
@@ -85,7 +86,7 @@ void BraveProfileImportImpl::StartImport(
items_to_import_ = items;
// Create worker thread in which importer runs.
import_thread_.reset(new base::Thread("import_thread"));
import_thread_ = std::make_unique<base::Thread>("import_thread");
#if BUILDFLAG(IS_WIN)
import_thread_->init_com_with_mta(false);
#endif
@@ -5,6 +5,7 @@
#include "bat/ledger/public/ledger_database.h"
#include <memory>
#include <utility>
#include <vector>
@@ -224,9 +225,9 @@ mojom::DBCommandResponse::Status LedgerDatabase::Initialize(
}
initialized_ = true;
memory_pressure_listener_.reset(new base::MemoryPressureListener(
memory_pressure_listener_ = std::make_unique<base::MemoryPressureListener>(
FROM_HERE, base::BindRepeating(&LedgerDatabase::OnMemoryPressure,
base::Unretained(this))));
base::Unretained(this)));
} else {
table_version = meta_table_.GetVersionNumber();
}
@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <memory>
#include <utility>
#include "bat/ledger/internal/common/time_util.h"
@@ -49,7 +50,7 @@ void LegacyBatState::OnLoad(ledger::type::Result result,
return;
}
state_.reset(new ledger::ClientProperties(state));
state_ = std::make_unique<ledger::ClientProperties>(state);
// fix timestamp ms to s conversion
if (std::to_string(state_->reconcile_timestamp).length() > 10) {
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <memory>
#include <utility>
#include "bat/ledger/internal/ledger_impl.h"
@@ -61,7 +62,7 @@ void LegacyPublisherState::OnLoad(ledger::type::Result result,
return;
}
state_.reset(new ledger::PublisherSettingsProperties(state));
state_ = std::make_unique<ledger::PublisherSettingsProperties>(state);
callback(ledger::type::Result::LEDGER_OK);
}