chore: use std::make_unique/base::MakeRefCounted when possible (#29510)
This commit is contained in:
parent
a4decffe9a
commit
79cb5144ae
38 changed files with 106 additions and 101 deletions
|
@ -58,7 +58,7 @@
|
|||
certChain:(CFArrayRef)certChain
|
||||
secPolicy:(SecPolicyRef)secPolicy {
|
||||
if ((self = [super init])) {
|
||||
promise_.reset(new gin_helper::Promise<void>(std::move(promise)));
|
||||
promise_ = std::make_unique<gin_helper::Promise<void>>(std::move(promise));
|
||||
panel_ = panel;
|
||||
cert_ = cert;
|
||||
trust_ = trust;
|
||||
|
|
|
@ -43,8 +43,8 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
|
|||
private:
|
||||
// content::ServerSocketFactory.
|
||||
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
|
||||
std::unique_ptr<net::ServerSocket> socket(
|
||||
new net::TCPServerSocket(nullptr, net::NetLogSource()));
|
||||
auto socket =
|
||||
std::make_unique<net::TCPServerSocket>(nullptr, net::NetLogSource());
|
||||
if (socket->ListenWithAddressAndPort(address_, port_, 10) != net::OK)
|
||||
return std::unique_ptr<net::ServerSocket>();
|
||||
|
||||
|
@ -77,8 +77,7 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
|||
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<content::DevToolsSocketFactory>(
|
||||
new TCPServerSocketFactory("127.0.0.1", port));
|
||||
return std::make_unique<TCPServerSocketFactory>("127.0.0.1", port);
|
||||
}
|
||||
|
||||
const char kBrowserCloseMethod[] = "Browser.close";
|
||||
|
|
|
@ -46,12 +46,11 @@ std::unique_ptr<views::StatusIconLinux> CreateLinuxStatusIcon(
|
|||
if (AppIndicatorIcon::CouldOpen()) {
|
||||
++indicators_count;
|
||||
|
||||
return std::unique_ptr<views::StatusIconLinux>(new AppIndicatorIcon(
|
||||
return std::make_unique<AppIndicatorIcon>(
|
||||
base::StringPrintf("%s%d", id_prefix, indicators_count), image,
|
||||
tool_tip));
|
||||
tool_tip);
|
||||
} else {
|
||||
return std::unique_ptr<views::StatusIconLinux>(
|
||||
new GtkStatusIcon(image, tool_tip));
|
||||
return std::make_unique<GtkStatusIcon>(image, tool_tip);
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
|
@ -614,8 +614,7 @@ void InspectableWebContents::AddDevToolsExtensionsToClient() {
|
|||
web_contents_->GetMainFrame()->GetProcess()->GetID(),
|
||||
url::Origin::Create(extension->url()));
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> extension_info(
|
||||
new base::DictionaryValue());
|
||||
auto extension_info = std::make_unique<base::DictionaryValue>();
|
||||
extension_info->SetString("startPage", devtools_page_url.spec());
|
||||
extension_info->SetString("name", extension->name());
|
||||
extension_info->SetBoolean(
|
||||
|
|
|
@ -91,8 +91,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
|||
int routing_id,
|
||||
ui::AXMode accessibility_mode,
|
||||
base::ProcessHandle handle = base::kNullProcessHandle) {
|
||||
std::unique_ptr<base::DictionaryValue> target_data(
|
||||
new base::DictionaryValue());
|
||||
auto target_data = std::make_unique<base::DictionaryValue>();
|
||||
target_data->SetInteger(kProcessIdField, process_id);
|
||||
target_data->SetInteger(kRoutingIdField, routing_id);
|
||||
target_data->SetString(kUrlField, url.spec());
|
||||
|
@ -135,8 +134,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
|||
|
||||
std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
||||
electron::NativeWindow* window) {
|
||||
std::unique_ptr<base::DictionaryValue> target_data(
|
||||
new base::DictionaryValue());
|
||||
auto target_data = std::make_unique<base::DictionaryValue>();
|
||||
target_data->SetInteger(kSessionIdField, window->window_id());
|
||||
target_data->SetString(kNameField, window->GetTitle());
|
||||
target_data->SetString(kTypeField, kBrowser);
|
||||
|
@ -259,7 +257,7 @@ void HandleAccessibilityRequestCallback(
|
|||
// Always dump the Accessibility tree.
|
||||
data.SetString(kInternal, kOn);
|
||||
|
||||
std::unique_ptr<base::ListValue> rvh_list(new base::ListValue());
|
||||
auto rvh_list = std::make_unique<base::ListValue>();
|
||||
std::unique_ptr<content::RenderWidgetHostIterator> widgets(
|
||||
content::RenderWidgetHost::GetRenderWidgetHosts());
|
||||
|
||||
|
@ -293,7 +291,7 @@ void HandleAccessibilityRequestCallback(
|
|||
|
||||
data.Set(kPagesField, std::move(rvh_list));
|
||||
|
||||
std::unique_ptr<base::ListValue> window_list(new base::ListValue());
|
||||
auto window_list = std::make_unique<base::ListValue>();
|
||||
for (auto* window : electron::WindowList::GetWindows()) {
|
||||
window_list->Append(BuildTargetDescriptor(window));
|
||||
}
|
||||
|
@ -383,7 +381,7 @@ void ElectronAccessibilityUIMessageHandler::RequestNativeUITree(
|
|||
}
|
||||
|
||||
// No browser with the specified |id| was found.
|
||||
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
|
||||
auto result = std::make_unique<base::DictionaryValue>();
|
||||
result->SetInteger(kSessionIdField, window_id);
|
||||
result->SetString(kTypeField, kBrowser);
|
||||
result->SetString(kErrorField, "Window no longer exists.");
|
||||
|
|
|
@ -210,9 +210,9 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
|||
if (pos.IsOrigin())
|
||||
rect.set_origin(display::Screen::GetScreen()->GetCursorScreenPoint());
|
||||
|
||||
menu_runner_.reset(
|
||||
new views::MenuRunner(menu_model != nullptr ? menu_model : menu_model_,
|
||||
views::MenuRunner::HAS_MNEMONICS));
|
||||
menu_runner_ = std::make_unique<views::MenuRunner>(
|
||||
menu_model != nullptr ? menu_model : menu_model_,
|
||||
views::MenuRunner::HAS_MNEMONICS);
|
||||
menu_runner_->RunMenuAt(nullptr, nullptr, rect,
|
||||
views::MenuAnchorPosition::kTopLeft,
|
||||
ui::MENU_SOURCE_MOUSE);
|
||||
|
|
|
@ -40,7 +40,7 @@ bool ShouldUseGlobalMenuBar() {
|
|||
return false;
|
||||
|
||||
dbus::Bus::Options options;
|
||||
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
|
||||
auto bus = base::MakeRefCounted<dbus::Bus>(options);
|
||||
|
||||
dbus::ObjectProxy* object_proxy =
|
||||
bus->GetObjectProxy(DBUS_SERVICE_DBUS, dbus::ObjectPath(DBUS_PATH_DBUS));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue