0

Apply modernize-make-unique to remaining files

This intends to cover directories and individual files where changes
weren't large enough to warrant splitting out to a separate change.

This is a large-scale change: go/chromium-modernize-make-unique

Bug: 1194272
Change-Id: Ia50424ec4b7f998e65dee5071926332ffcce7a94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2803041
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#869273}
This commit is contained in:
Peter Boström
2021-04-05 21:06:12 +00:00
committed by Chromium LUCI CQ
parent 958db01bfc
commit fb60ea0a4d
111 changed files with 474 additions and 353 deletions
apps
courgette
crypto
device
gin
google_apis
headless
ipc
jingle
mojo
ppapi
services
sql
storage/browser
ui
url

@ -414,7 +414,7 @@ void LaunchPlatformAppWithCommandLineAndLaunchId(
std::unique_ptr<app_runtime::LaunchData> launch_data =
std::make_unique<app_runtime::LaunchData>();
if (!launch_id.empty())
launch_data->id.reset(new std::string(launch_id));
launch_data->id = std::make_unique<std::string>(launch_id);
AppRuntimeEventRouter::DispatchOnLaunchedEvent(context, app, source,
std::move(launch_data));
return;

@ -6,6 +6,8 @@
#include <stdarg.h>
#include <memory>
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
@ -124,7 +126,7 @@ void CourgetteFlow::CreateEncodedProgramFromDisassemblerAndAssemblyProgram(
if (failed())
return;
Data* d = data(group);
d->encoded.reset(new EncodedProgram());
d->encoded = std::make_unique<EncodedProgram>();
if (!check(d->disassembler->DisassembleAndEncode(d->program.get(),
d->encoded.get()))) {
setMessage("Cannot disassemble to form EncodedProgram for %s.",

@ -142,7 +142,7 @@ Status EnsemblePatchApplication::ReadInitialParameters(
case EXE_WIN_32_X86: // Fall through.
case EXE_ELF_32_X86:
case EXE_WIN_32_X64:
patcher.reset(new PatcherX86_32(base_region_));
patcher = std::make_unique<PatcherX86_32>(base_region_);
break;
default:
return C_BAD_ENSEMBLE_HEADER;

@ -4,6 +4,8 @@
#include "courgette/program_detector.h"
#include <memory>
#include "courgette/disassembler.h"
#include "courgette/disassembler_elf_32_x86.h"
#include "courgette/disassembler_win32_x64.h"
@ -16,17 +18,17 @@ std::unique_ptr<Disassembler> DetectDisassembler(const uint8_t* buffer,
std::unique_ptr<Disassembler> disassembler;
if (DisassemblerWin32X86::QuickDetect(buffer, length)) {
disassembler.reset(new DisassemblerWin32X86(buffer, length));
disassembler = std::make_unique<DisassemblerWin32X86>(buffer, length);
if (disassembler->ParseHeader())
return disassembler;
}
if (DisassemblerWin32X64::QuickDetect(buffer, length)) {
disassembler.reset(new DisassemblerWin32X64(buffer, length));
disassembler = std::make_unique<DisassemblerWin32X64>(buffer, length);
if (disassembler->ParseHeader())
return disassembler;
}
if (DisassemblerElf32X86::QuickDetect(buffer, length)) {
disassembler.reset(new DisassemblerElf32X86(buffer, length));
disassembler = std::make_unique<DisassemblerElf32X86>(buffer, length);
if (disassembler->ParseHeader())
return disassembler;
}

@ -4,6 +4,8 @@
#include "crypto/signature_verifier.h"
#include <memory>
#include "base/check_op.h"
#include "crypto/openssl_util.h"
#include "third_party/boringssl/src/include/openssl/bytestring.h"
@ -49,7 +51,7 @@ bool SignatureVerifier::VerifyInit(SignatureAlgorithm signature_algorithm,
if (verify_context_)
return false;
verify_context_.reset(new VerifyContext);
verify_context_ = std::make_unique<VerifyContext>();
signature_.assign(signature.data(), signature.data() + signature.size());
CBS cbs;

@ -5,6 +5,7 @@
#include "device/bluetooth/bluetooth_discovery_filter.h"
#include <algorithm>
#include <memory>
#include "base/check.h"
#include "base/memory/ptr_util.h"
@ -121,7 +122,7 @@ BluetoothDiscoveryFilter::Merge(
return result;
}
result.reset(new BluetoothDiscoveryFilter(BLUETOOTH_TRANSPORT_DUAL));
result = std::make_unique<BluetoothDiscoveryFilter>(BLUETOOTH_TRANSPORT_DUAL);
if (!filter_a || !filter_b || filter_a->IsDefault() ||
filter_b->IsDefault()) {

@ -6,6 +6,8 @@
#import <CoreBluetooth/CoreBluetooth.h>
#include <memory>
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/memory/ref_counted.h"
@ -46,8 +48,8 @@ class BluetoothLowEnergyAdvertisementManagerMacTest : public testing::Test {
void OnAdvertisementRegisterError(
BluetoothAdvertisement::ErrorCode error_code) {
ASSERT_FALSE(registration_error_.get());
registration_error_.reset(
new BluetoothAdvertisement::ErrorCode(error_code));
registration_error_ =
std::make_unique<BluetoothAdvertisement::ErrorCode>(error_code);
}
void OnUnregisterSuccess() {
@ -57,7 +59,8 @@ class BluetoothLowEnergyAdvertisementManagerMacTest : public testing::Test {
void OnUnregisterError(BluetoothAdvertisement::ErrorCode error_code) {
ASSERT_FALSE(unregister_error_);
unregister_error_.reset(new BluetoothAdvertisement::ErrorCode(error_code));
unregister_error_ =
std::make_unique<BluetoothAdvertisement::ErrorCode>(error_code);
}
std::unique_ptr<BluetoothAdvertisement::Data> CreateAdvertisementData() {

@ -4,6 +4,8 @@
#include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
#include <memory>
#include "device/bluetooth/bluetooth_adapter_mac.h"
#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
@ -62,8 +64,8 @@ class BluetoothLowEnergyCentralManagerBridge {
(device::BluetoothLowEnergyDiscoveryManagerMac*)discovery_manager
andAdapter:(device::BluetoothAdapterMac*)adapter {
if ((self = [super init])) {
_bridge.reset(new device::BluetoothLowEnergyCentralManagerBridge(
discovery_manager, adapter));
_bridge = std::make_unique<device::BluetoothLowEnergyCentralManagerBridge>(
discovery_manager, adapter);
}
return self;
}

@ -4,6 +4,8 @@
#include "device/bluetooth/bluetooth_low_energy_peripheral_delegate.h"
#include <memory>
#include "device/bluetooth/bluetooth_adapter_mac.h"
#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
@ -70,7 +72,8 @@ class BluetoothLowEnergyPeripheralBridge {
- (id)initWithBluetoothLowEnergyDeviceMac:
(device::BluetoothLowEnergyDeviceMac*)device_mac {
if ((self = [super init])) {
_bridge.reset(new device::BluetoothLowEnergyPeripheralBridge(device_mac));
_bridge = std::make_unique<device::BluetoothLowEnergyPeripheralBridge>(
device_mac);
}
return self;
}

@ -4,6 +4,8 @@
#include "device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h"
#include <memory>
#include "device/bluetooth/bluetooth_adapter_mac.h"
namespace device {
@ -49,8 +51,9 @@ class BluetoothLowEnergyPeripheralManagerBridge {
advertisementManager
andAdapter:(device::BluetoothAdapterMac*)adapter {
if ((self = [super init])) {
_bridge.reset(new device::BluetoothLowEnergyPeripheralManagerBridge(
advertisementManager, adapter));
_bridge =
std::make_unique<device::BluetoothLowEnergyPeripheralManagerBridge>(
advertisementManager, adapter);
}
return self;
}

@ -547,7 +547,7 @@ void BluetoothSocketMac::OnSDPQueryComplete(
// Note: It's important to set the connect callbacks *prior* to opening the
// channel, as opening the channel can synchronously call into
// OnChannelOpenComplete().
connect_callbacks_.reset(new ConnectCallbacks());
connect_callbacks_ = std::make_unique<ConnectCallbacks>();
connect_callbacks_->success_callback = std::move(success_callback);
connect_callbacks_->error_callback = std::move(error_callback);
@ -661,7 +661,7 @@ void BluetoothSocketMac::Receive(
}
// Set the receive callback to use when data is received.
receive_callbacks_.reset(new ReceiveCallbacks());
receive_callbacks_ = std::make_unique<ReceiveCallbacks>();
receive_callbacks_->success_callback = std::move(success_callback);
receive_callbacks_->error_callback = std::move(error_callback);
}
@ -803,7 +803,7 @@ void BluetoothSocketMac::Accept(AcceptCompletionCallback success_callback,
return;
}
accept_request_.reset(new AcceptRequest);
accept_request_ = std::make_unique<AcceptRequest>();
accept_request_->success_callback = std::move(success_callback);
accept_request_->error_callback = std::move(error_callback);
@ -832,7 +832,7 @@ void BluetoothSocketMac::AcceptConnectionRequest() {
// Associating the socket can synchronously call into OnChannelOpenComplete().
// Make sure to first set the new socket to be connecting and hook it up to
// run the accept callback with the device object.
client_socket->connect_callbacks_.reset(new ConnectCallbacks());
client_socket->connect_callbacks_ = std::make_unique<ConnectCallbacks>();
client_socket->connect_callbacks_->success_callback = base::BindOnce(
std::move(accept_request_->success_callback), device, client_socket);
client_socket->connect_callbacks_->error_callback =

@ -4,6 +4,8 @@
#include "device/bluetooth/bluetooth_socket_thread.h"
#include <memory>
#include "base/lazy_instance.h"
#include "base/message_loop/message_pump_type.h"
#include "base/sequenced_task_runner.h"
@ -57,7 +59,7 @@ void BluetoothSocketThread::EnsureStarted() {
base::Thread::Options thread_options;
thread_options.message_pump_type = base::MessagePumpType::IO;
thread_.reset(new base::Thread("BluetoothSocketThread"));
thread_ = std::make_unique<base::Thread>("BluetoothSocketThread");
thread_->StartWithOptions(thread_options);
task_runner_ = thread_->task_runner();
}

@ -50,8 +50,8 @@ GraphicCharacters::GraphicCharacters() {
// - gc=Control (Cc)
// - gc=Surrogate (Cs)
// - gc=Unassigned (Cn)
graphic_.reset(
new icu::UnicodeSet(UNICODE_STRING_SIMPLE("[:graph:]"), graphic_status));
graphic_ = std::make_unique<icu::UnicodeSet>(
UNICODE_STRING_SIMPLE("[:graph:]"), graphic_status);
DCHECK(U_SUCCESS(graphic_status));
graphic_->freeze();

@ -7,6 +7,8 @@
#import <CoreBluetooth/CoreBluetooth.h>
#include <stdint.h>
#include <memory>
#include "base/bind.h"
#import "base/mac/foundation_util.h"
#include "base/strings/string_number_conversions.h"
@ -123,8 +125,8 @@ void BluetoothTestMac::InitWithoutDefaultAdapter() {
adapter_mac_ = adapter.get();
adapter_ = std::move(adapter);
mock_central_manager_.reset(
new ScopedMockCentralManager([[MockCentralManager alloc] init]));
mock_central_manager_ = std::make_unique<ScopedMockCentralManager>(
[[MockCentralManager alloc] init]);
[mock_central_manager_->get() setBluetoothTestMac:this];
[mock_central_manager_->get() setState:CBCentralManagerStateUnsupported];
adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get());
@ -137,8 +139,8 @@ void BluetoothTestMac::InitWithFakeAdapter() {
adapter_mac_ = adapter.get();
adapter_ = std::move(adapter);
mock_central_manager_.reset(
new ScopedMockCentralManager([[MockCentralManager alloc] init]));
mock_central_manager_ = std::make_unique<ScopedMockCentralManager>(
[[MockCentralManager alloc] init]);
mock_central_manager_->get().bluetoothTestMac = this;
[mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn];
adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get());

@ -5,6 +5,7 @@
#include "device/gamepad/gamepad_pad_state_provider.h"
#include <cmath>
#include <memory>
#include "device/gamepad/gamepad_data_fetcher.h"
#include "device/gamepad/gamepad_provider.h"
@ -22,7 +23,7 @@ PadState::PadState() = default;
PadState::~PadState() = default;
GamepadPadStateProvider::GamepadPadStateProvider() {
pad_states_.reset(new PadState[Gamepads::kItemsLengthCap]);
pad_states_ = std::make_unique<PadState[]>(Gamepads::kItemsLengthCap);
for (size_t i = 0; i < Gamepads::kItemsLengthCap; ++i)
ClearPadState(pad_states_.get()[i]);

@ -7,6 +7,7 @@
#include <stddef.h>
#include <string.h>
#include <cmath>
#include <memory>
#include <utility>
#include <vector>
@ -148,7 +149,7 @@ void GamepadProvider::Initialize(std::unique_ptr<GamepadDataFetcher> fetcher) {
monitor->AddDevicesChangedObserver(this);
if (!polling_thread_)
polling_thread_.reset(new base::Thread("Gamepad polling thread"));
polling_thread_ = std::make_unique<base::Thread>("Gamepad polling thread");
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
// On Linux, the data fetcher needs to watch file descriptors, so the message
// loop needs to be a libevent loop.

@ -4,6 +4,8 @@
#include "gin/public/context_holder.h"
#include <memory>
#include "base/check.h"
#include "gin/per_context_data.h"
@ -22,7 +24,7 @@ void ContextHolder::SetContext(v8::Local<v8::Context> context) {
DCHECK(context_.IsEmpty());
context_.Reset(isolate_, context);
context_.AnnotateStrongRetainer("gin::ContextHolder::context_");
data_.reset(new PerContextData(this, context));
data_ = std::make_unique<PerContextData>(this, context);
}
} // namespace gin

@ -62,13 +62,13 @@ IsolateHolder::IsolateHolder(
CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
isolate_ = v8::Isolate::Allocate();
isolate_data_.reset(
new PerIsolateData(isolate_, allocator, access_mode_, task_runner));
isolate_data_ = std::make_unique<PerIsolateData>(isolate_, allocator,
access_mode_, task_runner);
if (isolate_creation_mode == IsolateCreationMode::kCreateSnapshot) {
// This branch is called when creating a V8 snapshot for Blink.
// Note SnapshotCreator calls isolate->Enter() in its construction.
snapshot_creator_.reset(
new v8::SnapshotCreator(isolate_, g_reference_table));
snapshot_creator_ =
std::make_unique<v8::SnapshotCreator>(isolate_, g_reference_table);
DCHECK_EQ(isolate_, snapshot_creator_->GetIsolate());
} else {
v8::Isolate::CreateParams params;
@ -91,8 +91,8 @@ IsolateHolder::IsolateHolder(
// IsolateHolder, but only the first registration will have any effect.
gin::V8SharedMemoryDumpProvider::Register();
isolate_memory_dump_provider_.reset(
new V8IsolateMemoryDumpProvider(this, task_runner));
isolate_memory_dump_provider_ =
std::make_unique<V8IsolateMemoryDumpProvider>(this, task_runner);
}
IsolateHolder::~IsolateHolder() {

@ -4,6 +4,8 @@
#include "gin/shell_runner.h"
#include <memory>
#include "gin/converter.h"
#include "gin/per_context_data.h"
#include "gin/public/context_holder.h"
@ -49,7 +51,7 @@ ShellRunner::ShellRunner(ShellRunnerDelegate* delegate, Isolate* isolate)
v8::Local<v8::Context> context =
Context::New(isolate, NULL, delegate_->GetGlobalTemplate(this, isolate));
context_holder_.reset(new ContextHolder(isolate));
context_holder_ = std::make_unique<ContextHolder>(isolate);
context_holder_->SetContext(context);
PerContextData::From(context)->set_runner(this);

@ -146,11 +146,11 @@ class BaseRequestsTest : public testing::Test {
}
void SetUp() override {
sender_.reset(new RequestSender(std::make_unique<DummyAuthService>(),
test_shared_loader_factory_,
task_environment_.GetMainThreadTaskRunner(),
std::string(), /* custom user agent */
TRAFFIC_ANNOTATION_FOR_TESTS));
sender_ = std::make_unique<RequestSender>(
std::make_unique<DummyAuthService>(), test_shared_loader_factory_,
task_environment_.GetMainThreadTaskRunner(),
std::string(), /* custom user agent */
TRAFFIC_ANNOTATION_FOR_TESTS);
test_server_.RegisterRequestHandler(base::BindRepeating(
&BaseRequestsTest::HandleRequest, base::Unretained(this)));

@ -8,6 +8,7 @@
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -200,8 +201,8 @@ class DriveApiRequestsTest : public testing::Test {
ASSERT_TRUE(test_server_.Start());
GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port());
url_generator_.reset(
new DriveApiUrlGenerator(test_base_url, test_base_url));
url_generator_ =
std::make_unique<DriveApiUrlGenerator>(test_base_url, test_base_url);
// Reset the server's expected behavior just in case.
ResetExpectedResponse();

@ -113,10 +113,10 @@ class FilesListRequestRunnerTest : public testing::Test {
base::Unretained(this), test_server_.base_url()));
ASSERT_TRUE(test_server_.Start());
runner_.reset(new FilesListRequestRunner(
runner_ = std::make_unique<FilesListRequestRunner>(
request_sender_.get(),
google_apis::DriveApiUrlGenerator(test_server_.base_url(),
test_server_.GetURL("/thumbnail/"))));
test_server_.GetURL("/thumbnail/")));
}
void TearDown() override {
@ -129,7 +129,7 @@ class FilesListRequestRunnerTest : public testing::Test {
// Called when the request is completed and no more backoff retries will
// happen.
void OnCompleted(DriveApiErrorCode error, std::unique_ptr<FileList> entry) {
response_error_.reset(new DriveApiErrorCode(error));
response_error_ = std::make_unique<DriveApiErrorCode>(error);
response_entry_ = std::move(entry);
std::move(on_completed_callback_).Run();
}
@ -139,7 +139,8 @@ class FilesListRequestRunnerTest : public testing::Test {
// request.
void SetFakeServerResponse(net::HttpStatusCode code,
const std::string& content) {
fake_server_response_.reset(new net::test_server::BasicHttpResponse);
fake_server_response_ =
std::make_unique<net::test_server::BasicHttpResponse>();
fake_server_response_->set_code(code);
fake_server_response_->set_content(content);
fake_server_response_->set_content_type("application/json");
@ -149,7 +150,7 @@ class FilesListRequestRunnerTest : public testing::Test {
std::unique_ptr<net::test_server::HttpResponse> OnFilesListRequest(
const GURL& base_url,
const net::test_server::HttpRequest& request) {
http_request_.reset(new net::test_server::HttpRequest(request));
http_request_ = std::make_unique<net::test_server::HttpRequest>(request);
return std::move(fake_server_response_);
}

@ -4,6 +4,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include "base/bind.h"
@ -98,11 +99,11 @@ void CheckinRequestTest::CreateRequest(uint64_t android_id,
chrome_build_proto_);
// Then create a request with that protobuf and specified android_id,
// security_token.
request_.reset(new CheckinRequest(
request_ = std::make_unique<CheckinRequest>(
GURL(kCheckinURL), request_info, GetBackoffPolicy(),
base::BindOnce(&CheckinRequestTest::FetcherCallback,
base::Unretained(this)),
url_loader_factory(), base::ThreadTaskRunnerHandle::Get(), &recorder_));
url_loader_factory(), base::ThreadTaskRunnerHandle::Get(), &recorder_);
// Setting android_id_ and security_token_ to blank value, not used elsewhere
// in the tests.

@ -4,6 +4,7 @@
#include "google_apis/gcm/engine/connection_factory_impl.h"
#include <memory>
#include <string>
#include "base/bind.h"
@ -392,7 +393,7 @@ void ConnectionFactoryImpl::InitHandler(
std::unique_ptr<net::BackoffEntry> ConnectionFactoryImpl::CreateBackoffEntry(
const net::BackoffEntry::Policy* const policy) {
return std::unique_ptr<net::BackoffEntry>(new net::BackoffEntry(policy));
return std::make_unique<net::BackoffEntry>(policy);
}
std::unique_ptr<ConnectionHandler>

@ -359,7 +359,7 @@ ConnectionFactoryImplTest::~ConnectionFactoryImplTest() {}
void ConnectionFactoryImplTest::WaitForConnections() {
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
void ConnectionFactoryImplTest::ConnectionsComplete() {

@ -4,6 +4,7 @@
#include "google_apis/gcm/engine/connection_handler_impl.h"
#include <memory>
#include <utility>
#include "base/bind.h"
@ -80,8 +81,9 @@ void ConnectionHandlerImpl::Init(
handshake_complete_ = false;
message_tag_ = 0;
message_size_ = 0;
input_stream_.reset(new SocketInputStream(std::move(receive_stream)));
output_stream_.reset(new SocketOutputStream(std::move(send_stream)));
input_stream_ =
std::make_unique<SocketInputStream>(std::move(receive_stream));
output_stream_ = std::make_unique<SocketOutputStream>(std::move(send_stream));
Login(login_request);
}

@ -4,6 +4,8 @@
#include "google_apis/gcm/engine/fake_connection_factory.h"
#include <memory>
#include "google_apis/gcm/engine/fake_connection_handler.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "mojo/public/cpp/system/data_pipe.h"
@ -26,8 +28,8 @@ void FakeConnectionFactory::Initialize(
const ConnectionHandler::ProtoReceivedCallback& read_callback,
const ConnectionHandler::ProtoSentCallback& write_callback) {
request_builder_ = request_builder;
connection_handler_.reset(new FakeConnectionHandler(read_callback,
write_callback));
connection_handler_ =
std::make_unique<FakeConnectionHandler>(read_callback, write_callback);
}
ConnectionHandler* FakeConnectionFactory::GetConnectionHandler() const {

@ -197,7 +197,7 @@ MCSClientTest::MCSClientTest()
restored_security_token_(0),
message_send_status_(MCSClient::SENT) {
EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
// Advance the clock to a non-zero time.
clock_.Advance(base::TimeDelta::FromSeconds(1));
@ -216,14 +216,14 @@ void MCSClientTest::TearDown() {
}
void MCSClientTest::BuildMCSClient() {
gcm_store_.reset(
new GCMStoreImpl(temp_directory_.GetPath(),
/*remove_account_mappings_with_email_key=*/true,
task_environment_.GetMainThreadTaskRunner(),
base::WrapUnique<Encryptor>(new FakeEncryptor)));
mcs_client_.reset(
new TestMCSClient(&clock_, &connection_factory_, gcm_store_.get(),
base::ThreadTaskRunnerHandle::Get(), &recorder_));
gcm_store_ = std::make_unique<GCMStoreImpl>(
temp_directory_.GetPath(),
/*remove_account_mappings_with_email_key=*/true,
task_environment_.GetMainThreadTaskRunner(),
base::WrapUnique<Encryptor>(new FakeEncryptor));
mcs_client_ = std::make_unique<TestMCSClient>(
&clock_, &connection_factory_, gcm_store_.get(),
base::ThreadTaskRunnerHandle::Get(), &recorder_);
}
void MCSClientTest::InitializeClient() {
@ -238,7 +238,7 @@ void MCSClientTest::InitializeClient() {
base::BindRepeating(&MCSClientTest::MessageSentCallback,
base::Unretained(this))));
run_loop_->RunUntilIdle();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
void MCSClientTest::LoginClient(
@ -252,7 +252,7 @@ void MCSClientTest::LoginClientWithHeartbeat(
AddExpectedLoginRequest(acknowledged_ids, heartbeat_interval_ms);
mcs_client_->Login(kAndroidId, kSecurityToken);
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
void MCSClientTest::AddExpectedLoginRequest(
@ -277,7 +277,7 @@ void MCSClientTest::StoreCredentials() {
base::BindOnce(&MCSClientTest::SetDeviceCredentialsCallback,
base::Unretained(this)));
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
FakeConnectionHandler* MCSClientTest::GetFakeHandler() const {
@ -287,12 +287,12 @@ FakeConnectionHandler* MCSClientTest::GetFakeHandler() const {
void MCSClientTest::WaitForMCSEvent() {
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
void MCSClientTest::PumpLoop() {
run_loop_->RunUntilIdle();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
void MCSClientTest::ErrorCallback() {
@ -302,7 +302,7 @@ void MCSClientTest::ErrorCallback() {
}
void MCSClientTest::MessageReceivedCallback(const MCSMessage& message) {
received_message_.reset(new MCSMessage(message));
received_message_ = std::make_unique<MCSMessage>(message);
DVLOG(1) << "Message received callback invoked, killing loop.";
run_loop_->Quit();
}

@ -3,7 +3,9 @@
// found in the LICENSE file.
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
@ -101,13 +103,13 @@ void GCMRegistrationRequestTest::CreateRequest(const std::string& sender_ids) {
std::string() /* subtype */);
std::unique_ptr<GCMRegistrationRequestHandler> request_handler(
new GCMRegistrationRequestHandler(sender_ids));
request_.reset(new RegistrationRequest(
request_ = std::make_unique<RegistrationRequest>(
GURL(kRegistrationURL), request_info, std::move(request_handler),
GetBackoffPolicy(),
base::BindOnce(&RegistrationRequestTest::RegistrationCallback,
base::Unretained(this)),
max_retry_count_, url_loader_factory(),
base::ThreadTaskRunnerHandle::Get(), &recorder_, sender_ids));
base::ThreadTaskRunnerHandle::Get(), &recorder_, sender_ids);
}
TEST_F(GCMRegistrationRequestTest, RequestSuccessful) {
@ -425,13 +427,13 @@ void InstanceIDGetTokenRequestTest::CreateRequest(
std::unique_ptr<InstanceIDGetTokenRequestHandler> request_handler(
new InstanceIDGetTokenRequestHandler(instance_id, authorized_entity,
scope, kGCMVersion, time_to_live));
request_.reset(new RegistrationRequest(
request_ = std::make_unique<RegistrationRequest>(
GURL(kRegistrationURL), request_info, std::move(request_handler),
GetBackoffPolicy(),
base::BindOnce(&RegistrationRequestTest::RegistrationCallback,
base::Unretained(this)),
max_retry_count_, url_loader_factory(),
base::ThreadTaskRunnerHandle::Get(), &recorder_, authorized_entity));
base::ThreadTaskRunnerHandle::Get(), &recorder_, authorized_entity);
}
TEST_F(InstanceIDGetTokenRequestTest, RequestSuccessful) {

@ -3,7 +3,9 @@
// found in the LICENSE file.
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
@ -98,13 +100,13 @@ void GCMUnregistrationRequestTest::CreateRequest() {
std::string() /* subtype */);
std::unique_ptr<GCMUnregistrationRequestHandler> request_handler(
new GCMUnregistrationRequestHandler(kAppId));
request_.reset(new UnregistrationRequest(
request_ = std::make_unique<UnregistrationRequest>(
GURL(kRegistrationURL), request_info, std::move(request_handler),
GetBackoffPolicy(),
base::BindOnce(&UnregistrationRequestTest::UnregistrationCallback,
base::Unretained(this)),
max_retry_count_, url_loader_factory(),
base::ThreadTaskRunnerHandle::Get(), &recorder_, std::string()));
base::ThreadTaskRunnerHandle::Get(), &recorder_, std::string());
}
TEST_F(GCMUnregistrationRequestTest, RequestDataPassedToFetcher) {
@ -315,13 +317,13 @@ void InstaceIDDeleteTokenRequestTest::CreateRequest(
std::unique_ptr<InstanceIDDeleteTokenRequestHandler> request_handler(
new InstanceIDDeleteTokenRequestHandler(instance_id, authorized_entity,
scope, kGCMVersion));
request_.reset(new UnregistrationRequest(
request_ = std::make_unique<UnregistrationRequest>(
GURL(kRegistrationURL), request_info, std::move(request_handler),
GetBackoffPolicy(),
base::BindOnce(&UnregistrationRequestTest::UnregistrationCallback,
base::Unretained(this)),
max_retry_count(), url_loader_factory(),
base::ThreadTaskRunnerHandle::Get(), &recorder_, std::string()));
base::ThreadTaskRunnerHandle::Get(), &recorder_, std::string());
}
TEST_F(InstaceIDDeleteTokenRequestTest, RequestDataPassedToFetcher) {

@ -4,6 +4,7 @@
#include "headless/lib/browser/headless_devtools.h"
#include <memory>
#include <string>
#include <utility>
@ -145,7 +146,7 @@ void StartLocalDevToolsHttpHandler(HeadlessBrowserImpl* browser) {
std::unique_ptr<content::DevToolsSocketFactory> socket_factory;
const net::HostPortPair& endpoint = options->devtools_endpoint;
socket_factory.reset(new TCPEndpointServerSocketFactory(endpoint));
socket_factory = std::make_unique<TCPEndpointServerSocketFactory>(endpoint);
content::DevToolsAgentHost::StartRemoteDebuggingServer(
std::move(socket_factory),

@ -4,6 +4,8 @@
#include "headless/lib/browser/protocol/headless_handler.h"
#include <memory>
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
@ -77,7 +79,8 @@ HeadlessHandler::HeadlessHandler(HeadlessBrowserImpl* browser,
HeadlessHandler::~HeadlessHandler() {}
void HeadlessHandler::Wire(UberDispatcher* dispatcher) {
frontend_.reset(new HeadlessExperimental::Frontend(dispatcher->channel()));
frontend_ =
std::make_unique<HeadlessExperimental::Frontend>(dispatcher->channel());
HeadlessExperimental::Dispatcher::wire(dispatcher, this);
}

@ -67,22 +67,22 @@ class HeadlessBrowserContextIsolationTest
}
void RunDevTooledTest() override {
load_observer_.reset(new LoadObserver(
load_observer_ = std::make_unique<LoadObserver>(
devtools_client_.get(),
base::BindOnce(
&HeadlessBrowserContextIsolationTest::OnFirstLoadComplete,
base::Unretained(this))));
base::Unretained(this)));
devtools_client_->GetPage()->Navigate(
embedded_test_server()->GetURL("/hello.html").spec());
}
void OnFirstLoadComplete() {
EXPECT_TRUE(load_observer_->navigation_succeeded());
load_observer_.reset(new LoadObserver(
load_observer_ = std::make_unique<LoadObserver>(
devtools_client2_.get(),
base::BindOnce(
&HeadlessBrowserContextIsolationTest::OnSecondLoadComplete,
base::Unretained(this))));
base::Unretained(this)));
devtools_client2_->GetPage()->Navigate(
embedded_test_server()->GetURL("/hello.html").spec());
}

@ -42,10 +42,10 @@ class SynchronousLoadObserver {
: web_contents_(web_contents),
devtools_client_(HeadlessDevToolsClient::Create()) {
web_contents_->GetDevToolsTarget()->AttachClient(devtools_client_.get());
load_observer_.reset(new LoadObserver(
load_observer_ = std::make_unique<LoadObserver>(
devtools_client_.get(),
base::BindOnce(&HeadlessBrowserTest::FinishAsynchronousTest,
base::Unretained(browser_test))));
base::Unretained(browser_test)));
}
~SynchronousLoadObserver() {

@ -4,6 +4,8 @@
#include "headless/test/test_network_interceptor.h"
#include <memory>
#include "base/bind.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@ -166,7 +168,7 @@ TestNetworkInterceptor::Response::Response(Response&& r) = default;
TestNetworkInterceptor::Response::~Response() {}
TestNetworkInterceptor::TestNetworkInterceptor() {
impl_.reset(new Impl(weak_factory_.GetWeakPtr()));
impl_ = std::make_unique<Impl>(weak_factory_.GetWeakPtr());
interceptor_ = std::make_unique<content::URLLoaderInterceptor>(
base::BindRepeating(&TestNetworkInterceptor::Impl::RequestHandler,
base::Unretained(impl_.get())));

@ -171,8 +171,8 @@ bool ChannelMojo::Connect() {
DCHECK(!message_reader_);
sender->SetPeerPid(GetSelfPID());
message_reader_.reset(new internal::MessagePipeReader(
pipe_, std::move(sender), std::move(receiver), this));
message_reader_ = std::make_unique<internal::MessagePipeReader>(
pipe_, std::move(sender), std::move(receiver), this);
return true;
}

@ -835,7 +835,7 @@ class IPCChannelProxyMojoTest : public IPCChannelMojoTestBase {
public:
void Init(const std::string& client_name) {
IPCChannelMojoTestBase::Init(client_name);
runner_.reset(new ChannelProxyRunner(TakeHandle(), true));
runner_ = std::make_unique<ChannelProxyRunner>(TakeHandle(), true);
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
void RunProxy() {
@ -940,7 +940,7 @@ TEST_F(IPCChannelProxyMojoTest, ProxyThreadAssociatedInterface) {
class ChannelProxyClient {
public:
void Init(mojo::ScopedMessagePipeHandle handle) {
runner_.reset(new ChannelProxyRunner(std::move(handle), false));
runner_ = std::make_unique<ChannelProxyRunner>(std::move(handle), false);
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
@ -1231,7 +1231,7 @@ class SimpleTestClientImpl : public IPC::mojom::SimpleTestClient,
void set_sync_sender(IPC::Sender* sync_sender) { sync_sender_ = sync_sender; }
void WaitForValueRequest() {
run_loop_.reset(new base::RunLoop);
run_loop_ = std::make_unique<base::RunLoop>();
run_loop_->Run();
}

@ -243,12 +243,12 @@ class IPCChannelProxyTest : public IPCChannelMojoTestBase {
Init("ChannelProxyClient");
thread_.reset(new base::Thread("ChannelProxyTestServerThread"));
thread_ = std::make_unique<base::Thread>("ChannelProxyTestServerThread");
base::Thread::Options options;
options.message_pump_type = base::MessagePumpType::IO;
thread_->StartWithOptions(options);
listener_.reset(new QuitListener());
listener_ = std::make_unique<QuitListener>();
channel_proxy_ = IPC::ChannelProxy::Create(
TakeHandle().release(), IPC::Channel::MODE_SERVER, listener_.get(),
thread_->task_runner(), base::ThreadTaskRunnerHandle::Get());
@ -390,7 +390,7 @@ class IPCChannelBadMessageTest : public IPCChannelMojoTestBase {
Init("ChannelProxyClient");
listener_.reset(new QuitListener());
listener_ = std::make_unique<QuitListener>();
CreateChannel(listener_.get());
ASSERT_TRUE(ConnectChannel());
}

@ -85,7 +85,7 @@ class PerformanceChannelListener : public Listener {
std::string test_name =
base::StringPrintf("IPC_%s_Perf_%dx_%u", label_.c_str(), msg_count_,
static_cast<unsigned>(msg_size_));
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
if (sync_) {
for (; count_down_ > 0; --count_down_) {
std::string response;
@ -315,7 +315,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase {
std::string test_name =
base::StringPrintf("IPC_%s_Perf_%dx_%zu", label_.c_str(),
message_count_, payload_.size());
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
} else {
DCHECK_EQ(payload_.size(), value.size());
@ -462,7 +462,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
DCHECK(!perf_logger_.get());
std::string test_name = base::StringPrintf(
"IPC_%s_Perf_%zux_%zu", label_.c_str(), rounds_, num_interfaces_);
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
DoNextRound();
}
@ -754,7 +754,7 @@ class CallbackPerfTest : public testing::Test {
std::string test_name =
base::StringPrintf("Callback_MultiProcess_Perf_%dx_%zu",
message_count_, payload_.size());
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
} else {
DCHECK_EQ(payload_.size(), value.size());
@ -786,7 +786,7 @@ class CallbackPerfTest : public testing::Test {
std::string test_name =
base::StringPrintf("Callback_SingleThreadNoPostTask_Perf_%dx_%zu",
params[i].message_count(), payload_.size());
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
for (int j = 0; j < params[i].message_count(); ++j) {
ping.Run(payload_, j,
base::BindOnce(&CallbackPerfTest::SingleThreadPongNoPostTask,
@ -832,7 +832,7 @@ class CallbackPerfTest : public testing::Test {
std::string test_name =
base::StringPrintf("Callback_SingleThreadPostTask_Perf_%dx_%zu",
message_count_, payload_.size());
perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str()));
perf_logger_ = std::make_unique<base::PerfTimeLogger>(test_name.c_str());
} else {
DCHECK_EQ(payload_.size(), value.size());

@ -114,8 +114,8 @@ class FakeSSLClientSocketTest : public testing::Test {
void SetData(const net::MockConnect& mock_connect,
std::vector<net::MockRead>* reads,
std::vector<net::MockWrite>* writes) {
static_socket_data_provider_.reset(
new net::StaticSocketDataProvider(*reads, *writes));
static_socket_data_provider_ =
std::make_unique<net::StaticSocketDataProvider>(*reads, *writes);
static_socket_data_provider_->set_connect_data(mock_connect);
mock_client_socket_factory_.AddSocketDataProvider(
static_socket_data_provider_.get());

@ -330,12 +330,12 @@ class NetworkServiceAsyncSocketTest : public testing::Test,
test_url_request_context_.get());
}
ns_async_socket_.reset(new NetworkServiceAsyncSocket(
ns_async_socket_ = std::make_unique<NetworkServiceAsyncSocket>(
base::BindRepeating(
&NetworkServiceAsyncSocketTest::BindToProxyResolvingSocketFactory,
base::Unretained(this)),
false, /* use_fake_tls_handshake */
14, 20, TRAFFIC_ANNOTATION_FOR_TESTS));
14, 20, TRAFFIC_ANNOTATION_FOR_TESTS);
ns_async_socket_->SignalConnected.connect(
this, &NetworkServiceAsyncSocketTest::OnConnect);

@ -4,6 +4,7 @@
#include "jingle/notifier/communicator/login.h"
#include <memory>
#include <string>
#include "base/logging.h"
@ -54,7 +55,7 @@ Login::~Login() {
void Login::StartConnection() {
DVLOG(1) << "Starting connection...";
single_attempt_.reset(new SingleLoginAttempt(login_settings_, this));
single_attempt_ = std::make_unique<SingleLoginAttempt>(login_settings_, this);
}
void Login::UpdateXmppSettings(

@ -7,6 +7,7 @@
#include <stdint.h>
#include <limits>
#include <memory>
#include <string>
#include "base/logging.h"
@ -174,9 +175,9 @@ void SingleLoginAttempt::TryConnect(
jid.Str(), client_settings.auth_token(),
client_settings.token_service(),
login_settings_.auth_mechanism());
xmpp_connection_.reset(new XmppConnection(
xmpp_connection_ = std::make_unique<XmppConnection>(
client_settings, login_settings_.get_socket_factory_callback(), this,
pre_xmpp_auth, login_settings_.traffic_annotation()));
pre_xmpp_auth, login_settings_.traffic_annotation());
}
} // namespace notifier

@ -4,6 +4,8 @@
#include "jingle/notifier/listener/xmpp_push_client.h"
#include <memory>
#include "base/logging.h"
#include "jingle/notifier/base/notifier_options_util.h"
#include "jingle/notifier/listener/push_client_observer.h"
@ -128,13 +130,13 @@ void XmppPushClient::UpdateCredentials(
} else {
DVLOG(1) << "Push: Starting XMPP connection";
base_task_.reset();
login_.reset(new notifier::Login(
login_ = std::make_unique<notifier::Login>(
this, xmpp_settings_,
notifier_options_.network_config
.get_proxy_resolving_socket_factory_callback,
GetServerList(notifier_options_), notifier_options_.try_ssltcp_first,
notifier_options_.auth_mechanism, traffic_annotation,
notifier_options_.network_connection_tracker));
notifier_options_.network_connection_tracker);
login_->StartConnection();
}
}

@ -45,7 +45,7 @@ class XmppPushClientTest : public testing::Test {
~XmppPushClientTest() override {}
void SetUp() override {
xmpp_push_client_.reset(new XmppPushClient(notifier_options_));
xmpp_push_client_ = std::make_unique<XmppPushClient>(notifier_options_);
xmpp_push_client_->AddObserver(&mock_observer_);
}

@ -288,7 +288,7 @@ class ChannelMac : public Channel,
// Record the audit token of the sender. All messages received by the
// channel must be from this same sender.
auto* trailer = buffer.Object<mach_msg_audit_trailer_t>();
peer_audit_token_.reset(new audit_token_t);
peer_audit_token_ = std::make_unique<audit_token_t>();
memcpy(peer_audit_token_.get(), &trailer->msgh_audit,
sizeof(audit_token_t));

@ -7,6 +7,7 @@
#include <string.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -110,7 +111,7 @@ void RunMojoProcessErrorHandler(
} // namespace
Core::Core() {
handles_.reset(new HandleTable);
handles_ = std::make_unique<HandleTable>();
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
handles_.get(), "MojoHandleTable", nullptr);
}

@ -8,6 +8,7 @@
#include <algorithm>
#include <atomic>
#include <memory>
#include <utility>
#include <vector>
@ -683,10 +684,11 @@ int Node::OnObserveProxy(std::unique_ptr<ObserveProxyEvent> event) {
DVLOG(2) << "Delaying ObserveProxyAck to " << event->proxy_port_name()
<< "@" << event->proxy_node_name();
port->send_on_proxy_removal.reset(new std::pair<NodeName, ScopedEvent>(
event->proxy_node_name(),
std::make_unique<ObserveProxyAckEvent>(event->proxy_port_name(),
kInvalidSequenceNum)));
port->send_on_proxy_removal =
std::make_unique<std::pair<NodeName, ScopedEvent>>(
event->proxy_node_name(),
std::make_unique<ObserveProxyAckEvent>(event->proxy_port_name(),
kInvalidSequenceNum));
}
} else {
// Forward this event along to our peer. Eventually, it should find the

@ -4,6 +4,8 @@
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include <memory>
#include "base/sequenced_task_runner.h"
#include "mojo/public/cpp/bindings/lib/multiplex_router.h"
#include "mojo/public/cpp/bindings/lib/task_runner_helper.h"
@ -60,11 +62,11 @@ void AssociatedReceiverBase::BindImpl(
const char* interface_name) {
DCHECK(handle.is_valid());
endpoint_client_.reset(new InterfaceEndpointClient(
endpoint_client_ = std::make_unique<InterfaceEndpointClient>(
std::move(handle), receiver, std::move(payload_validator),
expect_sync_requests,
internal::GetTaskRunnerToUseFromUserProvidedTaskRunner(std::move(runner)),
interface_version, interface_name));
interface_version, interface_name);
}
} // namespace internal

@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "mojo/public/cpp/bindings/lib/binding_state.h"
#include <memory>
#include "mojo/public/cpp/bindings/lib/task_runner_helper.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
@ -123,10 +126,10 @@ void BindingStateBase::BindInternal(
sequenced_runner, interface_name);
router_->SetConnectionGroup(std::move(receiver_state->connection_group));
endpoint_client_.reset(new InterfaceEndpointClient(
endpoint_client_ = std::make_unique<InterfaceEndpointClient>(
router_->CreateLocalEndpointHandle(kPrimaryInterfaceId), stub,
std::move(request_validator), has_sync_methods,
std::move(sequenced_runner), interface_version, interface_name));
std::move(sequenced_runner), interface_version, interface_name);
endpoint_client_->SetIdleTrackingEnabledCallback(
base::BindOnce(&MultiplexRouter::SetConnectionGroup, router_));

@ -6,6 +6,8 @@
#include <stdint.h>
#include <memory>
#include "base/bind.h"
#include "base/check_op.h"
#include "base/compiler_specific.h"
@ -638,10 +640,10 @@ void Connector::HandleError(bool force_pipe_reset, bool force_async_handler) {
void Connector::EnsureSyncWatcherExists() {
if (sync_watcher_)
return;
sync_watcher_.reset(new SyncHandleWatcher(
sync_watcher_ = std::make_unique<SyncHandleWatcher>(
message_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE,
base::BindRepeating(&Connector::OnSyncHandleWatcherHandleReady,
base::Unretained(this))));
base::Unretained(this)));
}
} // namespace mojo

@ -4,7 +4,9 @@
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -271,10 +273,10 @@ class TestReceiver {
base::OnceClosure notify_finish) {
CHECK(task_runner()->RunsTasksInCurrentSequence());
impl0_.reset(new IntegerSenderImpl(std::move(receiver0)));
impl0_ = std::make_unique<IntegerSenderImpl>(std::move(receiver0));
impl0_->set_notify_send_method_called(base::BindRepeating(
&TestReceiver::SendMethodCalled, base::Unretained(this)));
impl1_.reset(new IntegerSenderImpl(std::move(receiver1)));
impl1_ = std::make_unique<IntegerSenderImpl>(std::move(receiver1));
impl1_->set_notify_send_method_called(base::BindRepeating(
&TestReceiver::SendMethodCalled, base::Unretained(this)));

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <utility>
#include "base/bind.h"
@ -194,7 +195,8 @@ class BindTaskRunnerTest : public testing::Test {
remote_task_runner_ = scoped_refptr<TestTaskRunner>(new TestTaskRunner);
auto receiver = remote_.BindNewPipeAndPassReceiver(remote_task_runner_);
impl_.reset(new ImplType(std::move(receiver), receiver_task_runner_));
impl_ =
std::make_unique<ImplType>(std::move(receiver), receiver_task_runner_);
}
base::test::SingleThreadTaskEnvironment task_environment_;
@ -221,9 +223,9 @@ class AssociatedBindTaskRunnerTest : public testing::Test {
auto connection_receiver = connection_remote_.BindNewPipeAndPassReceiver(
connection_remote_task_runner_);
connection_impl_.reset(new IntegerSenderConnectionImpl(
connection_impl_ = std::make_unique<IntegerSenderConnectionImpl>(
std::move(connection_receiver), connection_receiver_task_runner_,
sender_receiver_task_runner_));
sender_receiver_task_runner_);
connection_impl_->set_get_sender_notification(base::BindOnce(
&AssociatedBindTaskRunnerTest::QuitTaskRunner, base::Unretained(this)));

@ -4,6 +4,7 @@
#include "ppapi/proxy/audio_input_resource.h"
#include <memory>
#include <string>
#include "base/bind.h"
@ -183,7 +184,7 @@ void AudioInputResource::OnPluginMsgOpenReply(
void AudioInputResource::SetStreamInfo(
base::ReadOnlySharedMemoryRegion shared_memory_region,
base::SyncSocket::Handle socket_handle) {
socket_.reset(new base::CancelableSyncSocket(socket_handle));
socket_ = std::make_unique<base::CancelableSyncSocket>(socket_handle);
DCHECK(!shared_memory_mapping_.IsValid());
// Ensure that the allocated memory is enough for the audio bus and buffer
@ -232,8 +233,8 @@ void AudioInputResource::StartThread() {
return;
}
DCHECK(!audio_input_thread_.get());
audio_input_thread_.reset(new base::DelegateSimpleThread(
this, "plugin_audio_input_thread"));
audio_input_thread_ = std::make_unique<base::DelegateSimpleThread>(
this, "plugin_audio_input_thread");
audio_input_thread_->Start();
}

@ -4,6 +4,8 @@
#include "ppapi/proxy/audio_output_resource.h"
#include <memory>
#include "base/bind.h"
#include "base/check_op.h"
#include "base/numerics/safe_conversions.h"
@ -167,7 +169,7 @@ void AudioOutputResource::OnPluginMsgOpenReply(
void AudioOutputResource::SetStreamInfo(
base::UnsafeSharedMemoryRegion shared_memory_region,
base::SyncSocket::Handle socket_handle) {
socket_.reset(new base::CancelableSyncSocket(socket_handle));
socket_ = std::make_unique<base::CancelableSyncSocket>(socket_handle);
// Ensure that the allocated memory is enough for the audio bus and buffer
// parameters. Note that there might be slightly more allocated memory as
@ -209,8 +211,8 @@ void AudioOutputResource::StartThread() {
memset(client_buffer_.get(), 0, client_buffer_size_bytes_);
DCHECK(!audio_output_thread_.get());
audio_output_thread_.reset(
new base::DelegateSimpleThread(this, "plugin_audio_output_thread"));
audio_output_thread_ = std::make_unique<base::DelegateSimpleThread>(
this, "plugin_audio_output_thread");
audio_output_thread_->Start();
}

@ -6,6 +6,7 @@
#include <stddef.h>
#include <memory>
#include <tuple>
#include <utility>
#include <vector>
@ -427,11 +428,9 @@ void NaClMessageScanner::ScanUntrustedMessage(
// If the plugin is under-reporting, rewrite the message with the
// trusted value.
if (trusted_max_written_offset > file_growth.max_written_offset) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileIO_Close(
FileGrowth(trusted_max_written_offset, 0))));
*new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>(
params, PpapiHostMsg_FileIO_Close(
FileGrowth(trusted_max_written_offset, 0)));
}
break;
}
@ -455,10 +454,8 @@ void NaClMessageScanner::ScanUntrustedMessage(
if (increase <= 0)
return;
if (!it->second->Grow(increase)) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileIO_SetLength(-1)));
*new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>(
params, PpapiHostMsg_FileIO_SetLength(-1));
}
break;
}
@ -489,11 +486,9 @@ void NaClMessageScanner::ScanUntrustedMessage(
}
}
if (audit_failed) {
new_msg_ptr->reset(
new PpapiHostMsg_ResourceCall(
params,
PpapiHostMsg_FileSystem_ReserveQuota(
amount, file_growths)));
*new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>(
params,
PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths));
}
break;
}

@ -4,6 +4,8 @@
#include "ppapi/proxy/plugin_globals.h"
#include <memory>
#include "base/macros.h"
#include "base/message_loop/message_pump_type.h"
#include "base/single_thread_task_runner.h"
@ -162,7 +164,7 @@ MessageLoopShared* PluginGlobals::GetCurrentMessageLoop() {
base::TaskRunner* PluginGlobals::GetFileTaskRunner() {
if (!file_thread_.get()) {
file_thread_.reset(new base::Thread("Plugin::File"));
file_thread_ = std::make_unique<base::Thread>("Plugin::File");
base::Thread::Options options;
options.message_pump_type = base::MessagePumpType::IO;
file_thread_->StartWithOptions(options);
@ -201,8 +203,8 @@ PP_Resource PluginGlobals::CreateBrowserFont(
void PluginGlobals::SetPluginProxyDelegate(PluginProxyDelegate* delegate) {
DCHECK(delegate && !plugin_proxy_delegate_);
plugin_proxy_delegate_ = delegate;
browser_sender_.reset(
new BrowserSender(plugin_proxy_delegate_->GetBrowserSender()));
browser_sender_ = std::make_unique<BrowserSender>(
plugin_proxy_delegate_->GetBrowserSender());
}
void PluginGlobals::ResetPluginProxyDelegate() {

@ -4,6 +4,7 @@
#include "ppapi/proxy/ppapi_proxy_test.h"
#include <memory>
#include <tuple>
#include "base/bind.h"
@ -171,10 +172,8 @@ void PluginProxyTestHarness::SetUpHarness() {
resource_tracker().DidCreateInstance(pp_instance());
plugin_dispatcher_.reset(new PluginDispatcher(
&MockGetInterface,
PpapiPermissions(),
false));
plugin_dispatcher_ = std::make_unique<PluginDispatcher>(
&MockGetInterface, PpapiPermissions(), false);
plugin_dispatcher_->InitWithTestSink(&sink());
// The plugin proxy delegate is needed for
// |PluginProxyDelegate::GetBrowserSender| which is used
@ -199,10 +198,8 @@ void PluginProxyTestHarness::SetUpHarnessWithChannel(
resource_tracker().DidCreateInstance(pp_instance());
plugin_delegate_mock_.Init(ipc_task_runner, shutdown_event);
plugin_dispatcher_.reset(new PluginDispatcher(
&MockGetInterface,
PpapiPermissions(),
false));
plugin_dispatcher_ = std::make_unique<PluginDispatcher>(
&MockGetInterface, PpapiPermissions(), false);
plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_,
base::kNullProcessId,
channel_handle,
@ -228,11 +225,11 @@ void PluginProxyTestHarness::TearDownHarness() {
void PluginProxyTestHarness::CreatePluginGlobals(
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
if (globals_config_ == PER_THREAD_GLOBALS) {
plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest(),
ipc_task_runner));
plugin_globals_ = std::make_unique<PluginGlobals>(
PpapiGlobals::PerThreadForTest(), ipc_task_runner);
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
} else {
plugin_globals_.reset(new PluginGlobals(ipc_task_runner));
plugin_globals_ = std::make_unique<PluginGlobals>(ipc_task_runner);
}
}
@ -330,10 +327,10 @@ void PluginProxyMultiThreadTest::RunTest() {
main_thread_task_runner_ = PpapiGlobals::Get()->GetMainThreadMessageLoop();
ASSERT_EQ(main_thread_task_runner_.get(),
base::ThreadTaskRunnerHandle::Get().get());
nested_main_thread_message_loop_.reset(new base::RunLoop());
nested_main_thread_message_loop_ = std::make_unique<base::RunLoop>();
secondary_thread_.reset(new base::DelegateSimpleThread(
this, "PluginProxyMultiThreadTest"));
secondary_thread_ = std::make_unique<base::DelegateSimpleThread>(
this, "PluginProxyMultiThreadTest");
{
ProxyAutoLock auto_lock;
@ -432,10 +429,8 @@ void HostProxyTestHarness::SetUpHarness() {
// These must be first since the dispatcher set-up uses them.
CreateHostGlobals();
host_dispatcher_.reset(new HostDispatcher(
pp_module(),
&MockGetInterface,
PpapiPermissions::AllPermissions()));
host_dispatcher_ = std::make_unique<HostDispatcher>(
pp_module(), &MockGetInterface, PpapiPermissions::AllPermissions());
host_dispatcher_->InitWithTestSink(&sink());
HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get());
}
@ -450,10 +445,8 @@ void HostProxyTestHarness::SetUpHarnessWithChannel(
delegate_mock_.Init(ipc_task_runner, shutdown_event);
host_dispatcher_.reset(new HostDispatcher(
pp_module(),
&MockGetInterface,
PpapiPermissions::AllPermissions()));
host_dispatcher_ = std::make_unique<HostDispatcher>(
pp_module(), &MockGetInterface, PpapiPermissions::AllPermissions());
ppapi::Preferences preferences;
host_dispatcher_->InitHostWithChannel(&delegate_mock_, base::kNullProcessId,
channel_handle, is_client, preferences,
@ -468,12 +461,13 @@ void HostProxyTestHarness::TearDownHarness() {
}
void HostProxyTestHarness::CreateHostGlobals() {
disable_locking_.reset(new ProxyLock::LockingDisablerForTest);
disable_locking_ = std::make_unique<ProxyLock::LockingDisablerForTest>();
if (globals_config_ == PER_THREAD_GLOBALS) {
host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest()));
host_globals_ =
std::make_unique<TestGlobals>(PpapiGlobals::PerThreadForTest());
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
} else {
host_globals_.reset(new TestGlobals());
host_globals_ = std::make_unique<TestGlobals>();
}
}

@ -4,6 +4,8 @@
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
#include <memory>
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
@ -64,9 +66,9 @@ bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
InstanceData* data = dispatcher->GetInstanceData(host_resource().instance());
DCHECK(data);
command_buffer_.reset(new PpapiCommandBufferProxy(
command_buffer_ = std::make_unique<PpapiCommandBufferProxy>(
host_resource(), &data->flush_info, dispatcher, capabilities,
std::move(shared_state), command_buffer_id));
std::move(shared_state), command_buffer_id);
return CreateGLES2Impl(share_gles2);
}

@ -6,6 +6,7 @@
#include <stddef.h>
#include <memory>
#include <vector>
#include "base/bind.h"
@ -91,7 +92,8 @@ int32_t MessageLoopResource::AttachToCurrentThread() {
AddRef();
slot->Set(this);
single_thread_task_executor_.reset(new base::SingleThreadTaskExecutor);
single_thread_task_executor_ =
std::make_unique<base::SingleThreadTaskExecutor>();
task_runner_ = base::ThreadTaskRunnerHandle::Get();
// Post all pending work to the task executor.

@ -4,6 +4,8 @@
#include "ppapi/proxy/raw_var_data.h"
#include <memory>
#include "base/containers/stack.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
@ -685,7 +687,7 @@ bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) {
pp_resource_ = resource_var->GetPPResource();
const IPC::Message* message = resource_var->GetCreationMessage();
if (message)
creation_message_.reset(new IPC::Message(*message));
creation_message_ = std::make_unique<IPC::Message>(*message);
else
creation_message_.reset();
pending_renderer_host_id_ = resource_var->GetPendingRendererHostId();
@ -738,7 +740,7 @@ bool ResourceRawVarData::Read(PP_VarType type,
if (!iter->ReadBool(&has_creation_message))
return false;
if (has_creation_message) {
creation_message_.reset(new IPC::Message());
creation_message_ = std::make_unique<IPC::Message>();
if (!IPC::ReadParam(m, iter, creation_message_.get()))
return false;
} else {

@ -4,6 +4,7 @@
#include "ppapi/shared_impl/ppb_audio_shared.h"
#include <memory>
#include <utility>
#include "base/bind.h"
@ -101,7 +102,8 @@ void PPB_Audio_Shared::SetStreamInfo(
base::SyncSocket::ScopedHandle socket_handle,
PP_AudioSampleRate sample_rate,
int sample_frame_count) {
socket_.reset(new base::CancelableSyncSocket(std::move(socket_handle)));
socket_ =
std::make_unique<base::CancelableSyncSocket>(std::move(socket_handle));
shared_memory_size_ = media::ComputeAudioOutputBufferSize(
kAudioOutputChannels, sample_frame_count);
DCHECK_GE(shared_memory_region.GetSize(), shared_memory_size_);
@ -155,8 +157,8 @@ void PPB_Audio_Shared::StartThread() {
nacl_thread_active_ = true;
} else {
DCHECK(!audio_thread_.get());
audio_thread_.reset(
new base::DelegateSimpleThread(this, "plugin_audio_thread"));
audio_thread_ = std::make_unique<base::DelegateSimpleThread>(
this, "plugin_audio_thread");
audio_thread_->Start();
}
}

@ -4,6 +4,8 @@
#include "ppapi/shared_impl/resource_tracker.h"
#include <memory>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
@ -19,7 +21,7 @@ namespace ppapi {
ResourceTracker::ResourceTracker(ThreadMode thread_mode)
: last_resource_value_(0) {
if (thread_mode == SINGLE_THREADED)
thread_checker_.reset(new base::ThreadChecker);
thread_checker_ = std::make_unique<base::ThreadChecker>();
}
ResourceTracker::~ResourceTracker() {}

@ -4,6 +4,8 @@
#include "ppapi/shared_impl/tracked_callback.h"
#include <memory>
#include "base/bind.h"
#include "base/check.h"
#include "base/compiler_specific.h"
@ -74,7 +76,8 @@ TrackedCallback::TrackedCallback(Resource* resource,
if (is_blocking()) {
// This is a blocking completion callback, so we will need a condition
// variable for blocking & signalling the calling thread.
operation_completed_condvar_.reset(new base::ConditionVariable(&lock_));
operation_completed_condvar_ =
std::make_unique<base::ConditionVariable>(&lock_);
} else {
// It's a non-blocking callback, so we should have a MessageLoopResource
// to dispatch to. Note that we don't error check here, though. Later,

@ -7,6 +7,7 @@
#include <string.h>
#include <limits>
#include <memory>
#include "base/logging.h"
#include "base/memory/unsafe_shared_memory_region.h"
@ -26,7 +27,7 @@ VarTracker::VarInfo::VarInfo(Var* v, int input_ref_count)
VarTracker::VarTracker(ThreadMode thread_mode) : last_var_id_(0) {
if (thread_mode == SINGLE_THREADED)
thread_checker_.reset(new base::ThreadChecker);
thread_checker_ = std::make_unique<base::ThreadChecker>();
}
VarTracker::~VarTracker() {}

@ -8,6 +8,7 @@
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -268,8 +269,7 @@ void InputController::Record() {
stream_create_time_ = base::TimeTicks::Now();
audio_callback_.reset(new AudioCallback(
this));
audio_callback_ = std::make_unique<AudioCallback>(this);
stream_->Start(audio_callback_.get());
return;
}

@ -5,6 +5,7 @@
#include "services/audio/public/cpp/sounds/audio_stream_handler.h"
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
@ -191,8 +192,8 @@ AudioStreamHandler::AudioStreamHandler(
// Store the duration of the WAV data then pass the handler to |stream_|.
duration_ = wav_audio->GetDuration();
stream_.reset(new AudioStreamContainer(std::move(stream_factory_binder),
std::move(wav_audio)));
stream_ = std::make_unique<AudioStreamContainer>(
std::move(stream_factory_binder), std::move(wav_audio));
}
AudioStreamHandler::~AudioStreamHandler() {

@ -147,7 +147,7 @@ class CertNetFetcherURLLoaderTest : public PlatformTest {
void StartNetworkThread() {
// Start the network thread.
creation_thread_.reset(new base::Thread("network thread"));
creation_thread_ = std::make_unique<base::Thread>("network thread");
base::Thread::Options options(base::MessagePumpType::IO, 0);
EXPECT_TRUE(creation_thread_->StartWithOptions(options));
}

@ -136,9 +136,9 @@ class GeolocationLocationArbitratorTest : public testing::Test {
const LocationProvider::LocationProviderUpdateCallback callback =
base::BindRepeating(&MockLocationObserver::OnLocationUpdate,
base::Unretained(observer_.get()));
arbitrator_.reset(new TestingLocationArbitrator(
arbitrator_ = std::make_unique<TestingLocationArbitrator>(
callback, provider_getter, std::move(url_loader_factory),
should_use_system_location_provider));
should_use_system_location_provider);
}
// testing::Test

@ -4,6 +4,8 @@
#include "services/device/geolocation/public_ip_address_geolocator.h"
#include <memory>
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/run_loop.h"
@ -30,11 +32,11 @@ class PublicIpAddressGeolocatorTest : public testing::Test {
: task_environment_(base::test::TaskEnvironment::MainThreadType::IO),
network_connection_tracker_(
network::TestNetworkConnectionTracker::CreateInstance()) {
notifier_.reset(new PublicIpAddressLocationNotifier(
notifier_ = std::make_unique<PublicIpAddressLocationNotifier>(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_),
network::TestNetworkConnectionTracker::GetInstance(),
kTestGeolocationApiKey));
kTestGeolocationApiKey);
}
~PublicIpAddressGeolocatorTest() override {}

@ -4,6 +4,8 @@
#include "services/device/geolocation/public_ip_address_location_notifier.h"
#include <memory>
#include "base/bind.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/device/geolocation/wifi_data.h"
@ -42,8 +44,8 @@ void PublicIpAddressLocationNotifier::QueryNextPosition(
QueryNextPositionCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
network_traffic_annotation_tag_.reset(
new net::PartialNetworkTrafficAnnotationTag(tag));
network_traffic_annotation_tag_ =
std::make_unique<net::PartialNetworkTrafficAnnotationTag>(tag);
// If a network location request is in flight, wait.
if (network_location_request_) {
callbacks_.push_back(std::move(callback));

@ -4,6 +4,8 @@
#include "services/device/usb/usb_context.h"
#include <memory>
#include "base/atomicops.h"
#include "base/logging.h"
#include "base/macros.h"
@ -64,7 +66,7 @@ void UsbContext::UsbEventHandler::Stop() {
UsbContext::UsbContext(PlatformUsbContext context) : context_(context) {
// Ownership of the PlatformUsbContext is passed to the event handler thread.
event_handler_.reset(new UsbEventHandler(context_));
event_handler_ = std::make_unique<UsbEventHandler>(context_);
event_handler_->Start();
}

@ -4,6 +4,7 @@
#include "services/network/expect_ct_reporter.h"
#include <memory>
#include <string>
#include "base/base64.h"
@ -323,8 +324,8 @@ class ExpectCTReporterWaitTest : public ::testing::Test {
void SetUp() override {
// Initializes URLRequestContext after the thread is set up.
context_.reset(
new net::TestURLRequestContext(true /* delay_initialization */));
context_ = std::make_unique<net::TestURLRequestContext>(
true /* delay_initialization */);
context_->set_network_delegate(&network_delegate_);
context_->Init();
net::URLRequestFailedJob::AddUrlHandler();

@ -4,6 +4,7 @@
#include "services/network/mojo_host_resolver_impl.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
@ -115,8 +116,8 @@ class MojoHostResolverImplTest : public testing::Test {
kChromiumOrgAddress.ToString());
mock_host_resolver_.rules()->AddSimulatedFailure("failure.fail");
resolver_service_.reset(new MojoHostResolverImpl(&mock_host_resolver_,
net::NetLogWithSource()));
resolver_service_ = std::make_unique<MojoHostResolverImpl>(
&mock_host_resolver_, net::NetLogWithSource());
}
// Wait until the mock resolver has received |num| resolve requests.

@ -5,6 +5,7 @@
#include "services/network/network_change_manager.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/macros.h"
@ -68,7 +69,7 @@ class TestNetworkChangeManagerClient
void WaitForNotification(NotificationType notification_type) {
notification_type_to_wait_ = notification_type;
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
mojom::ConnectionType connection_type() const { return connection_type_; }

@ -1046,9 +1046,9 @@ void NetworkContext::SetNetworkConditions(
mojom::NetworkConditionsPtr conditions) {
std::unique_ptr<NetworkConditions> network_conditions;
if (conditions) {
network_conditions.reset(new NetworkConditions(
network_conditions = std::make_unique<NetworkConditions>(
conditions->offline, conditions->latency.InMillisecondsF(),
conditions->download_throughput, conditions->upload_throughput));
conditions->download_throughput, conditions->upload_throughput);
}
ThrottlingController::SetConditions(throttling_profile_id,
std::move(network_conditions));

@ -5,6 +5,7 @@
#include "services/network/network_quality_estimator_manager.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/macros.h"
@ -68,7 +69,7 @@ class TestNetworkQualityEstimatorManagerClient
net::EffectiveConnectionType effective_connection_type) {
run_loop_wait_effective_connection_type_ = effective_connection_type;
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
net::EffectiveConnectionType effective_connection_type() const {

@ -925,7 +925,7 @@ class NetworkServiceTestWithService : public testing::Test {
void StartLoadingURL(const ResourceRequest& request,
uint32_t process_id,
int options = mojom::kURLLoadOptionNone) {
client_.reset(new TestURLLoaderClient());
client_ = std::make_unique<TestURLLoaderClient>();
mojo::Remote<mojom::URLLoaderFactory> loader_factory;
mojom::URLLoaderFactoryParamsPtr params =
mojom::URLLoaderFactoryParams::New();
@ -1423,7 +1423,7 @@ class NetworkServiceNetworkDelegateTest : public NetworkServiceTest {
int options = mojom::kURLLoadOptionNone,
mojo::PendingRemote<mojom::URLLoaderNetworkServiceObserver>
url_loader_network_observer = mojo::NullRemote()) {
client_.reset(new TestURLLoaderClient());
client_ = std::make_unique<TestURLLoaderClient>();
mojo::Remote<mojom::URLLoaderFactory> loader_factory;
mojom::URLLoaderFactoryParamsPtr params =
mojom::URLLoaderFactoryParams::New();
@ -1447,8 +1447,8 @@ class NetworkServiceNetworkDelegateTest : public NetworkServiceTest {
protected:
void SetUp() override {
// Set up HTTPS server.
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(
&NetworkServiceNetworkDelegateTest::HandleHTTPSRequest,

@ -7,6 +7,7 @@
#include <stdint.h>
#include <list>
#include <memory>
#include <utility>
#include "base/run_loop.h"
@ -92,8 +93,8 @@ class P2PSocketTcpServerTest : public testing::Test {
mojo::PendingRemote<mojom::P2PSocket> socket;
auto socket_receiver = socket.InitWithNewPipeAndPassReceiver();
fake_client_.reset(new FakeSocketClient(
std::move(socket), socket_client.InitWithNewPipeAndPassReceiver()));
fake_client_ = std::make_unique<FakeSocketClient>(
std::move(socket), socket_client.InitWithNewPipeAndPassReceiver());
socket_ = new FakeServerSocket();
p2p_socket_ = std::make_unique<P2PSocketTcpServer>(

@ -7,6 +7,8 @@
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
@ -45,8 +47,8 @@ class P2PSocketTcpTestBase : public testing::Test {
mojo::PendingRemote<mojom::P2PSocket> socket;
auto socket_receiver = socket.InitWithNewPipeAndPassReceiver();
fake_client_.reset(new FakeSocketClient(
std::move(socket), socket_client.InitWithNewPipeAndPassReceiver()));
fake_client_ = std::make_unique<FakeSocketClient>(
std::move(socket), socket_client.InitWithNewPipeAndPassReceiver());
EXPECT_CALL(*fake_client_.get(), SocketCreated(_, _)).Times(1);

@ -4,6 +4,7 @@
#include "services/network/p2p/socket_throttler.h"
#include <memory>
#include <utility>
#include "third_party/webrtc/rtc_base/data_rate_limiter.h"
@ -23,7 +24,7 @@ P2PMessageThrottler::P2PMessageThrottler()
P2PMessageThrottler::~P2PMessageThrottler() {}
void P2PMessageThrottler::SetSendIceBandwidth(int bandwidth_kbps) {
rate_limiter_.reset(new rtc::DataRateLimiter(bandwidth_kbps, 1.0));
rate_limiter_ = std::make_unique<rtc::DataRateLimiter>(bandwidth_kbps, 1.0);
}
bool P2PMessageThrottler::DropNextPacket(size_t packet_len) {

@ -512,12 +512,13 @@ class ProxyResolverFactoryMojoTest : public testing::Test {
void SetUp() override {
mojo::PendingRemote<proxy_resolver::mojom::ProxyResolverFactory>
factory_remote;
mock_proxy_resolver_factory_.reset(new MockMojoProxyResolverFactory(
&mock_proxy_resolver_,
factory_remote.InitWithNewPipeAndPassReceiver()));
proxy_resolver_factory_mojo_.reset(
new ProxyResolverFactoryMojo(std::move(factory_remote), &host_resolver_,
base::NullCallback(), &net_log_));
mock_proxy_resolver_factory_ =
std::make_unique<MockMojoProxyResolverFactory>(
&mock_proxy_resolver_,
factory_remote.InitWithNewPipeAndPassReceiver());
proxy_resolver_factory_mojo_ = std::make_unique<ProxyResolverFactoryMojo>(
std::move(factory_remote), &host_resolver_, base::NullCallback(),
&net_log_);
}
std::unique_ptr<Request> MakeRequest(

@ -4,6 +4,8 @@
#include "services/network/public/cpp/network_connection_tracker.h"
#include <memory>
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/macros.h"
@ -115,7 +117,7 @@ class TestLeakyNetworkConnectionObserver
void WaitForNotification() {
run_loop_->Run();
run_loop_.reset(new base::RunLoop());
run_loop_ = std::make_unique<base::RunLoop>();
}
network::mojom::ConnectionType connection_type() const {

@ -188,7 +188,7 @@ class HttpServerTest : public testing::Test, public HttpServer::Delegate {
run_loop.Run();
EXPECT_EQ(net::OK, net_error);
server_.reset(new HttpServer(std::move(server_socket_), this));
server_ = std::make_unique<HttpServer>(std::move(server_socket_), this);
}
void OnConnect(int connection_id) override {

@ -1574,7 +1574,7 @@ TEST_F(ResourceSchedulerTest, NumActiveResourceSchedulerClientsUMA) {
"ResourceScheduler.ActiveSchedulerClientsCount", 1, 1);
scheduler_->OnClientDeleted(kChildId3, kRouteId3);
scheduler_->OnClientDeleted(kChildId2, kRouteId2);
histogram_tester.reset(new base::HistogramTester);
histogram_tester = std::make_unique<base::HistogramTester>();
// Test that UMA counts are recorded correctly when multiple scheduler clients
// are created in sequence. There are at most 20 active clients.
@ -1590,7 +1590,7 @@ TEST_F(ResourceSchedulerTest, NumActiveResourceSchedulerClientsUMA) {
histogram_tester->ExpectBucketCount(
"ResourceScheduler.ActiveSchedulerClientsCount", 1 + i, 1);
}
histogram_tester.reset(new base::HistogramTester);
histogram_tester = std::make_unique<base::HistogramTester>();
// Test that UMA counts are recorded correctly when a sequence of resource
// scheduler clients are deleted in sequence. Note: Create a new client
@ -1632,7 +1632,7 @@ TEST_F(ResourceSchedulerTest, NumDelayableAtStartOfNonDelayableUMA) {
histogram_tester->ExpectUniqueSample(
"ResourceScheduler.NumDelayableRequestsInFlightAtStart.NonDelayable", 0,
1);
histogram_tester.reset(new base::HistogramTester);
histogram_tester = std::make_unique<base::HistogramTester>();
// Check that nothing is recorded when delayable request is started in the
// presence of a non-delayable request.
std::unique_ptr<TestRequest> low1(

@ -73,8 +73,8 @@ class ThrottlingControllerTestHelper {
std::unique_ptr<net::HttpTransaction> network_transaction;
network_layer_.CreateTransaction(net::DEFAULT_PRIORITY,
&network_transaction);
transaction_.reset(
new ThrottlingNetworkTransaction(std::move(network_transaction)));
transaction_ = std::make_unique<ThrottlingNetworkTransaction>(
std::move(network_transaction));
}
void SetNetworkState(bool offline, double download, double upload) {
@ -90,13 +90,13 @@ class ThrottlingControllerTestHelper {
}
int Start(bool with_upload) {
request_.reset(new MockHttpRequest(mock_transaction_));
request_ = std::make_unique<MockHttpRequest>(mock_transaction_);
throttling_token_ = ScopedThrottlingToken::MaybeCreate(
net_log_with_source_.source().id, profile_id_);
if (with_upload) {
upload_data_stream_.reset(
new net::ChunkedUploadDataStream(kUploadIdentifier));
upload_data_stream_ =
std::make_unique<net::ChunkedUploadDataStream>(kUploadIdentifier);
upload_data_stream_->AppendData(kUploadData, base::size(kUploadData),
true);
request_->upload_data_stream = upload_data_stream_.get();

@ -4,6 +4,7 @@
#include "services/network/throttling/throttling_network_transaction.h"
#include <memory>
#include <utility>
#include "base/bind.h"
@ -117,11 +118,11 @@ int ThrottlingNetworkTransaction::Start(const net::HttpRequestInfo* request,
ThrottlingController::GetInterceptor(net_log.source().id);
if (interceptor) {
custom_request_.reset(new net::HttpRequestInfo(*request_));
custom_request_ = std::make_unique<net::HttpRequestInfo>(*request_);
if (request_->upload_data_stream) {
custom_upload_data_stream_.reset(
new ThrottlingUploadDataStream(request_->upload_data_stream));
custom_upload_data_stream_ = std::make_unique<ThrottlingUploadDataStream>(
request_->upload_data_stream);
custom_request_->upload_data_stream = custom_upload_data_stream_.get();
}

@ -4,6 +4,7 @@
#include "services/network/throttling/throttling_network_transaction_factory.h"
#include <memory>
#include <set>
#include <string>
#include <utility>
@ -30,8 +31,8 @@ int ThrottlingNetworkTransactionFactory::CreateTransaction(
if (rv != net::OK) {
return rv;
}
trans->reset(
new ThrottlingNetworkTransaction(std::move(network_transaction)));
*trans = std::make_unique<ThrottlingNetworkTransaction>(
std::move(network_transaction));
return net::OK;
}

@ -7,6 +7,7 @@
#include <inttypes.h>
#include <string.h>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -597,8 +598,8 @@ void WebSocket::AddChannel(
std::unique_ptr<net::WebSocketEventInterface> event_interface(
new WebSocketEventHandler(this));
channel_.reset(new net::WebSocketChannel(std::move(event_interface),
factory_->GetURLRequestContext()));
channel_ = std::make_unique<net::WebSocketChannel>(
std::move(event_interface), factory_->GetURLRequestContext());
net::HttpRequestHeaders headers_to_pass;
for (const auto& header : additional_headers) {

@ -5,7 +5,9 @@
#include "services/preferences/tracked/pref_hash_filter.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/bind.h"
@ -79,14 +81,14 @@ PrefHashFilter::PrefHashFilter(
std::unique_ptr<TrackedPreference> tracked_preference;
switch (metadata.strategy) {
case PrefTrackingStrategy::ATOMIC:
tracked_preference.reset(new TrackedAtomicPreference(
tracked_preference = std::make_unique<TrackedAtomicPreference>(
metadata.name, metadata.reporting_id, reporting_ids_count,
metadata.enforcement_level, metadata.value_type, delegate));
metadata.enforcement_level, metadata.value_type, delegate);
break;
case PrefTrackingStrategy::SPLIT:
tracked_preference.reset(new TrackedSplitPreference(
tracked_preference = std::make_unique<TrackedSplitPreference>(
metadata.name, metadata.reporting_id, reporting_ids_count,
metadata.enforcement_level, metadata.value_type, delegate));
metadata.enforcement_level, metadata.value_type, delegate);
break;
}
DCHECK(tracked_preference);

@ -580,13 +580,13 @@ class PrefHashFilterTest : public testing::TestWithParam<EnforcementLevel>,
reset_on_load_observer;
reset_on_load_observer_receivers_.Add(
this, reset_on_load_observer.InitWithNewPipeAndPassReceiver());
pref_hash_filter_.reset(new PrefHashFilter(
pref_hash_filter_ = std::make_unique<PrefHashFilter>(
std::move(temp_mock_pref_hash_store),
PrefHashFilter::StoreContentsPair(
std::move(temp_mock_external_validation_pref_hash_store),
std::move(temp_mock_external_validation_hash_store_contents)),
std::move(configuration), std::move(reset_on_load_observer),
&mock_validation_delegate_, base::size(kTestTrackedPrefs)));
&mock_validation_delegate_, base::size(kTestTrackedPrefs));
}
// Verifies whether a reset was reported by the PrefHashFiler. Also verifies

@ -153,11 +153,13 @@ class TrackedPreferencesMigrationTest : public testing::Test {
switch (store_id) {
case MOCK_UNPROTECTED_PREF_STORE:
store = unprotected_prefs_.get();
pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, false));
pref_hash_store =
std::make_unique<PrefHashStoreImpl>(kSeed, kDeviceId, false);
break;
case MOCK_PROTECTED_PREF_STORE:
store = protected_prefs_.get();
pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, true));
pref_hash_store =
std::make_unique<PrefHashStoreImpl>(kSeed, kDeviceId, true);
break;
}
DCHECK(store);

@ -6,6 +6,7 @@
#include <algorithm>
#include <cstdio>
#include <memory>
#include <utility>
#include "base/auto_reset.h"
@ -397,9 +398,9 @@ class SharedIsolateFactory {
has_initialized_v8_ = true;
}
holder_.reset(new gin::IsolateHolder(
holder_ = std::make_unique<gin::IsolateHolder>(
base::ThreadTaskRunnerHandle::Get(), gin::IsolateHolder::kUseLocker,
gin::IsolateHolder::IsolateType::kUtility));
gin::IsolateHolder::IsolateType::kUtility);
}
return holder_->isolate();

@ -5,6 +5,7 @@
#include "services/proxy_resolver/proxy_resolver_v8_tracing.h"
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
@ -978,7 +979,7 @@ void ProxyResolverV8TracingImpl::GetProxyForURL(
scoped_refptr<Job> job = new Job(job_params_.get(), std::move(bindings));
request->reset(new RequestImpl(job));
*request = std::make_unique<RequestImpl>(job);
job->StartGetProxyForURL(url, network_isolation_key, results,
std::move(callback));
@ -1023,8 +1024,8 @@ class ProxyResolverV8TracingFactoryImpl::CreateJob
base::Thread::Options options;
options.timer_slack = base::TIMER_SLACK_MAXIMUM;
CHECK(thread_->StartWithOptions(options));
job_params_.reset(
new Job::Params(thread_->task_runner(), &num_outstanding_callbacks_));
job_params_ = std::make_unique<Job::Params>(thread_->task_runner(),
&num_outstanding_callbacks_);
create_resolver_job_ = new Job(job_params_.get(), std::move(bindings));
create_resolver_job_->StartCreateV8Resolver(
pac_script, &v8_resolver_,
@ -1055,8 +1056,8 @@ class ProxyResolverV8TracingFactoryImpl::CreateJob
DCHECK(factory_);
if (error == net::OK) {
job_params_->v8_resolver = v8_resolver_.get();
resolver_out_->reset(new ProxyResolverV8TracingImpl(
std::move(thread_), std::move(v8_resolver_), std::move(job_params_)));
*resolver_out_ = std::make_unique<ProxyResolverV8TracingImpl>(
std::move(thread_), std::move(v8_resolver_), std::move(job_params_));
} else {
StopWorkerThread();
}

@ -4,6 +4,8 @@
#include "services/resource_coordinator/memory_instrumentation/coordinator_impl.h"
#include <memory>
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
@ -70,7 +72,7 @@ class CoordinatorImplTest : public testing::Test {
CoordinatorImplTest() = default;
void SetUp() override {
coordinator_.reset(new NiceMock<FakeCoordinatorImpl>);
coordinator_ = std::make_unique<NiceMock<FakeCoordinatorImpl>>();
}
void TearDown() override { coordinator_.reset(); }

@ -6,6 +6,8 @@
#import <AppKit/AppKit.h>
#include <memory>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/mac/mac_util.h"
@ -47,7 +49,7 @@ TEST_F(TextDetectionImplMacTest, ScanOnce) {
return;
}
impl_.reset(new TextDetectionImplMac);
impl_ = std::make_unique<TextDetectionImplMac>();
base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));

@ -360,7 +360,8 @@ class TracingConsumerTest : public testing::Test,
MojoResult rv = mojo::CreateDataPipe(&options, producer, consumer);
ASSERT_EQ(MOJO_RESULT_OK, rv);
threaded_service_->ReadBuffers(std::move(producer), base::OnceClosure());
drainer_.reset(new mojo::DataPipeDrainer(this, std::move(consumer)));
drainer_ =
std::make_unique<mojo::DataPipeDrainer>(this, std::move(consumer));
}
void DisableTracingAndEmitJson(base::OnceClosure write_callback,
@ -375,7 +376,8 @@ class TracingConsumerTest : public testing::Test,
threaded_service_->DisableTracingAndEmitJson(std::move(producer),
std::move(write_callback),
enable_privacy_filtering);
drainer_.reset(new mojo::DataPipeDrainer(this, std::move(consumer)));
drainer_ =
std::make_unique<mojo::DataPipeDrainer>(this, std::move(consumer));
}
perfetto::TraceConfig GetDefaultTraceConfig(

@ -417,9 +417,9 @@ class GrDirectContext* ContextProviderCommandBuffer::GrContext() {
else
gl_interface = gles2_impl_.get();
gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(
gr_context_ = std::make_unique<skia_bindings::GrContextForGLES2Interface>(
gl_interface, ContextSupport(), ContextCapabilities(),
max_resource_cache_bytes, max_glyph_cache_texture_bytes));
max_resource_cache_bytes, max_glyph_cache_texture_bytes);
cache_controller_->SetGrContext(gr_context_->get());
// If GlContext is already lost, also abandon the new GrContext.

@ -9,6 +9,8 @@
#include <stdint.h>
#include <string.h>
#include <memory>
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@ -1631,8 +1633,8 @@ bool Database::OpenInternal(const std::string& file_name,
}
DCHECK(!memory_dump_provider_);
memory_dump_provider_.reset(
new DatabaseMemoryDumpProvider(db_, histogram_tag_));
memory_dump_provider_ =
std::make_unique<DatabaseMemoryDumpProvider>(db_, histogram_tag_);
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
memory_dump_provider_.get(), "sql::Database", nullptr);

@ -79,7 +79,7 @@ BlobReader::BlobReader(const BlobDataHandle* blob_handle)
if (blob_handle->IsBroken()) {
net_error_ = ConvertBlobErrorToNetError(blob_handle->GetBlobStatus());
} else {
blob_handle_.reset(new BlobDataHandle(*blob_handle));
blob_handle_ = std::make_unique<BlobDataHandle>(*blob_handle);
}
}
}

Some files were not shown because too many files have changed in this diff Show More