Use td::unique_ptr instead of std::unique_ptr whenever possible.

GitOrigin-RevId: 424beb72dc62efdefdbffb75f1036ba9417f84cb
This commit is contained in:
levlam 2018-09-27 04:19:03 +03:00
parent 83be04a5f4
commit f948956bf7
139 changed files with 541 additions and 541 deletions

View File

@ -136,7 +136,7 @@ class QueryBench : public td::Benchmark {
virtual ~Callback() = default;
virtual void on_result(int x) = 0;
};
explicit ClientActor(std::unique_ptr<Callback> callback) : callback_(std::move(callback)) {
explicit ClientActor(td::unique_ptr<Callback> callback) : callback_(std::move(callback)) {
}
void f(int x) {
callback_->on_result(x * x);
@ -152,7 +152,7 @@ class QueryBench : public td::Benchmark {
}
private:
std::unique_ptr<Callback> callback_;
td::unique_ptr<Callback> callback_;
};
class ServerActor : public td::Actor {

View File

@ -167,13 +167,13 @@ class SqliteKeyValueAsyncBench : public td::Benchmark {
}
private:
std::unique_ptr<td::ConcurrentScheduler> scheduler_;
td::unique_ptr<td::ConcurrentScheduler> scheduler_;
std::shared_ptr<td::SqliteConnectionSafe> sql_connection_;
std::shared_ptr<td::SqliteKeyValueSafe> sqlite_kv_safe_;
std::unique_ptr<td::SqliteKeyValueAsyncInterface> sqlite_kv_async_;
td::unique_ptr<td::SqliteKeyValueAsyncInterface> sqlite_kv_async_;
td::Status do_start_up() {
scheduler_ = std::make_unique<td::ConcurrentScheduler>();
scheduler_ = td::make_unique<td::ConcurrentScheduler>();
scheduler_->init(1);
auto guard = scheduler_->get_main_guard();

View File

@ -76,13 +76,13 @@ class MessagesDbBench : public Benchmark {
}
private:
std::unique_ptr<td::ConcurrentScheduler> scheduler_;
td::unique_ptr<td::ConcurrentScheduler> scheduler_;
std::shared_ptr<SqliteConnectionSafe> sql_connection_;
std::shared_ptr<MessagesDbSyncSafeInterface> messages_db_sync_safe_;
std::shared_ptr<MessagesDbAsyncInterface> messages_db_async_;
Status do_start_up() {
scheduler_ = std::make_unique<ConcurrentScheduler>();
scheduler_ = make_unique<ConcurrentScheduler>();
scheduler_->init(1);
auto guard = scheduler_->get_main_guard();

View File

@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
auto timeout = 10;
auto ttl = 3;
auto prefer_ipv6 = (argc > 2 && std::string(argv[2]) == "-6");
auto scheduler = std::make_unique<td::ConcurrentScheduler>();
auto scheduler = td::make_unique<td::ConcurrentScheduler>();
scheduler->init(0);
scheduler
->create_actor_unsafe<td::Wget>(0, "Client", td::PromiseCreator::lambda([](td::Result<td::HttpQueryPtr> res) {

View File

@ -14,6 +14,7 @@
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/mtproto/HandshakeActor.h"
#include "td/mtproto/HandshakeConnection.h"
#include "td/utils/common.h"
@ -13,14 +14,12 @@
namespace td {
namespace mtproto {
HandshakeActor::HandshakeActor(std::unique_ptr<AuthKeyHandshake> handshake,
std::unique_ptr<RawConnection> raw_connection,
std::unique_ptr<AuthKeyHandshakeContext> context, double timeout,
Promise<std::unique_ptr<RawConnection>> raw_connection_promise,
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise)
HandshakeActor::HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
Promise<unique_ptr<RawConnection>> raw_connection_promise,
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise)
: handshake_(std::move(handshake))
, connection_(
std::make_unique<HandshakeConnection>(std::move(raw_connection), handshake_.get(), std::move(context)))
, connection_(make_unique<HandshakeConnection>(std::move(raw_connection), handshake_.get(), std::move(context)))
, timeout_(timeout)
, raw_connection_promise_(std::move(raw_connection_promise))
, handshake_promise_(std::move(handshake_promise)) {

View File

@ -13,26 +13,28 @@
namespace td {
namespace mtproto {
class AuthKeyHandshake;
class AuthKeyHandshakeContext;
class RawConnection;
class HandshakeConnection;
// Has Raw connection. Generates new auth key. And returns it and raw_connection. Or error...
class HandshakeActor : public Actor {
public:
HandshakeActor(std::unique_ptr<AuthKeyHandshake> handshake, std::unique_ptr<RawConnection> raw_connection,
std::unique_ptr<AuthKeyHandshakeContext> context, double timeout,
Promise<std::unique_ptr<RawConnection>> raw_connection_promise,
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise);
HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
Promise<unique_ptr<RawConnection>> raw_connection_promise,
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise);
void close();
private:
std::unique_ptr<AuthKeyHandshake> handshake_;
std::unique_ptr<HandshakeConnection> connection_;
unique_ptr<AuthKeyHandshake> handshake_;
unique_ptr<HandshakeConnection> connection_;
double timeout_;
Promise<std::unique_ptr<RawConnection>> raw_connection_promise_;
Promise<std::unique_ptr<AuthKeyHandshake>> handshake_promise_;
Promise<unique_ptr<RawConnection>> raw_connection_promise_;
Promise<unique_ptr<AuthKeyHandshake>> handshake_promise_;
void start_up() override;
void tear_down() override {

View File

@ -26,8 +26,8 @@ class HandshakeConnection
: private RawConnection::Callback
, private AuthKeyHandshake::Callback {
public:
HandshakeConnection(std::unique_ptr<RawConnection> raw_connection, AuthKeyHandshake *handshake,
std::unique_ptr<AuthKeyHandshakeContext> context)
HandshakeConnection(unique_ptr<RawConnection> raw_connection, AuthKeyHandshake *handshake,
unique_ptr<AuthKeyHandshakeContext> context)
: raw_connection_(std::move(raw_connection)), handshake_(handshake), context_(std::move(context)) {
handshake_->resume(this);
}
@ -36,7 +36,7 @@ class HandshakeConnection
return raw_connection_->get_poll_info();
}
std::unique_ptr<RawConnection> move_as_raw_connection() {
unique_ptr<RawConnection> move_as_raw_connection() {
return std::move(raw_connection_);
}
@ -54,9 +54,9 @@ class HandshakeConnection
}
private:
std::unique_ptr<RawConnection> raw_connection_;
unique_ptr<RawConnection> raw_connection_;
AuthKeyHandshake *handshake_;
std::unique_ptr<AuthKeyHandshakeContext> context_;
unique_ptr<AuthKeyHandshakeContext> context_;
void send_no_crypto(const Storer &storer) override {
raw_connection_->send_no_crypto(PacketStorer<NoCryptoImpl>(0, storer));

View File

@ -13,14 +13,14 @@
namespace td {
namespace mtproto {
std::unique_ptr<IStreamTransport> create_transport(TransportType type) {
unique_ptr<IStreamTransport> create_transport(TransportType type) {
switch (type.type) {
case TransportType::ObfuscatedTcp:
return std::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
return td::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
case TransportType::Tcp:
return std::make_unique<tcp::OldTransport>();
return td::make_unique<tcp::OldTransport>();
case TransportType::Http:
return std::make_unique<http::Transport>(type.secret);
return td::make_unique<http::Transport>(type.secret);
}
UNREACHABLE();
}

View File

@ -34,6 +34,6 @@ class IStreamTransport {
virtual TransportType get_type() const = 0;
};
std::unique_ptr<IStreamTransport> create_transport(TransportType type);
unique_ptr<IStreamTransport> create_transport(TransportType type);
} // namespace mtproto
} // namespace td

View File

@ -24,7 +24,7 @@ namespace mtproto {
class PingConnection : private RawConnection::Callback {
public:
PingConnection(std::unique_ptr<RawConnection> raw_connection, size_t ping_count)
PingConnection(unique_ptr<RawConnection> raw_connection, size_t ping_count)
: raw_connection_(std::move(raw_connection)), ping_count_(ping_count) {
}
@ -32,7 +32,7 @@ class PingConnection : private RawConnection::Callback {
return raw_connection_->get_poll_info();
}
std::unique_ptr<RawConnection> move_as_raw_connection() {
unique_ptr<RawConnection> move_as_raw_connection() {
return std::move(raw_connection_);
}
@ -76,7 +76,7 @@ class PingConnection : private RawConnection::Callback {
}
private:
std::unique_ptr<RawConnection> raw_connection_;
unique_ptr<RawConnection> raw_connection_;
size_t ping_count_ = 1;
double start_time_ = 0.0;
double finish_time_ = 0.0;

View File

@ -42,7 +42,7 @@ class RawConnection {
virtual void on_mtproto_error() = 0;
};
RawConnection() = default;
RawConnection(SocketFd socket_fd, TransportType transport_type, std::unique_ptr<StatsCallback> stats_callback)
RawConnection(SocketFd socket_fd, TransportType transport_type, unique_ptr<StatsCallback> stats_callback)
: socket_fd_(std::move(socket_fd))
, transport_(create_transport(transport_type))
, stats_callback_(std::move(stats_callback)) {
@ -116,7 +116,7 @@ class RawConnection {
std::map<uint32, uint64> quick_ack_to_token_;
bool has_error_{false};
std::unique_ptr<StatsCallback> stats_callback_;
unique_ptr<StatsCallback> stats_callback_;
StateManager::ConnectionToken connection_token_;

View File

@ -659,7 +659,7 @@ Status SessionConnection::on_quick_ack(uint64 quick_ack_token) {
callback_->on_message_ack(quick_ack_token);
return Status::OK();
}
SessionConnection::SessionConnection(Mode mode, std::unique_ptr<RawConnection> raw_connection, AuthData *auth_data,
SessionConnection::SessionConnection(Mode mode, unique_ptr<RawConnection> raw_connection, AuthData *auth_data,
DhCallback *dh_callback)
: raw_connection_(std::move(raw_connection)), auth_data_(auth_data), dh_callback_(dh_callback) {
state_ = Init;

View File

@ -66,8 +66,7 @@ class SessionConnection
, private RawConnection::Callback {
public:
enum class Mode { Tcp, Http, HttpLongPoll };
SessionConnection(Mode mode, std::unique_ptr<RawConnection> raw_connection, AuthData *auth_data,
DhCallback *dh_callback);
SessionConnection(Mode mode, unique_ptr<RawConnection> raw_connection, AuthData *auth_data, DhCallback *dh_callback);
PollableFdInfo &get_poll_info();
@ -181,7 +180,7 @@ class SessionConnection
int64 main_message_id_ = 0;
double created_at_ = 0;
std::unique_ptr<RawConnection> raw_connection_;
unique_ptr<RawConnection> raw_connection_;
AuthData *auth_data_;
SessionConnection::Callback *callback_ = nullptr;
DhCallback *dh_callback_;

View File

@ -129,7 +129,7 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
td_->file_manager_->get_file_object(file_id));
}
FileId AnimationsManager::on_get_animation(std::unique_ptr<Animation> new_animation, bool replace) {
FileId AnimationsManager::on_get_animation(unique_ptr<Animation> new_animation, bool replace) {
auto file_id = new_animation->file_id;
LOG(INFO) << (replace ? "Replace" : "Add") << " animation " << file_id << " of size " << new_animation->dimensions;
auto &a = animations_[file_id];
@ -200,7 +200,7 @@ FileId AnimationsManager::dup_animation(FileId new_id, FileId old_id) {
CHECK(old_animation != nullptr);
auto &new_animation = animations_[new_id];
CHECK(!new_animation);
new_animation = std::make_unique<Animation>(*old_animation);
new_animation = make_unique<Animation>(*old_animation);
new_animation->file_id = new_id;
new_animation->thumbnail.file_id = td_->file_manager_->dup_file_id(new_animation->thumbnail.file_id);
return new_id;

View File

@ -99,7 +99,7 @@ class AnimationsManager : public Actor {
const Animation *get_animation(FileId file_id) const;
FileId on_get_animation(std::unique_ptr<Animation> new_animation, bool replace);
FileId on_get_animation(unique_ptr<Animation> new_animation, bool replace);
int32 get_saved_animations_hash(const char *source) const;

View File

@ -43,7 +43,7 @@ tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {
get_photo_size_object(td_->file_manager_.get(), &audio->thumbnail), td_->file_manager_->get_file_object(file_id));
}
FileId AudiosManager::on_get_audio(std::unique_ptr<Audio> new_audio, bool replace) {
FileId AudiosManager::on_get_audio(unique_ptr<Audio> new_audio, bool replace) {
auto file_id = new_audio->file_id;
LOG(INFO) << "Receive audio " << file_id;
auto &a = audios_[file_id];
@ -98,7 +98,7 @@ FileId AudiosManager::dup_audio(FileId new_id, FileId old_id) {
CHECK(old_audio != nullptr);
auto &new_audio = audios_[new_id];
CHECK(!new_audio);
new_audio = std::make_unique<Audio>(*old_audio);
new_audio = make_unique<Audio>(*old_audio);
new_audio->file_id = new_id;
new_audio->thumbnail.file_id = td_->file_manager_->dup_file_id(new_audio->thumbnail.file_id);
return new_id;
@ -167,7 +167,7 @@ void AudiosManager::delete_audio_thumbnail(FileId file_id) {
void AudiosManager::create_audio(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type,
int32 duration, string title, string performer, bool replace) {
auto a = std::make_unique<Audio>();
auto a = make_unique<Audio>();
a->file_id = file_id;
a->file_name = std::move(file_name);
a->mime_type = std::move(mime_type);

View File

@ -76,7 +76,7 @@ class AudiosManager {
const Audio *get_audio(FileId file_id) const;
FileId on_get_audio(std::unique_ptr<Audio> new_audio, bool replace);
FileId on_get_audio(unique_ptr<Audio> new_audio, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<Audio>, FileIdHash> audios_;

View File

@ -25,7 +25,7 @@ namespace td {
class Client::Impl final {
public:
Impl() {
concurrent_scheduler_ = std::make_unique<ConcurrentScheduler>();
concurrent_scheduler_ = make_unique<ConcurrentScheduler>();
concurrent_scheduler_->init(0);
class Callback : public TdCallback {
public:
@ -98,7 +98,7 @@ class Client::Impl final {
private:
std::deque<Response> responses_;
std::vector<Request> requests_;
std::unique_ptr<ConcurrentScheduler> concurrent_scheduler_;
unique_ptr<ConcurrentScheduler> concurrent_scheduler_;
ActorOwn<Td> td_;
bool closed_ = false;
};
@ -136,7 +136,7 @@ class Client::Impl final {
private:
std::shared_ptr<OutputQueue> output_queue_;
};
td_ = concurrent_scheduler_->create_actor_unsafe<Td>(0, "Td", std::make_unique<Callback>(output_queue_));
td_ = concurrent_scheduler_->create_actor_unsafe<Td>(0, "Td", td::make_unique<Callback>(output_queue_));
concurrent_scheduler_->start();
scheduler_thread_ = thread([concurrent_scheduler = concurrent_scheduler_] {
@ -201,7 +201,7 @@ class Client::Impl final {
#endif
/*** Client ***/
Client::Client() : impl_(make_unique<Impl>()) {
Client::Client() : impl_(std::make_unique<Impl>()) {
// At least it should be enough for everybody who uses TDLib
init_openssl_threads();
}

View File

@ -200,7 +200,7 @@ ActorOwn<> get_full_config(DcId dc_id, IPAddress ip_address, Promise<FullConfig>
}
void on_closed() final {
}
void request_raw_connection(Promise<std::unique_ptr<mtproto::RawConnection>> promise) final {
void request_raw_connection(Promise<unique_ptr<mtproto::RawConnection>> promise) final {
request_raw_connection_cnt_++;
VLOG(config_recoverer) << "Request full config from " << address_ << ", try = " << request_raw_connection_cnt_;
if (request_raw_connection_cnt_ <= 2) {
@ -219,7 +219,7 @@ ActorOwn<> get_full_config(DcId dc_id, IPAddress ip_address, Promise<FullConfig>
ActorShared<> parent_;
IPAddress address_;
size_t request_raw_connection_cnt_{0};
std::vector<Promise<std::unique_ptr<mtproto::RawConnection>>> delay_forever_;
std::vector<Promise<unique_ptr<mtproto::RawConnection>>> delay_forever_;
};
class SimpleAuthData : public AuthDataShared {
@ -280,7 +280,7 @@ ActorOwn<> get_full_config(DcId dc_id, IPAddress ip_address, Promise<FullConfig>
DcId dc_id_;
std::shared_ptr<PublicRsaKeyShared> public_rsa_key_ = std::make_shared<PublicRsaKeyShared>(DcId::empty());
std::vector<std::unique_ptr<Listener>> auth_key_listeners_;
std::vector<unique_ptr<Listener>> auth_key_listeners_;
void notify() {
auto it = std::remove_if(auth_key_listeners_.begin(), auth_key_listeners_.end(),
[&](auto &listener) { return !listener->notify(); });
@ -303,7 +303,7 @@ ActorOwn<> get_full_config(DcId dc_id, IPAddress ip_address, Promise<FullConfig>
private:
void start_up() override {
auto session_callback = std::make_unique<SessionCallback>(actor_shared(this, 1), std::move(ip_address_));
auto session_callback = make_unique<SessionCallback>(actor_shared(this, 1), std::move(ip_address_));
auto auth_data = std::make_shared<SimpleAuthData>(dc_id_);
int32 int_dc_id = dc_id_.get_raw_id();

View File

@ -6454,7 +6454,8 @@ bool ContactsManager::on_update_user_full_bot_info(UserFull *user_full, UserId u
for (auto &command : bot_info->commands_) {
commands.emplace_back(std::move(command->command_), std::move(command->description_));
}
user_full->bot_info = make_unique<BotInfo>(bot_info_version, std::move(bot_info->description_), std::move(commands));
user_full->bot_info =
td::make_unique<BotInfo>(bot_info_version, std::move(bot_info->description_), std::move(commands));
user_full->is_changed = true;
return true;
}

View File

@ -510,7 +510,7 @@ class ContactsManager : public Actor {
int32 photo_count = -1;
int32 photos_offset = -1;
std::unique_ptr<BotInfo> bot_info;
unique_ptr<BotInfo> bot_info;
string about;

View File

@ -158,7 +158,7 @@ std::shared_ptr<DialogDbSyncSafeInterface> create_dialog_db_sync(
public:
explicit DialogDbSyncSafe(std::shared_ptr<SqliteConnectionSafe> sqlite_connection)
: lsls_db_([safe_connection = std::move(sqlite_connection)] {
return std::make_unique<DialogDbImpl>(safe_connection->get().clone());
return make_unique<DialogDbImpl>(safe_connection->get().clone());
}) {
}
DialogDbSyncInterface &get() override {
@ -166,7 +166,7 @@ std::shared_ptr<DialogDbSyncSafeInterface> create_dialog_db_sync(
}
private:
LazySchedulerLocalStorage<std::unique_ptr<DialogDbSyncInterface>> lsls_db_;
LazySchedulerLocalStorage<unique_ptr<DialogDbSyncInterface>> lsls_db_;
};
return std::make_shared<DialogDbSyncSafe>(std::move(sqlite_connection));
}

View File

@ -369,7 +369,7 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
return {document_type, file_id};
}
FileId DocumentsManager::on_get_document(std::unique_ptr<Document> new_document, bool replace) {
FileId DocumentsManager::on_get_document(unique_ptr<Document> new_document, bool replace) {
auto file_id = new_document->file_id;
LOG(INFO) << "Receive document " << file_id;
auto &d = documents_[new_document->file_id];
@ -521,7 +521,7 @@ FileId DocumentsManager::dup_document(FileId new_id, FileId old_id) {
CHECK(old_document != nullptr);
auto &new_document = documents_[new_id];
CHECK(!new_document);
new_document = std::make_unique<Document>(*old_document);
new_document = make_unique<Document>(*old_document);
new_document->file_id = new_id;
new_document->thumbnail.file_id = td_->file_manager_->dup_file_id(new_document->thumbnail.file_id);
return new_id;

View File

@ -124,7 +124,7 @@ class DocumentsManager {
const Document *get_document(FileId file_id) const;
FileId on_get_document(std::unique_ptr<Document> new_document, bool replace);
FileId on_get_document(unique_ptr<Document> new_document, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<Document>, FileIdHash> documents_; // file_id -> Document

View File

@ -57,11 +57,11 @@ void Global::set_temp_auth_key_watchdog(ActorOwn<TempAuthKeyWatchdog> actor) {
MtprotoHeader &Global::mtproto_header() {
return *mtproto_header_;
}
void Global::set_mtproto_header(std::unique_ptr<MtprotoHeader> mtproto_header) {
void Global::set_mtproto_header(unique_ptr<MtprotoHeader> mtproto_header) {
mtproto_header_ = std::move(mtproto_header);
}
Status Global::init(const TdParameters &parameters, ActorId<Td> td, std::unique_ptr<TdDb> td_db) {
Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db) {
parameters_ = parameters;
gc_scheduler_id_ = min(Scheduler::instance()->sched_id() + 2, Scheduler::instance()->sched_count() - 1);
@ -114,11 +114,11 @@ DcId Global::get_webfile_dc_id() const {
return DcId::internal(dc_id);
}
void Global::set_net_query_dispatcher(std::unique_ptr<NetQueryDispatcher> net_query_dispatcher) {
void Global::set_net_query_dispatcher(unique_ptr<NetQueryDispatcher> net_query_dispatcher) {
net_query_dispatcher_ = std::move(net_query_dispatcher);
}
void Global::set_shared_config(std::unique_ptr<ConfigShared> shared_config) {
void Global::set_shared_config(unique_ptr<ConfigShared> shared_config) {
shared_config_ = std::move(shared_config);
}

View File

@ -72,7 +72,7 @@ class Global : public ActorContext {
void close_all(Promise<> on_finished);
void close_and_destroy_all(Promise<> on_finished);
Status init(const TdParameters &parameters, ActorId<Td> td, std::unique_ptr<TdDb> td_db) TD_WARN_UNUSED_RESULT;
Status init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db) TD_WARN_UNUSED_RESULT;
Slice get_dir() const {
return parameters_.database_directory;
@ -88,7 +88,7 @@ class Global : public ActorContext {
return net_query_creator_.get();
}
void set_net_query_dispatcher(std::unique_ptr<NetQueryDispatcher> net_query_dispatcher);
void set_net_query_dispatcher(unique_ptr<NetQueryDispatcher> net_query_dispatcher);
NetQueryDispatcher &net_query_dispatcher() {
return *net_query_dispatcher_;
@ -98,7 +98,7 @@ class Global : public ActorContext {
return net_query_dispatcher_ != nullptr;
}
void set_shared_config(std::unique_ptr<ConfigShared> shared_config);
void set_shared_config(unique_ptr<ConfigShared> shared_config);
ConfigShared &shared_config() {
return *shared_config_;
@ -232,7 +232,7 @@ class Global : public ActorContext {
void set_temp_auth_key_watchdog(ActorOwn<TempAuthKeyWatchdog> actor);
MtprotoHeader &mtproto_header();
void set_mtproto_header(std::unique_ptr<MtprotoHeader> mtproto_header);
void set_mtproto_header(unique_ptr<MtprotoHeader> mtproto_header);
bool have_mtproto_header() const {
return mtproto_header_ != nullptr;
}
@ -309,7 +309,7 @@ class Global : public ActorContext {
private:
std::shared_ptr<DhConfig> dh_config_;
std::unique_ptr<TdDb> td_db_;
unique_ptr<TdDb> td_db_;
Condition binlog_replay_finish_;
ActorId<Td> td_;
@ -330,7 +330,7 @@ class Global : public ActorContext {
ActorOwn<ConnectionCreator> connection_creator_;
ActorOwn<TempAuthKeyWatchdog> temp_auth_key_watchdog_;
std::unique_ptr<MtprotoHeader> mtproto_header_;
unique_ptr<MtprotoHeader> mtproto_header_;
TdParameters parameters_;
int32 gc_scheduler_id_;
@ -345,9 +345,9 @@ class Global : public ActorContext {
ActorId<StateManager> state_manager_;
SchedulerLocalStorage<NetQueryCreator> net_query_creator_;
std::unique_ptr<NetQueryDispatcher> net_query_dispatcher_;
unique_ptr<NetQueryDispatcher> net_query_dispatcher_;
std::unique_ptr<ConfigShared> shared_config_;
unique_ptr<ConfigShared> shared_config_;
int32 my_id_ = 0; // hack

View File

@ -68,14 +68,14 @@ struct LanguagePackManager::LanguagePack {
SqliteKeyValue pack_kv_; // usages should be guarded by database_->mutex_
std::map<string, LanguageInfo> custom_language_pack_infos_; // sorted by language_code
vector<std::pair<string, LanguageInfo>> server_language_pack_infos_; // sorted by server
std::unordered_map<string, std::unique_ptr<Language>> languages_;
std::unordered_map<string, unique_ptr<Language>> languages_;
};
struct LanguagePackManager::LanguageDatabase {
std::mutex mutex_;
string path_;
SqliteDb database_;
std::unordered_map<string, std::unique_ptr<LanguagePack>> language_packs_;
std::unordered_map<string, unique_ptr<LanguagePack>> language_packs_;
};
LanguagePackManager::~LanguagePackManager() = default;
@ -1284,7 +1284,6 @@ void LanguagePackManager::hangup() {
int32 LanguagePackManager::manager_count_ = 0;
std::mutex LanguagePackManager::language_database_mutex_;
std::unordered_map<string, std::unique_ptr<LanguagePackManager::LanguageDatabase>>
LanguagePackManager::language_databases_;
std::unordered_map<string, unique_ptr<LanguagePackManager::LanguageDatabase>> LanguagePackManager::language_databases_;
} // namespace td

View File

@ -92,7 +92,7 @@ class LanguagePackManager : public NetQueryCallback {
static int32 manager_count_;
static std::mutex language_database_mutex_;
static std::unordered_map<string, std::unique_ptr<LanguageDatabase>> language_databases_;
static std::unordered_map<string, unique_ptr<LanguageDatabase>> language_databases_;
static LanguageDatabase *add_language_database(const string &path);

View File

@ -799,7 +799,7 @@ std::shared_ptr<MessagesDbSyncSafeInterface> create_messages_db_sync(
public:
explicit MessagesDbSyncSafe(std::shared_ptr<SqliteConnectionSafe> sqlite_connection)
: lsls_db_([safe_connection = std::move(sqlite_connection)] {
return std::make_unique<MessagesDbImpl>(safe_connection->get().clone());
return make_unique<MessagesDbImpl>(safe_connection->get().clone());
}) {
}
MessagesDbSyncInterface &get() override {
@ -807,7 +807,7 @@ std::shared_ptr<MessagesDbSyncSafeInterface> create_messages_db_sync(
}
private:
LazySchedulerLocalStorage<std::unique_ptr<MessagesDbSyncInterface>> lsls_db_;
LazySchedulerLocalStorage<unique_ptr<MessagesDbSyncInterface>> lsls_db_;
};
return std::make_shared<MessagesDbSyncSafe>(std::move(sqlite_connection));
}

View File

@ -7010,7 +7010,7 @@ void MessagesManager::load_secret_thumbnail(FileId thumbnail_file_id) {
});
send_closure(G()->file_manager(), &FileManager::download, thumbnail_file_id,
std::make_unique<Callback>(std::move(download_promise)), 1);
std::make_shared<Callback>(std::move(download_promise)), 1);
}
void MessagesManager::on_upload_media(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
@ -19183,8 +19183,8 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
force_create_dialog(from_dialog_id, "message forward from info");
}
return make_unique<MessageForwardInfo>(sender_user_id, forward_header->date_, dialog_id, message_id, author_signature,
from_dialog_id, from_message_id);
return td::make_unique<MessageForwardInfo>(sender_user_id, forward_header->date_, dialog_id, message_id,
author_signature, from_dialog_id, from_message_id);
}
tl_object_ptr<td_api::MessageForwardInfo> MessagesManager::get_message_forward_info_object(
@ -19442,7 +19442,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
auto author_signature = forwarded_message->sender_user_id.is_valid()
? td_->contacts_manager_->get_user_title(forwarded_message->sender_user_id)
: forwarded_message->author_signature;
forward_info = make_unique<MessageForwardInfo>(UserId(), forwarded_message->date, from_dialog_id,
forward_info = td::make_unique<MessageForwardInfo>(UserId(), forwarded_message->date, from_dialog_id,
forwarded_message_id, std::move(author_signature),
saved_from_dialog_id, saved_from_message_id);
}
@ -22907,11 +22907,11 @@ unique_ptr<MessageContent> MessagesManager::get_message_content(FormattedText me
bool need_shipping_address =
(message_invoice->flags_ & telegram_api::messageMediaInvoice::SHIPPING_ADDRESS_REQUESTED_MASK) != 0;
bool is_test = (message_invoice->flags_ & telegram_api::messageMediaInvoice::TEST_MASK) != 0;
return make_unique<MessageInvoice>(std::move(message_invoice->title_), std::move(message_invoice->description_),
return td::make_unique<MessageInvoice>(
std::move(message_invoice->title_), std::move(message_invoice->description_),
get_web_document_photo(std::move(message_invoice->photo_), owner_dialog_id),
std::move(message_invoice->start_param_), message_invoice->total_amount_,
std::move(message_invoice->currency_), is_test, need_shipping_address,
receipt_message_id);
std::move(message_invoice->currency_), is_test, need_shipping_address, receipt_message_id);
}
case telegram_api::messageMediaWebPage::ID: {
auto media_web_page = move_tl_object_as<telegram_api::messageMediaWebPage>(media);
@ -23148,11 +23148,11 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
}
}
return make_unique<MessageChatCreate>(std::move(chat_create->title_), std::move(participant_user_ids));
return td::make_unique<MessageChatCreate>(std::move(chat_create->title_), std::move(participant_user_ids));
}
case telegram_api::messageActionChatEditTitle::ID: {
auto chat_edit_title = move_tl_object_as<telegram_api::messageActionChatEditTitle>(action);
return make_unique<MessageChatChangeTitle>(std::move(chat_edit_title->title_));
return td::make_unique<MessageChatChangeTitle>(std::move(chat_edit_title->title_));
}
case telegram_api::messageActionChatEditPhoto::ID: {
auto chat_edit_photo = move_tl_object_as<telegram_api::messageActionChatEditPhoto>(action);
@ -23187,7 +23187,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
}
}
return make_unique<MessageChatAddUsers>(std::move(user_ids));
return td::make_unique<MessageChatAddUsers>(std::move(user_ids));
}
case telegram_api::messageActionChatJoinedByLink::ID:
return make_unique<MessageChatJoinedByLink>();
@ -23216,7 +23216,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
}
case telegram_api::messageActionChannelCreate::ID: {
auto channel_create = move_tl_object_as<telegram_api::messageActionChannelCreate>(action);
return make_unique<MessageChannelCreate>(std::move(channel_create->title_));
return td::make_unique<MessageChannelCreate>(std::move(channel_create->title_));
}
case telegram_api::messageActionChannelMigrateFrom::ID: {
auto channel_migrate_from = move_tl_object_as<telegram_api::messageActionChannelMigrateFrom>(action);
@ -23225,7 +23225,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
LOG_IF(ERROR, !chat_id.is_valid()) << "Receive messageActionChannelMigrateFrom with invalid " << chat_id << " in "
<< owner_dialog_id;
return make_unique<MessageChannelMigrateFrom>(std::move(channel_migrate_from->title_), chat_id);
return td::make_unique<MessageChannelMigrateFrom>(std::move(channel_migrate_from->title_), chat_id);
}
case telegram_api::messageActionPinMessage::ID: {
if (!reply_to_message_id.is_valid()) {
@ -23256,7 +23256,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
reply_to_message_id = MessageId();
}
auto payment_sent = move_tl_object_as<telegram_api::messageActionPaymentSent>(action);
return make_unique<MessagePaymentSuccessful>(reply_to_message_id, std::move(payment_sent->currency_),
return td::make_unique<MessagePaymentSuccessful>(reply_to_message_id, std::move(payment_sent->currency_),
payment_sent->total_amount_);
}
case telegram_api::messageActionPaymentSentMe::ID: {
@ -23266,7 +23266,7 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
reply_to_message_id = MessageId();
}
auto payment_sent = move_tl_object_as<telegram_api::messageActionPaymentSentMe>(action);
auto result = make_unique<MessagePaymentSuccessful>(reply_to_message_id, std::move(payment_sent->currency_),
auto result = td::make_unique<MessagePaymentSuccessful>(reply_to_message_id, std::move(payment_sent->currency_),
payment_sent->total_amount_);
result->invoice_payload = payment_sent->payload_.as_slice().str();
result->shipping_option_id = std::move(payment_sent->shipping_option_id_);
@ -23280,21 +23280,21 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
}
case telegram_api::messageActionCustomAction::ID: {
auto custom_action = move_tl_object_as<telegram_api::messageActionCustomAction>(action);
return make_unique<MessageCustomServiceAction>(std::move(custom_action->message_));
return td::make_unique<MessageCustomServiceAction>(std::move(custom_action->message_));
}
case telegram_api::messageActionBotAllowed::ID: {
auto bot_allowed = move_tl_object_as<telegram_api::messageActionBotAllowed>(action);
return make_unique<MessageWebsiteConnected>(std::move(bot_allowed->domain_));
return td::make_unique<MessageWebsiteConnected>(std::move(bot_allowed->domain_));
}
case telegram_api::messageActionSecureValuesSent::ID: {
LOG_IF(ERROR, td_->auth_manager_->is_bot()) << "Receive MessageActionSecureValuesSent in " << owner_dialog_id;
auto secure_values = move_tl_object_as<telegram_api::messageActionSecureValuesSent>(action);
return make_unique<MessagePassportDataSent>(get_secure_value_types(secure_values->types_));
return td::make_unique<MessagePassportDataSent>(get_secure_value_types(secure_values->types_));
}
case telegram_api::messageActionSecureValuesSentMe::ID: {
LOG_IF(ERROR, !td_->auth_manager_->is_bot()) << "Receive MessageActionSecureValuesSentMe in " << owner_dialog_id;
auto secure_values = move_tl_object_as<telegram_api::messageActionSecureValuesSentMe>(action);
return make_unique<MessagePassportDataReceived>(
return td::make_unique<MessagePassportDataReceived>(
get_encrypted_secure_values(td_->file_manager_.get(), std::move(secure_values->values_)),
get_encrypted_secure_credentials(std::move(secure_values->credentials_)));
}

View File

@ -543,9 +543,9 @@ unique_ptr<Address> get_address(tl_object_ptr<telegram_api::postAddress> &&addre
if (address == nullptr) {
return nullptr;
}
return make_unique<Address>(std::move(address->country_iso2_), std::move(address->state_), std::move(address->city_),
std::move(address->street_line1_), std::move(address->street_line2_),
std::move(address->post_code_));
return td::make_unique<Address>(std::move(address->country_iso2_), std::move(address->state_),
std::move(address->city_), std::move(address->street_line1_),
std::move(address->street_line2_), std::move(address->post_code_));
}
static bool is_capital_alpha(char c) {
@ -684,8 +684,9 @@ unique_ptr<OrderInfo> get_order_info(tl_object_ptr<telegram_api::paymentRequeste
if (order_info == nullptr || order_info->flags_ == 0) {
return nullptr;
}
return make_unique<OrderInfo>(std::move(order_info->name_), std::move(order_info->phone_),
std::move(order_info->email_), get_address(std::move(order_info->shipping_address_)));
return td::make_unique<OrderInfo>(std::move(order_info->name_), std::move(order_info->phone_),
std::move(order_info->email_),
get_address(std::move(order_info->shipping_address_)));
}
tl_object_ptr<td_api::orderInfo> get_order_info_object(const unique_ptr<OrderInfo> &order_info) {

View File

@ -55,7 +55,7 @@ class SecretImpl {
const Storer &data;
};
SecretChatActor::SecretChatActor(int32 id, std::unique_ptr<Context> context, bool can_be_empty)
SecretChatActor::SecretChatActor(int32 id, unique_ptr<Context> context, bool can_be_empty)
: context_(std::move(context)), can_be_empty_(can_be_empty) {
auth_state_.id = id;
}
@ -81,7 +81,7 @@ void SecretChatActor::create_chat(int32 user_id, int64 user_access_hash, int32 r
return;
}
auto event = std::make_unique<logevent::CreateSecretChat>();
auto event = make_unique<logevent::CreateSecretChat>();
event->user_id = user_id;
event->user_access_hash = user_access_hash;
event->random_id = random_id;
@ -124,18 +124,18 @@ void SecretChatActor::on_result_resendable(NetQueryPtr net_query, Promise<NetQue
loop();
}
void SecretChatActor::replay_close_chat(std::unique_ptr<logevent::CloseSecretChat> event) {
void SecretChatActor::replay_close_chat(unique_ptr<logevent::CloseSecretChat> event) {
do_close_chat_impl(std::move(event));
}
void SecretChatActor::replay_create_chat(std::unique_ptr<logevent::CreateSecretChat> event) {
void SecretChatActor::replay_create_chat(unique_ptr<logevent::CreateSecretChat> event) {
if (close_flag_) {
return;
}
do_create_chat_impl(std::move(event));
}
void SecretChatActor::add_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message) {
void SecretChatActor::add_inbound_message(unique_ptr<logevent::InboundSecretMessage> message) {
SCOPE_EXIT {
if (message) {
message->qts_ack.set_value(Unit());
@ -152,7 +152,7 @@ void SecretChatActor::add_inbound_message(std::unique_ptr<logevent::InboundSecre
loop();
}
void SecretChatActor::replay_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message) {
void SecretChatActor::replay_inbound_message(unique_ptr<logevent::InboundSecretMessage> message) {
if (close_flag_) {
return;
}
@ -175,7 +175,7 @@ void SecretChatActor::replay_inbound_message(std::unique_ptr<logevent::InboundSe
loop();
}
void SecretChatActor::replay_outbound_message(std::unique_ptr<logevent::OutboundSecretMessage> message) {
void SecretChatActor::replay_outbound_message(unique_ptr<logevent::OutboundSecretMessage> message) {
if (close_flag_) {
return;
}
@ -316,7 +316,7 @@ void SecretChatActor::send_message_impl(tl_object_ptr<secret_api::DecryptedMessa
return on_outbound_outer_send_message_promise(it->second, std::move(promise));
}
auto binlog_event = std::make_unique<logevent::OutboundSecretMessage>();
auto binlog_event = make_unique<logevent::OutboundSecretMessage>();
binlog_event->chat_id = auth_state_.id;
binlog_event->random_id = random_id;
binlog_event->file = logevent::EncryptedInputFile::from_input_encrypted_file(file);
@ -726,7 +726,7 @@ void SecretChatActor::cancel_chat(Promise<> promise) {
create_logevent_id_ = 0;
}
auto event = std::make_unique<logevent::CloseSecretChat>();
auto event = make_unique<logevent::CloseSecretChat>();
event->chat_id = auth_state_.id;
event->set_logevent_id(binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*event)));
@ -745,7 +745,7 @@ void SecretChatActor::cancel_chat(Promise<> promise) {
yield();
}
void SecretChatActor::do_close_chat_impl(std::unique_ptr<logevent::CloseSecretChat> event) {
void SecretChatActor::do_close_chat_impl(unique_ptr<logevent::CloseSecretChat> event) {
close_flag_ = true;
close_logevent_id_ = event->logevent_id();
LOG(INFO) << "Send messages.discardEncryption";
@ -764,7 +764,7 @@ void SecretChatActor::do_close_chat_impl(std::unique_ptr<logevent::CloseSecretCh
context_->send_net_query(std::move(query), actor_shared(this), true);
}
void SecretChatActor::do_create_chat_impl(std::unique_ptr<logevent::CreateSecretChat> event) {
void SecretChatActor::do_create_chat_impl(unique_ptr<logevent::CreateSecretChat> event) {
LOG(INFO) << *event;
CHECK(event->random_id == auth_state_.id);
create_logevent_id_ = event->logevent_id();
@ -873,7 +873,7 @@ Result<std::tuple<uint64, BufferSlice, int32>> SecretChatActor::decrypt(BufferSl
}
}
Status SecretChatActor::do_inbound_message_encrypted(std::unique_ptr<logevent::InboundSecretMessage> message) {
Status SecretChatActor::do_inbound_message_encrypted(unique_ptr<logevent::InboundSecretMessage> message) {
SCOPE_EXIT {
if (message) {
message->qts_ack.set_value(Unit());
@ -965,8 +965,7 @@ Status SecretChatActor::check_seq_no(int in_seq_no, int out_seq_no, int32 his_la
return Status::OK();
}
Status SecretChatActor::do_inbound_message_decrypted_unchecked(
std::unique_ptr<logevent::InboundSecretMessage> message) {
Status SecretChatActor::do_inbound_message_decrypted_unchecked(unique_ptr<logevent::InboundSecretMessage> message) {
SCOPE_EXIT {
LOG_IF(FATAL, message && message->qts_ack) << "Lost qts_promise";
};
@ -1045,7 +1044,7 @@ Status SecretChatActor::do_inbound_message_decrypted_unchecked(
return do_inbound_message_decrypted(std::move(message));
}
void SecretChatActor::do_outbound_message_impl(std::unique_ptr<logevent::OutboundSecretMessage> binlog_event,
void SecretChatActor::do_outbound_message_impl(unique_ptr<logevent::OutboundSecretMessage> binlog_event,
Promise<> promise) {
binlog_event->crc = crc64(binlog_event->encrypted_message.as_slice());
LOG(INFO) << "Do outbound message: " << *binlog_event << tag("crc", binlog_event->crc);
@ -1192,7 +1191,7 @@ void SecretChatActor::update_seq_no_state(const T &new_seq_no_state) {
return on_seq_no_state_changed();
}
Status SecretChatActor::do_inbound_message_decrypted_pending(std::unique_ptr<logevent::InboundSecretMessage> message) {
Status SecretChatActor::do_inbound_message_decrypted_pending(unique_ptr<logevent::InboundSecretMessage> message) {
// Just save logevent if necessary
auto logevent_id = message->logevent_id();
@ -1217,7 +1216,7 @@ Status SecretChatActor::do_inbound_message_decrypted_pending(std::unique_ptr<log
return Status::OK();
}
Status SecretChatActor::do_inbound_message_decrypted(std::unique_ptr<logevent::InboundSecretMessage> message) {
Status SecretChatActor::do_inbound_message_decrypted(unique_ptr<logevent::InboundSecretMessage> message) {
// InboundSecretMessage
//
// 1. [] => Add logevent. [save_logevent]

View File

@ -101,7 +101,7 @@ class SecretChatActor : public NetQueryCallback {
virtual void on_send_message_error(int64 random_id, Status error, Promise<> promise) = 0;
};
SecretChatActor(int32 id, std::unique_ptr<Context> context, bool can_be_empty);
SecretChatActor(int32 id, unique_ptr<Context> context, bool can_be_empty);
// First query to new chat must be on of this two
void update_chat(telegram_api::object_ptr<telegram_api::EncryptedChat> chat);
@ -110,7 +110,7 @@ class SecretChatActor : public NetQueryCallback {
// Inbound messages
// Logevent is created by SecretChatsManager, because it must contain qts
void add_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message);
void add_inbound_message(unique_ptr<logevent::InboundSecretMessage> message);
// Outbound messages
// Promise will be set just after correspoiding logevent will be SENT to binlog.
@ -127,10 +127,10 @@ class SecretChatActor : public NetQueryCallback {
void send_set_ttl_message(int32 ttl, int64 random_id, Promise<> promise);
// Binlog replay interface
void replay_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message);
void replay_outbound_message(std::unique_ptr<logevent::OutboundSecretMessage> message);
void replay_close_chat(std::unique_ptr<logevent::CloseSecretChat> event);
void replay_create_chat(std::unique_ptr<logevent::CreateSecretChat> event);
void replay_inbound_message(unique_ptr<logevent::InboundSecretMessage> message);
void replay_outbound_message(unique_ptr<logevent::OutboundSecretMessage> message);
void replay_close_chat(unique_ptr<logevent::CloseSecretChat> event);
void replay_create_chat(unique_ptr<logevent::CreateSecretChat> event);
void binlog_replay_finish();
private:
@ -435,7 +435,7 @@ class SecretChatActor : public NetQueryCallback {
};
std::shared_ptr<SecretChatDb> db_;
std::unique_ptr<Context> context_;
unique_ptr<Context> context_;
bool binlog_replay_finish_flag_ = false;
bool close_flag_ = false;
@ -543,14 +543,14 @@ class SecretChatActor : public NetQueryCallback {
};
Container<InboundMessageState> inbound_message_states_;
std::map<int32, std::unique_ptr<logevent::InboundSecretMessage>> pending_inbound_messages_;
std::map<int32, unique_ptr<logevent::InboundSecretMessage>> pending_inbound_messages_;
Result<std::tuple<uint64, BufferSlice, int32>> decrypt(BufferSlice &encrypted_message);
Status do_inbound_message_encrypted(std::unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted_unchecked(std::unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted(std::unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted_pending(std::unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_encrypted(unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted_unchecked(unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted(unique_ptr<logevent::InboundSecretMessage> message);
Status do_inbound_message_decrypted_pending(unique_ptr<logevent::InboundSecretMessage> message);
void on_inbound_save_message_finish(uint64 state_id);
void on_inbound_save_changes_finish(uint64 state_id);
@ -558,7 +558,7 @@ class SecretChatActor : public NetQueryCallback {
// OutboundMessage
struct OutboundMessageState {
std::unique_ptr<logevent::OutboundSecretMessage> message;
unique_ptr<logevent::OutboundSecretMessage> message;
Promise<> outer_send_message_finish;
Promise<> send_message_finish;
@ -593,7 +593,7 @@ class SecretChatActor : public NetQueryCallback {
void send_message_impl(tl_object_ptr<secret_api::DecryptedMessage> message,
tl_object_ptr<telegram_api::InputEncryptedFile> file, int32 flags, Promise<> promise);
void do_outbound_message_impl(std::unique_ptr<logevent::OutboundSecretMessage>, Promise<> promise);
void do_outbound_message_impl(unique_ptr<logevent::OutboundSecretMessage>, Promise<> promise);
Result<BufferSlice> create_encrypted_message(int32 layer, int32 my_in_seq_no, int32 my_out_seq_no,
tl_object_ptr<secret_api::DecryptedMessage> &message);
@ -612,7 +612,7 @@ class SecretChatActor : public NetQueryCallback {
// DiscardEncryption
void on_fatal_error(Status status);
void do_close_chat_impl(std::unique_ptr<logevent::CloseSecretChat> event);
void do_close_chat_impl(unique_ptr<logevent::CloseSecretChat> event);
void on_discard_encryption_result(NetQueryPtr result);
// Other
@ -668,7 +668,7 @@ class SecretChatActor : public NetQueryCallback {
void on_dh_config(telegram_api::messages_dhConfigNotModified &dh_not_modified);
void on_dh_config(telegram_api::messages_dhConfig &dh);
void do_create_chat_impl(std::unique_ptr<logevent::CreateSecretChat> event);
void do_create_chat_impl(unique_ptr<logevent::CreateSecretChat> event);
SecretChatId get_secret_chat_id() {
return SecretChatId(auth_state_.id);

View File

@ -258,7 +258,7 @@ void SecretChatsManager::on_update_message(tl_object_ptr<telegram_api::updateNew
}
}
auto event = std::make_unique<logevent::InboundSecretMessage>();
auto event = make_unique<logevent::InboundSecretMessage>();
event->qts = qts;
downcast_call(*update->message_, [&](auto &x) {
event->chat_id = x.chat_id_;
@ -295,17 +295,17 @@ void SecretChatsManager::replay_binlog_event(BinlogEvent &&binlog_event) {
LOG(INFO) << "Process binlog event " << *message;
switch (message->get_type()) {
case logevent::SecretChatEvent::Type::InboundSecretMessage:
return replay_inbound_message(std::unique_ptr<logevent::InboundSecretMessage>(
static_cast<logevent::InboundSecretMessage *>(message.release())));
return replay_inbound_message(
unique_ptr<logevent::InboundSecretMessage>(static_cast<logevent::InboundSecretMessage *>(message.release())));
case logevent::SecretChatEvent::Type::OutboundSecretMessage:
return replay_outbound_message(std::unique_ptr<logevent::OutboundSecretMessage>(
return replay_outbound_message(unique_ptr<logevent::OutboundSecretMessage>(
static_cast<logevent::OutboundSecretMessage *>(message.release())));
case logevent::SecretChatEvent::Type::CloseSecretChat:
return replay_close_chat(
std::unique_ptr<logevent::CloseSecretChat>(static_cast<logevent::CloseSecretChat *>(message.release())));
unique_ptr<logevent::CloseSecretChat>(static_cast<logevent::CloseSecretChat *>(message.release())));
case logevent::SecretChatEvent::Type::CreateSecretChat:
return replay_create_chat(
std::unique_ptr<logevent::CreateSecretChat>(static_cast<logevent::CreateSecretChat *>(message.release())));
unique_ptr<logevent::CreateSecretChat>(static_cast<logevent::CreateSecretChat *>(message.release())));
}
LOG(FATAL) << "Unknown logevent type " << tag("type", format::as_hex(static_cast<int32>(message->get_type())));
}
@ -317,13 +317,13 @@ void SecretChatsManager::binlog_replay_finish() {
}
}
void SecretChatsManager::replay_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message) {
void SecretChatsManager::replay_inbound_message(unique_ptr<logevent::InboundSecretMessage> message) {
LOG(INFO) << "Replay inbound secret message in chat " << message->chat_id << " with qts " << message->qts;
auto actor = get_chat_actor(message->chat_id);
send_closure_later(actor, &SecretChatActor::replay_inbound_message, std::move(message));
}
void SecretChatsManager::add_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message) {
void SecretChatsManager::add_inbound_message(unique_ptr<logevent::InboundSecretMessage> message) {
LOG(INFO) << "Process inbound secret message in chat " << message->chat_id << " with qts " << message->qts;
message->qts_ack = add_qts(message->qts);
@ -331,21 +331,21 @@ void SecretChatsManager::add_inbound_message(std::unique_ptr<logevent::InboundSe
send_closure(actor, &SecretChatActor::add_inbound_message, std::move(message));
}
void SecretChatsManager::replay_close_chat(std::unique_ptr<logevent::CloseSecretChat> message) {
void SecretChatsManager::replay_close_chat(unique_ptr<logevent::CloseSecretChat> message) {
LOG(INFO) << "Replay close secret chat " << message->chat_id;
auto actor = get_chat_actor(message->chat_id);
send_closure_later(actor, &SecretChatActor::replay_close_chat, std::move(message));
}
void SecretChatsManager::replay_create_chat(std::unique_ptr<logevent::CreateSecretChat> message) {
void SecretChatsManager::replay_create_chat(unique_ptr<logevent::CreateSecretChat> message) {
LOG(INFO) << "Replay create secret chat " << message->random_id;
auto actor = create_chat_actor(message->random_id);
send_closure_later(actor, &SecretChatActor::replay_create_chat, std::move(message));
}
void SecretChatsManager::replay_outbound_message(std::unique_ptr<logevent::OutboundSecretMessage> message) {
void SecretChatsManager::replay_outbound_message(unique_ptr<logevent::OutboundSecretMessage> message) {
LOG(INFO) << "Replay oubound secret message in chat " << message->chat_id;
auto actor = get_chat_actor(message->chat_id);
@ -365,10 +365,10 @@ ActorId<SecretChatActor> SecretChatsManager::create_chat_actor(int32 id) {
return create_chat_actor_impl(id, true);
}
std::unique_ptr<SecretChatActor::Context> SecretChatsManager::make_secret_chat_context(int32 id) {
unique_ptr<SecretChatActor::Context> SecretChatsManager::make_secret_chat_context(int32 id) {
class Context : public SecretChatActor::Context {
public:
Context(int32 id, ActorShared<SecretChatsManager> parent, std::unique_ptr<SecretChatDb> secret_chat_db)
Context(int32 id, ActorShared<SecretChatsManager> parent, unique_ptr<SecretChatDb> secret_chat_db)
: secret_chat_id_(SecretChatId(id)), parent_(std::move(parent)), secret_chat_db_(std::move(secret_chat_db)) {
sequence_dispatcher_ = create_actor<SequenceDispatcher>("SecretChat SequenceDispatcher");
}
@ -472,10 +472,10 @@ std::unique_ptr<SecretChatActor::Context> SecretChatsManager::make_secret_chat_c
SecretChatId secret_chat_id_;
ActorOwn<SequenceDispatcher> sequence_dispatcher_;
ActorShared<SecretChatsManager> parent_;
std::unique_ptr<SecretChatDb> secret_chat_db_;
unique_ptr<SecretChatDb> secret_chat_db_;
};
return std::make_unique<Context>(id, actor_shared(this, id),
std::make_unique<SecretChatDb>(G()->td_db()->get_binlog_pmc_shared(), id));
return make_unique<Context>(id, actor_shared(this, id),
td::make_unique<SecretChatDb>(G()->td_db()->get_binlog_pmc_shared(), id));
}
ActorId<SecretChatActor> SecretChatsManager::create_chat_actor_impl(int32 id, bool can_be_empty) {

View File

@ -73,13 +73,13 @@ class SecretChatsManager : public Actor {
void flush_pending_chat_updates();
void do_update_chat(tl_object_ptr<telegram_api::updateEncryption> update);
void replay_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message);
void add_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message);
void replay_outbound_message(std::unique_ptr<logevent::OutboundSecretMessage> message);
void replay_close_chat(std::unique_ptr<logevent::CloseSecretChat> message);
void replay_create_chat(std::unique_ptr<logevent::CreateSecretChat> message);
void replay_inbound_message(unique_ptr<logevent::InboundSecretMessage> message);
void add_inbound_message(unique_ptr<logevent::InboundSecretMessage> message);
void replay_outbound_message(unique_ptr<logevent::OutboundSecretMessage> message);
void replay_close_chat(unique_ptr<logevent::CloseSecretChat> message);
void replay_create_chat(unique_ptr<logevent::CreateSecretChat> message);
std::unique_ptr<SecretChatActor::Context> make_secret_chat_context(int32 id);
unique_ptr<SecretChatActor::Context> make_secret_chat_context(int32 id);
ActorId<SecretChatActor> get_chat_actor(int32 id);
ActorId<SecretChatActor> create_chat_actor(int32 id);
ActorId<SecretChatActor> create_chat_actor_impl(int32 id, bool can_be_empty);

View File

@ -929,7 +929,7 @@ tl_object_ptr<telegram_api::InputStickerSet> StickersManager::get_input_sticker_
return get_input_sticker_set(sticker_set);
}
FileId StickersManager::on_get_sticker(std::unique_ptr<Sticker> new_sticker, bool replace) {
FileId StickersManager::on_get_sticker(unique_ptr<Sticker> new_sticker, bool replace) {
auto file_id = new_sticker->file_id;
LOG(INFO) << "Receive sticker " << file_id;
auto &s = stickers_[file_id];
@ -1150,7 +1150,7 @@ FileId StickersManager::dup_sticker(FileId new_id, FileId old_id) {
CHECK(old_sticker != nullptr);
auto &new_sticker = stickers_[new_id];
CHECK(!new_sticker);
new_sticker = std::make_unique<Sticker>(*old_sticker);
new_sticker = make_unique<Sticker>(*old_sticker);
new_sticker->file_id = new_id;
// there is no reason to dup sticker_thumb
new_sticker->message_thumbnail.file_id = td_->file_manager_->dup_file_id(new_sticker->message_thumbnail.file_id);

View File

@ -303,7 +303,7 @@ class StickersManager : public Actor {
Sticker *get_sticker(FileId file_id);
const Sticker *get_sticker(FileId file_id) const;
FileId on_get_sticker(std::unique_ptr<Sticker> new_sticker, bool replace);
FileId on_get_sticker(unique_ptr<Sticker> new_sticker, bool replace);
StickerSet *get_sticker_set(int64 sticker_set_id);
const StickerSet *get_sticker_set(int64 sticker_set_id) const;

View File

@ -3107,7 +3107,7 @@ class GetInviteTextRequest : public RequestActor<string> {
};
/** Td **/
Td::Td(std::unique_ptr<TdCallback> callback) : callback_(std::move(callback)) {
Td::Td(unique_ptr<TdCallback> callback) : callback_(std::move(callback)) {
}
void Td::on_alarm_timeout_callback(void *td_ptr, int64 alarm_id) {
@ -4059,7 +4059,7 @@ Status Td::init(DbKey key) {
};
G()->set_shared_config(
std::make_unique<ConfigShared>(G()->td_db()->get_config_pmc(), std::make_unique<ConfigSharedCallback>()));
make_unique<ConfigShared>(G()->td_db()->get_config_pmc(), make_unique<ConfigSharedCallback>()));
config_manager_ = create_actor<ConfigManager>("ConfigManager", create_reference());
G()->set_config_manager(config_manager_.get());
@ -4092,7 +4092,7 @@ Status Td::init(DbKey key) {
options_.language_code = G()->shared_config().get_option_string("language_pack_id");
options_.is_emulator = G()->shared_config().get_option_boolean("is_emulator");
// options_.proxy = Proxy();
G()->set_mtproto_header(std::make_unique<MtprotoHeader>(options_));
G()->set_mtproto_header(make_unique<MtprotoHeader>(options_));
if (!G()->shared_config().have_option("message_text_length_max")) {
G()->shared_config().set_option_integer("message_text_length_max", 4096);
@ -4102,11 +4102,11 @@ Status Td::init(DbKey key) {
}
VLOG(td_init) << "Create NetQueryDispatcher";
auto net_query_dispatcher = std::make_unique<NetQueryDispatcher>([&] { return create_reference(); });
auto net_query_dispatcher = make_unique<NetQueryDispatcher>([&] { return create_reference(); });
G()->set_net_query_dispatcher(std::move(net_query_dispatcher));
VLOG(td_init) << "Create AuthManager";
auth_manager_ = std::make_unique<AuthManager>(parameters_.api_id, parameters_.api_hash, create_reference());
auth_manager_ = td::make_unique<AuthManager>(parameters_.api_id, parameters_.api_hash, create_reference());
auth_manager_actor_ = register_actor("AuthManager", auth_manager_.get());
VLOG(td_init) << "Create FileManager";
@ -4131,7 +4131,7 @@ Status Td::init(DbKey key) {
private:
Td *td_;
};
file_manager_ = std::make_unique<FileManager>(std::make_unique<FileManagerContext>(this));
file_manager_ = make_unique<FileManager>(make_unique<FileManagerContext>(this));
file_manager_actor_ = register_actor("FileManager", file_manager_.get());
file_manager_->init_actor();
G()->set_file_manager(file_manager_actor_.get());
@ -4144,24 +4144,24 @@ Status Td::init(DbKey key) {
videos_manager_ = make_unique<VideosManager>(this);
voice_notes_manager_ = make_unique<VoiceNotesManager>(this);
animations_manager_ = std::make_unique<AnimationsManager>(this, create_reference());
animations_manager_ = make_unique<AnimationsManager>(this, create_reference());
animations_manager_actor_ = register_actor("AnimationsManager", animations_manager_.get());
G()->set_animations_manager(animations_manager_actor_.get());
contacts_manager_ = std::make_unique<ContactsManager>(this, create_reference());
contacts_manager_ = make_unique<ContactsManager>(this, create_reference());
contacts_manager_actor_ = register_actor("ContactsManager", contacts_manager_.get());
G()->set_contacts_manager(contacts_manager_actor_.get());
inline_queries_manager_ = std::make_unique<InlineQueriesManager>(this, create_reference());
inline_queries_manager_ = make_unique<InlineQueriesManager>(this, create_reference());
inline_queries_manager_actor_ = register_actor("InlineQueriesManager", inline_queries_manager_.get());
messages_manager_ = std::make_unique<MessagesManager>(this, create_reference());
messages_manager_ = make_unique<MessagesManager>(this, create_reference());
messages_manager_actor_ = register_actor("MessagesManager", messages_manager_.get());
G()->set_messages_manager(messages_manager_actor_.get());
stickers_manager_ = std::make_unique<StickersManager>(this, create_reference());
stickers_manager_ = make_unique<StickersManager>(this, create_reference());
stickers_manager_actor_ = register_actor("StickersManager", stickers_manager_.get());
G()->set_stickers_manager(stickers_manager_actor_.get());
updates_manager_ = std::make_unique<UpdatesManager>(this, create_reference());
updates_manager_ = make_unique<UpdatesManager>(this, create_reference());
updates_manager_actor_ = register_actor("UpdatesManager", updates_manager_.get());
G()->set_updates_manager(updates_manager_actor_.get());
web_pages_manager_ = std::make_unique<WebPagesManager>(this, create_reference());
web_pages_manager_ = make_unique<WebPagesManager>(this, create_reference());
web_pages_manager_actor_ = register_actor("WebPagesManager", web_pages_manager_.get());
G()->set_web_pages_manager(web_pages_manager_actor_.get());

View File

@ -128,23 +128,23 @@ class Td final : public NetQueryCallback {
unique_ptr<VideosManager> videos_manager_;
unique_ptr<VoiceNotesManager> voice_notes_manager_;
std::unique_ptr<AnimationsManager> animations_manager_;
unique_ptr<AnimationsManager> animations_manager_;
ActorOwn<AnimationsManager> animations_manager_actor_;
std::unique_ptr<AuthManager> auth_manager_;
unique_ptr<AuthManager> auth_manager_;
ActorOwn<AuthManager> auth_manager_actor_;
std::unique_ptr<ContactsManager> contacts_manager_;
unique_ptr<ContactsManager> contacts_manager_;
ActorOwn<ContactsManager> contacts_manager_actor_;
std::unique_ptr<FileManager> file_manager_;
unique_ptr<FileManager> file_manager_;
ActorOwn<FileManager> file_manager_actor_;
std::unique_ptr<InlineQueriesManager> inline_queries_manager_;
unique_ptr<InlineQueriesManager> inline_queries_manager_;
ActorOwn<InlineQueriesManager> inline_queries_manager_actor_;
std::unique_ptr<MessagesManager> messages_manager_;
unique_ptr<MessagesManager> messages_manager_;
ActorOwn<MessagesManager> messages_manager_actor_;
std::unique_ptr<StickersManager> stickers_manager_;
unique_ptr<StickersManager> stickers_manager_;
ActorOwn<StickersManager> stickers_manager_actor_;
std::unique_ptr<UpdatesManager> updates_manager_;
unique_ptr<UpdatesManager> updates_manager_;
ActorOwn<UpdatesManager> updates_manager_actor_;
std::unique_ptr<WebPagesManager> web_pages_manager_;
unique_ptr<WebPagesManager> web_pages_manager_;
ActorOwn<WebPagesManager> web_pages_manager_actor_;
ActorOwn<CallManager> call_manager_;

View File

@ -346,8 +346,8 @@ Status TdDb::init(int32 scheduler_id, const TdParameters &parameters, DbKey key,
Binlog *binlog_ptr = nullptr;
auto binlog = std::shared_ptr<Binlog>(new Binlog, [&](Binlog *ptr) { binlog_ptr = ptr; });
auto binlog_pmc = std::make_unique<BinlogKeyValue<Binlog>>();
auto config_pmc = std::make_unique<BinlogKeyValue<Binlog>>();
auto binlog_pmc = make_unique<BinlogKeyValue<Binlog>>();
auto config_pmc = make_unique<BinlogKeyValue<Binlog>>();
binlog_pmc->external_init_begin(static_cast<int32>(LogEvent::HandlerType::BinlogPmcMagic));
config_pmc->external_init_begin(static_cast<int32>(LogEvent::HandlerType::ConfigPmcMagic));
@ -400,7 +400,7 @@ Status TdDb::init(int32 scheduler_id, const TdParameters &parameters, DbKey key,
config_pmc.reset();
CHECK(binlog_ptr != nullptr);
auto concurrent_binlog = std::make_shared<ConcurrentBinlog>(std::unique_ptr<Binlog>(binlog_ptr), scheduler_id);
auto concurrent_binlog = std::make_shared<ConcurrentBinlog>(unique_ptr<Binlog>(binlog_ptr), scheduler_id);
concurrent_binlog_pmc->external_init_finish(concurrent_binlog);
concurrent_config_pmc->external_init_finish(concurrent_binlog);
@ -415,9 +415,8 @@ Status TdDb::init(int32 scheduler_id, const TdParameters &parameters, DbKey key,
TdDb::TdDb() = default;
TdDb::~TdDb() = default;
Result<std::unique_ptr<TdDb>> TdDb::open(int32 scheduler_id, const TdParameters &parameters, DbKey key,
Events &events) {
auto db = std::make_unique<TdDb>();
Result<unique_ptr<TdDb>> TdDb::open(int32 scheduler_id, const TdParameters &parameters, DbKey key, Events &events) {
auto db = make_unique<TdDb>();
TRY_STATUS(db->init(scheduler_id, parameters, std::move(key), events));
return std::move(db);
}

View File

@ -51,8 +51,7 @@ class TdDb {
~TdDb();
struct Events;
static Result<std::unique_ptr<TdDb>> open(int32 scheduler_id, const TdParameters &parameters, DbKey key,
Events &events);
static Result<unique_ptr<TdDb>> open(int32 scheduler_id, const TdParameters &parameters, DbKey key, Events &events);
static Result<EncryptionInfo> check_encryption(const TdParameters &parameters);
static Status destroy(const TdParameters &parameters);
@ -99,7 +98,7 @@ class TdDb {
std::shared_ptr<FileDbInterface> file_db_;
std::shared_ptr<SqliteKeyValueSafe> common_kv_safe_;
std::unique_ptr<SqliteKeyValueAsyncInterface> common_kv_async_;
unique_ptr<SqliteKeyValueAsyncInterface> common_kv_async_;
std::shared_ptr<MessagesDbSyncSafeInterface> messages_db_sync_safe_;
std::shared_ptr<MessagesDbAsyncInterface> messages_db_async_;

View File

@ -44,7 +44,7 @@ tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId
td_->file_manager_->get_file_object(file_id));
}
FileId VideoNotesManager::on_get_video_note(std::unique_ptr<VideoNote> new_video_note, bool replace) {
FileId VideoNotesManager::on_get_video_note(unique_ptr<VideoNote> new_video_note, bool replace) {
auto file_id = new_video_note->file_id;
LOG(INFO) << "Receive video note " << file_id;
auto &v = video_notes_[file_id];
@ -99,7 +99,7 @@ FileId VideoNotesManager::dup_video_note(FileId new_id, FileId old_id) {
CHECK(old_video_note != nullptr);
auto &new_video_note = video_notes_[new_id];
CHECK(!new_video_note);
new_video_note = std::make_unique<VideoNote>(*old_video_note);
new_video_note = make_unique<VideoNote>(*old_video_note);
new_video_note->file_id = new_id;
new_video_note->thumbnail.file_id = td_->file_manager_->dup_file_id(new_video_note->thumbnail.file_id);
return new_id;

View File

@ -70,7 +70,7 @@ class VideoNotesManager {
const VideoNote *get_video_note(FileId file_id) const;
FileId on_get_video_note(std::unique_ptr<VideoNote> new_video_note, bool replace);
FileId on_get_video_note(unique_ptr<VideoNote> new_video_note, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<VideoNote>, FileIdHash> video_notes_;

View File

@ -46,7 +46,7 @@ tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {
get_photo_size_object(td_->file_manager_.get(), &video->thumbnail), td_->file_manager_->get_file_object(file_id));
}
FileId VideosManager::on_get_video(std::unique_ptr<Video> new_video, bool replace) {
FileId VideosManager::on_get_video(unique_ptr<Video> new_video, bool replace) {
auto file_id = new_video->file_id;
LOG(INFO) << "Receive video " << file_id;
auto &v = videos_[file_id];
@ -121,7 +121,7 @@ FileId VideosManager::dup_video(FileId new_id, FileId old_id) {
CHECK(old_video != nullptr);
auto &new_video = videos_[new_id];
CHECK(!new_video);
new_video = std::make_unique<Video>(*old_video);
new_video = make_unique<Video>(*old_video);
new_video->file_id = new_id;
new_video->thumbnail.file_id = td_->file_manager_->dup_file_id(new_video->thumbnail.file_id);
return new_id;

View File

@ -82,7 +82,7 @@ class VideosManager {
const Video *get_video(FileId file_id) const;
FileId on_get_video(std::unique_ptr<Video> new_video, bool replace);
FileId on_get_video(unique_ptr<Video> new_video, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<Video>, FileIdHash> videos_;

View File

@ -43,7 +43,7 @@ tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId
td_->file_manager_->get_file_object(file_id));
}
FileId VoiceNotesManager::on_get_voice_note(std::unique_ptr<VoiceNote> new_voice_note, bool replace) {
FileId VoiceNotesManager::on_get_voice_note(unique_ptr<VoiceNote> new_voice_note, bool replace) {
auto file_id = new_voice_note->file_id;
LOG(INFO) << "Receive voice note " << file_id;
auto &v = voice_notes_[file_id];
@ -82,7 +82,7 @@ FileId VoiceNotesManager::dup_voice_note(FileId new_id, FileId old_id) {
CHECK(old_voice_note != nullptr);
auto &new_voice_note = voice_notes_[new_id];
CHECK(!new_voice_note);
new_voice_note = std::make_unique<VoiceNote>(*old_voice_note);
new_voice_note = make_unique<VoiceNote>(*old_voice_note);
new_voice_note->file_id = new_id;
return new_id;
}
@ -129,7 +129,7 @@ bool VoiceNotesManager::merge_voice_notes(FileId new_id, FileId old_id, bool can
void VoiceNotesManager::create_voice_note(FileId file_id, string mime_type, int32 duration, string waveform,
bool replace) {
auto v = std::make_unique<VoiceNote>();
auto v = make_unique<VoiceNote>();
v->file_id = file_id;
v->mime_type = std::move(mime_type);
v->duration = max(duration, 0);

View File

@ -63,7 +63,7 @@ class VoiceNotesManager {
const VoiceNote *get_voice_note(FileId file_id) const;
FileId on_get_voice_note(std::unique_ptr<VoiceNote> new_voice_note, bool replace);
FileId on_get_voice_note(unique_ptr<VoiceNote> new_voice_note, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<VoiceNote>, FileIdHash> voice_notes_;

View File

@ -462,14 +462,14 @@ class WebPagesManager::PageBlock {
call_impl(type, this, [&](const auto *object) { store(*object, storer); });
}
template <class T>
static std::unique_ptr<PageBlock> parse(T &parser) {
static unique_ptr<PageBlock> parse(T &parser) {
using ::td::parse;
Type type;
parse(type, parser);
std::unique_ptr<PageBlock> res;
unique_ptr<PageBlock> res;
call_impl(type, nullptr, [&](const auto *ptr) {
using ObjT = std::decay_t<decltype(*ptr)>;
auto object = std::make_unique<ObjT>();
auto object = make_unique<ObjT>();
parse(*object, parser);
res = std::move(object);
});
@ -2353,7 +2353,7 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
}
case telegram_api::pageBlockPreformatted::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockPreformatted>(page_block_ptr);
return make_unique<PageBlockPreformatted>(get_rich_text(std::move(page_block->text_)),
return td::make_unique<PageBlockPreformatted>(get_rich_text(std::move(page_block->text_)),
std::move(page_block->language_));
}
case telegram_api::pageBlockFooter::ID: {
@ -2364,11 +2364,11 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
return make_unique<PageBlockDivider>();
case telegram_api::pageBlockAnchor::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockAnchor>(page_block_ptr);
return make_unique<PageBlockAnchor>(std::move(page_block->name_));
return td::make_unique<PageBlockAnchor>(std::move(page_block->name_));
}
case telegram_api::pageBlockList::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockList>(page_block_ptr);
return make_unique<PageBlockList>(get_rich_texts(std::move(page_block->items_)), page_block->ordered_);
return td::make_unique<PageBlockList>(get_rich_texts(std::move(page_block->items_)), page_block->ordered_);
}
case telegram_api::pageBlockBlockquote::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockBlockquote>(page_block_ptr);
@ -2431,7 +2431,7 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
} else {
poster_photo = it->second;
}
return make_unique<PageBlockEmbedded>(std::move(page_block->url_), std::move(page_block->html_),
return td::make_unique<PageBlockEmbedded>(std::move(page_block->url_), std::move(page_block->html_),
std::move(poster_photo), get_dimensions(page_block->w_, page_block->h_),
get_rich_text(std::move(page_block->caption_)), is_full_width,
allow_scrolling);
@ -2445,20 +2445,20 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
} else {
author_photo = it->second;
}
return make_unique<PageBlockEmbeddedPost>(
return td::make_unique<PageBlockEmbeddedPost>(
std::move(page_block->url_), std::move(page_block->author_), std::move(author_photo), page_block->date_,
get_page_blocks(std::move(page_block->blocks_), animations, audios, photos, videos),
get_rich_text(std::move(page_block->caption_)));
}
case telegram_api::pageBlockCollage::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockCollage>(page_block_ptr);
return make_unique<PageBlockCollage>(
return td::make_unique<PageBlockCollage>(
get_page_blocks(std::move(page_block->items_), animations, audios, photos, videos),
get_rich_text(std::move(page_block->caption_)));
}
case telegram_api::pageBlockSlideshow::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockSlideshow>(page_block_ptr);
return make_unique<PageBlockSlideshow>(
return td::make_unique<PageBlockSlideshow>(
get_page_blocks(std::move(page_block->items_), animations, audios, photos, videos),
get_rich_text(std::move(page_block->caption_)));
}
@ -2476,12 +2476,12 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
if (td_->contacts_manager_->have_channel_force(channel_id)) {
td_->contacts_manager_->on_get_chat(std::move(page_block->channel_));
LOG(INFO) << "Receive known min " << channel_id;
return make_unique<PageBlockChatLink>(td_->contacts_manager_->get_channel_title(channel_id),
return td::make_unique<PageBlockChatLink>(td_->contacts_manager_->get_channel_title(channel_id),
*td_->contacts_manager_->get_channel_dialog_photo(channel_id),
td_->contacts_manager_->get_channel_username(channel_id));
} else {
return make_unique<PageBlockChatLink>(std::move(channel->title_),
get_dialog_photo(td_->file_manager_.get(), std::move(channel->photo_)),
return td::make_unique<PageBlockChatLink>(
std::move(channel->title_), get_dialog_photo(td_->file_manager_.get(), std::move(channel->photo_)),
std::move(channel->username_));
}
} else {

View File

@ -30,7 +30,7 @@ namespace td {
FileDownloader::FileDownloader(const FullRemoteFileLocation &remote, const LocalFileLocation &local, int64 size,
string name, const FileEncryptionKey &encryption_key, bool is_small, bool search_file,
std::unique_ptr<Callback> callback)
unique_ptr<Callback> callback)
: remote_(remote)
, local_(local)
, size_(size)

View File

@ -34,7 +34,7 @@ class FileDownloader : public FileLoader {
FileDownloader(const FullRemoteFileLocation &remote, const LocalFileLocation &local, int64 size, string name,
const FileEncryptionKey &encryption_key, bool is_small, bool search_file,
std::unique_ptr<Callback> callback);
unique_ptr<Callback> callback);
// Should just implement all parent pure virtual methods.
// Must not call any of them...
@ -46,7 +46,7 @@ class FileDownloader : public FileLoader {
int64 size_;
string name_;
FileEncryptionKey encryption_key_;
std::unique_ptr<Callback> callback_;
unique_ptr<Callback> callback_;
bool only_check_{false};
string path_;

View File

@ -13,7 +13,7 @@
namespace td {
FileFromBytes::FileFromBytes(FileType type, BufferSlice bytes, string name, std::unique_ptr<Callback> callback)
FileFromBytes::FileFromBytes(FileType type, BufferSlice bytes, string name, unique_ptr<Callback> callback)
: type_(type), bytes_(std::move(bytes)), name_(std::move(name)), callback_(std::move(callback)) {
}

View File

@ -29,7 +29,7 @@ class FileFromBytes : public FileLoaderActor {
virtual void on_error(Status status) = 0;
};
FileFromBytes(FileType type, BufferSlice bytes, string name, std::unique_ptr<Callback> callback);
FileFromBytes(FileType type, BufferSlice bytes, string name, unique_ptr<Callback> callback);
// Should just implement all parent pure virtual methods.
// Must not call any of them...
@ -38,7 +38,7 @@ class FileFromBytes : public FileLoaderActor {
BufferSlice bytes_;
string name_;
std::unique_ptr<Callback> callback_;
unique_ptr<Callback> callback_;
FileFd fd_;
string path_;

View File

@ -42,7 +42,7 @@ class FileGenerateActor : public Actor {
class FileDownloadGenerateActor : public FileGenerateActor {
public:
FileDownloadGenerateActor(FileType file_type, FileId file_id, std::unique_ptr<FileGenerateCallback> callback,
FileDownloadGenerateActor(FileType file_type, FileId file_id, unique_ptr<FileGenerateCallback> callback,
ActorShared<> parent)
: file_type_(file_type), file_id_(file_id), callback_(std::move(callback)), parent_(std::move(parent)) {
}
@ -56,7 +56,7 @@ class FileDownloadGenerateActor : public FileGenerateActor {
private:
FileType file_type_;
FileId file_id_;
std::unique_ptr<FileGenerateCallback> callback_;
unique_ptr<FileGenerateCallback> callback_;
ActorShared<> parent_;
void start_up() override {
@ -79,7 +79,7 @@ class FileDownloadGenerateActor : public FileGenerateActor {
ActorId<FileDownloadGenerateActor> parent_;
};
send_closure(G()->file_manager(), &FileManager::download, file_id_, std::make_unique<Callback>(actor_id(this)), 1);
send_closure(G()->file_manager(), &FileManager::download, file_id_, std::make_shared<Callback>(actor_id(this)), 1);
}
void hangup() override {
send_closure(G()->file_manager(), &FileManager::download, file_id_, nullptr, 0);
@ -108,7 +108,7 @@ class FileDownloadGenerateActor : public FileGenerateActor {
class MapDownloadGenerateActor : public FileGenerateActor {
public:
MapDownloadGenerateActor(string conversion, std::unique_ptr<FileGenerateCallback> callback, ActorShared<> parent)
MapDownloadGenerateActor(string conversion, unique_ptr<FileGenerateCallback> callback, ActorShared<> parent)
: conversion_(std::move(conversion)), callback_(std::move(callback)), parent_(std::move(parent)) {
}
void file_generate_progress(int32 expected_size, int32 local_prefix_size, Promise<> promise) override {
@ -120,7 +120,7 @@ class MapDownloadGenerateActor : public FileGenerateActor {
private:
string conversion_;
std::unique_ptr<FileGenerateCallback> callback_;
unique_ptr<FileGenerateCallback> callback_;
ActorShared<> parent_;
string file_name_;
@ -233,7 +233,7 @@ class FileExternalGenerateActor : public FileGenerateActor {
public:
FileExternalGenerateActor(uint64 query_id, const FullGenerateFileLocation &generate_location,
const LocalFileLocation &local_location, string name,
std::unique_ptr<FileGenerateCallback> callback, ActorShared<> parent)
unique_ptr<FileGenerateCallback> callback, ActorShared<> parent)
: query_id_(query_id)
, generate_location_(generate_location)
, local_(local_location)
@ -260,7 +260,7 @@ class FileExternalGenerateActor : public FileGenerateActor {
LocalFileLocation local_;
string name_;
string path_;
std::unique_ptr<FileGenerateCallback> callback_;
unique_ptr<FileGenerateCallback> callback_;
ActorShared<> parent_;
void start_up() override {
@ -342,7 +342,7 @@ FileGenerateManager::Query &FileGenerateManager::Query::operator=(Query &&other)
void FileGenerateManager::generate_file(uint64 query_id, const FullGenerateFileLocation &generate_location,
const LocalFileLocation &local_location, string name,
std::unique_ptr<FileGenerateCallback> callback) {
unique_ptr<FileGenerateCallback> callback) {
CHECK(query_id != 0);
auto it_flag = query_id_to_query_.insert(std::make_pair(query_id, Query{}));
CHECK(it_flag.second) << "Query id must be unique";

View File

@ -36,8 +36,7 @@ class FileGenerateManager : public Actor {
}
void generate_file(uint64 query_id, const FullGenerateFileLocation &generate_location,
const LocalFileLocation &local_location, string name,
std::unique_ptr<FileGenerateCallback> callback);
const LocalFileLocation &local_location, string name, unique_ptr<FileGenerateCallback> callback);
void cancel(uint64 query_id);
// external updates about file generation state

View File

@ -31,7 +31,7 @@ class FileHashUploader : public FileLoaderActor {
virtual void on_error(Status status) = 0;
};
FileHashUploader(const FullLocalFileLocation &local, int64 size, std::unique_ptr<Callback> callback)
FileHashUploader(const FullLocalFileLocation &local, int64 size, unique_ptr<Callback> callback)
: local_(local), size_(size), size_left_(size), callback_(std::move(callback)) {
}

View File

@ -1254,7 +1254,7 @@ class FileData {
GenerateFileLocation generate;
parse(generate, parser);
if (generate.type() == GenerateFileLocation::Type::Full) {
generate_ = std::make_unique<FullGenerateFileLocation>(generate.full());
generate_ = make_unique<FullGenerateFileLocation>(generate.full());
} else {
generate_ = nullptr;
}

View File

@ -426,7 +426,7 @@ void prepare_path_for_pmc(FileType file_type, string &path) {
}
} // namespace
FileManager::FileManager(std::unique_ptr<Context> context) : context_(std::move(context)) {
FileManager::FileManager(unique_ptr<Context> context) : context_(std::move(context)) {
if (G()->parameters().use_file_db) {
file_db_ = G()->td_db()->get_file_db_shared();
}
@ -699,7 +699,8 @@ Result<FileId> FileManager::register_generate(FileType file_type, FileLocationSo
string original_path, string conversion, DialogId owner_dialog_id,
int64 expected_size) {
FileData data;
data.generate_ = make_unique<FullGenerateFileLocation>(file_type, std::move(original_path), std::move(conversion));
data.generate_ =
td::make_unique<FullGenerateFileLocation>(file_type, std::move(original_path), std::move(conversion));
data.owner_dialog_id_ = owner_dialog_id;
data.expected_size_ = expected_size;
return register_file(std::move(data), file_location_source, "register_generate", false);
@ -742,7 +743,7 @@ Result<FileId> FileManager::register_file(FileData data, FileLocationSource file
// create FileNode
auto file_node_id = next_file_node_id();
auto &node = file_nodes_[file_node_id];
node = std::make_unique<FileNode>(std::move(data.local_), std::move(data.remote_), std::move(data.generate_),
node = td::make_unique<FileNode>(std::move(data.local_), std::move(data.remote_), std::move(data.generate_),
data.size_, data.expected_size_, std::move(data.remote_name_), std::move(data.url_),
data.owner_dialog_id_, std::move(data.encryption_key_), file_id,
static_cast<int8>(has_remote));
@ -1209,7 +1210,7 @@ void FileManager::clear_from_pmc(FileNodePtr node) {
data.remote_ = node->remote_;
}
if (file_view.has_generate_location()) {
data.generate_ = std::make_unique<FullGenerateFileLocation>(*node->generate_);
data.generate_ = make_unique<FullGenerateFileLocation>(*node->generate_);
}
file_db_->clear_file_data(node->pmc_id_, data);
node->pmc_id_ = 0;
@ -1234,7 +1235,7 @@ void FileManager::flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local
}
data.remote_ = node->remote_;
if (node->generate_ != nullptr && !begins_with(node->generate_->conversion_, "#file_id#")) {
data.generate_ = std::make_unique<FullGenerateFileLocation>(*node->generate_);
data.generate_ = make_unique<FullGenerateFileLocation>(*node->generate_);
}
// TODO: not needed when GenerateLocation has constant convertion
@ -1701,7 +1702,7 @@ void FileManager::run_generate(FileNodePtr node) {
send_closure(actor_, &FileManager::on_error, query_id_, std::move(error));
}
};
return std::make_unique<Callback>(file_manager->actor_id(file_manager), id);
return make_unique<Callback>(file_manager->actor_id(file_manager), id);
}());
LOG(INFO) << "File " << file_id << " generate request has sent to FileGenerateManager";

View File

@ -298,7 +298,7 @@ class FileManager : public FileLoadManager::Callback {
virtual ~Context() = default;
};
explicit FileManager(std::unique_ptr<Context> context);
explicit FileManager(unique_ptr<Context> context);
FileManager(const FileManager &other) = delete;
FileManager &operator=(const FileManager &other) = delete;
FileManager(FileManager &&other) = delete;
@ -393,7 +393,7 @@ class FileManager : public FileLoadManager::Callback {
};
ActorShared<> parent_;
std::unique_ptr<Context> context_;
unique_ptr<Context> context_;
std::shared_ptr<FileDbInterface> file_db_;
FileIdInfo *get_file_id_info(FileId file_id);
@ -417,7 +417,7 @@ class FileManager : public FileLoadManager::Callback {
vector<FileIdInfo> file_id_info_;
vector<int32> empty_file_ids_;
vector<std::unique_ptr<FileNode>> file_nodes_;
vector<unique_ptr<FileNode>> file_nodes_;
ActorOwn<FileLoadManager> file_load_manager_;
ActorOwn<FileGenerateManager> file_generate_manager_;

View File

@ -26,7 +26,7 @@
namespace td {
FileUploader::FileUploader(const LocalFileLocation &local, const RemoteFileLocation &remote, int64 expected_size,
const FileEncryptionKey &encryption_key, std::vector<int> bad_parts,
std::unique_ptr<Callback> callback)
unique_ptr<Callback> callback)
: local_(local)
, remote_(remote)
, expected_size_(expected_size)

View File

@ -26,7 +26,7 @@ class FileUploader : public FileLoader {
};
FileUploader(const LocalFileLocation &local, const RemoteFileLocation &remote, int64 expected_size,
const FileEncryptionKey &encryption_key, std::vector<int> bad_parts, std::unique_ptr<Callback> callback);
const FileEncryptionKey &encryption_key, std::vector<int> bad_parts, unique_ptr<Callback> callback);
// Should just implement all parent pure virtual methods.
// Must not call any of them...
@ -37,7 +37,7 @@ class FileUploader : public FileLoader {
int64 expected_size_;
FileEncryptionKey encryption_key_;
std::vector<int> bad_parts_;
std::unique_ptr<Callback> callback_;
unique_ptr<Callback> callback_;
int64 local_size_ = 0;
bool local_is_ready_ = false;
FileType file_type_ = FileType::Temp;

View File

@ -18,7 +18,7 @@ namespace td {
void ResourceManager::register_worker(ActorShared<FileLoaderActor> callback, int8 priority) {
auto node_id = nodes_container_.create();
auto *node_ptr = nodes_container_.get(node_id);
*node_ptr = std::make_unique<Node>();
*node_ptr = make_unique<Node>();
auto *node = (*node_ptr).get();
CHECK(node);
node->node_id = node_id;

View File

@ -45,7 +45,7 @@ class ResourceManager : public Actor {
}
};
Container<std::unique_ptr<Node>> nodes_container_;
Container<unique_ptr<Node>> nodes_container_;
vector<std::pair<int8, NodeId>> to_xload_;
KHeap<int64> by_estimated_extra_;
ResourceState resource_state_;

View File

@ -129,13 +129,13 @@ void store(const EventT &event, StorerT &storer) {
}
template <class DestT, class T>
Result<std::unique_ptr<DestT>> from_parser(T &&parser) {
Result<unique_ptr<DestT>> from_parser(T &&parser) {
auto version = parser.fetch_int();
parser.set_version(version);
parser.set_context(G());
auto magic = static_cast<typename DestT::Type>(parser.fetch_int());
std::unique_ptr<DestT> event;
unique_ptr<DestT> event;
DestT::downcast_call(magic, [&](auto *ptr) {
auto tmp = make_unique<std::decay_t<decltype(*ptr)>>();
tmp->parse(parser);
@ -150,7 +150,7 @@ Result<std::unique_ptr<DestT>> from_parser(T &&parser) {
}
template <class DestT>
Result<std::unique_ptr<DestT>> from_buffer_slice(BufferSlice slice) {
Result<unique_ptr<DestT>> from_buffer_slice(BufferSlice slice) {
return from_parser<DestT>(WithVersion<WithContext<TlBufferParser, Global *>>{&slice});
}
@ -191,7 +191,7 @@ class LogEventBase : public LogEvent {
void store(StorerT &storer) const {
detail::store(static_cast<const ChildT &>(*this), storer);
}
static Result<std::unique_ptr<ChildT>> from_buffer_slice(BufferSlice slice) {
static Result<unique_ptr<ChildT>> from_buffer_slice(BufferSlice slice) {
return detail::from_buffer_slice<ChildT>(std::move(slice));
}
};

View File

@ -88,15 +88,15 @@ class StatsCallback final : public mtproto::RawConnection::StatsCallback {
class PingActor : public Actor {
public:
PingActor(std::unique_ptr<mtproto::RawConnection> raw_connection,
Promise<std::unique_ptr<mtproto::RawConnection>> promise, ActorShared<> parent)
PingActor(unique_ptr<mtproto::RawConnection> raw_connection, Promise<unique_ptr<mtproto::RawConnection>> promise,
ActorShared<> parent)
: promise_(std::move(promise)), parent_(std::move(parent)) {
ping_connection_ = std::make_unique<mtproto::PingConnection>(std::move(raw_connection), 2);
ping_connection_ = make_unique<mtproto::PingConnection>(std::move(raw_connection), 2);
}
private:
std::unique_ptr<mtproto::PingConnection> ping_connection_;
Promise<std::unique_ptr<mtproto::RawConnection>> promise_;
unique_ptr<mtproto::PingConnection> ping_connection_;
Promise<unique_ptr<mtproto::RawConnection>> promise_;
ActorShared<> parent_;
void start_up() override {
@ -558,15 +558,15 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
LOG(INFO) << "Start ping proxy: " << extra.debug_str;
auto token = next_token();
if (proxy.use_socks5_proxy()) {
children_[token] = {false, create_actor<Socks5>("PingSocks5", std::move(socket_fd), extra.mtproto_ip,
proxy.proxy().user().str(), proxy.proxy().password().str(),
std::make_unique<Callback>(std::move(socket_fd_promise)),
create_reference(token))};
children_[token] = {
false, create_actor<Socks5>("PingSocks5", std::move(socket_fd), extra.mtproto_ip, proxy.proxy().user().str(),
proxy.proxy().password().str(),
make_unique<Callback>(std::move(socket_fd_promise)), create_reference(token))};
} else {
children_[token] = {false, create_actor<HttpProxy>("PingHttpProxy", std::move(socket_fd), extra.mtproto_ip,
children_[token] = {
false, create_actor<HttpProxy>("PingHttpProxy", std::move(socket_fd), extra.mtproto_ip,
proxy.proxy().user().str(), proxy.proxy().password().str(),
std::make_unique<Callback>(std::move(socket_fd_promise)),
create_reference(token))};
make_unique<Callback>(std::move(socket_fd_promise)), create_reference(token))};
}
} else {
socket_fd_promise.set_value(std::move(socket_fd));
@ -576,13 +576,11 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
void ConnectionCreator::ping_proxy_socket_fd(SocketFd socket_fd, mtproto::TransportType transport_type,
Promise<double> promise) {
auto token = next_token();
auto raw_connection =
std::make_unique<mtproto::RawConnection>(std::move(socket_fd), std::move(transport_type), nullptr);
children_[token] = {
false, create_actor<detail::PingActor>(
auto raw_connection = make_unique<mtproto::RawConnection>(std::move(socket_fd), std::move(transport_type), nullptr);
children_[token] = {false, create_actor<detail::PingActor>(
"PingActor", std::move(raw_connection),
PromiseCreator::lambda(
[promise = std::move(promise)](Result<std::unique_ptr<mtproto::RawConnection>> result) mutable {
PromiseCreator::lambda([promise = std::move(promise)](
Result<unique_ptr<mtproto::RawConnection>> result) mutable {
if (result.is_error()) {
return promise.set_error(Status::Error(400, result.error().message()));
}
@ -781,7 +779,7 @@ void ConnectionCreator::on_mtproto_error(size_t hash) {
}
void ConnectionCreator::request_raw_connection(DcId dc_id, bool allow_media_only, bool is_media,
Promise<std::unique_ptr<mtproto::RawConnection>> promise, size_t hash) {
Promise<unique_ptr<mtproto::RawConnection>> promise, size_t hash) {
auto &client = clients_[hash];
if (!client.inited) {
client.inited = true;
@ -803,12 +801,12 @@ void ConnectionCreator::request_raw_connection(DcId dc_id, bool allow_media_only
}
void ConnectionCreator::request_raw_connection_by_ip(IPAddress ip_address,
Promise<std::unique_ptr<mtproto::RawConnection>> promise) {
Promise<unique_ptr<mtproto::RawConnection>> promise) {
auto r_socket_fd = SocketFd::open(ip_address);
if (r_socket_fd.is_error()) {
return promise.set_error(r_socket_fd.move_as_error());
}
auto raw_connection = std::make_unique<mtproto::RawConnection>(
auto raw_connection = make_unique<mtproto::RawConnection>(
r_socket_fd.move_as_ok(), mtproto::TransportType{mtproto::TransportType::ObfuscatedTcp, 0, ""}, nullptr);
raw_connection->extra_ = network_generation_;
promise.set_value(std::move(raw_connection));
@ -997,15 +995,15 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
std::move(r_connection_data), check_mode, transport_type, hash, debug_str, network_generation);
});
auto stats_callback = std::make_unique<detail::StatsCallback>(
client.is_media ? media_net_stats_callback_ : common_net_stats_callback_, actor_id(this), client.hash,
extra.stat);
auto stats_callback =
td::make_unique<detail::StatsCallback>(client.is_media ? media_net_stats_callback_ : common_net_stats_callback_,
actor_id(this), client.hash, extra.stat);
if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy()) {
VLOG(connections) << "client_loop: create new transparent proxy connection " << extra.debug_str;
class Callback : public TransparentProxy::Callback {
public:
explicit Callback(Promise<ConnectionData> promise, std::unique_ptr<detail::StatsCallback> stats_callback)
explicit Callback(Promise<ConnectionData> promise, unique_ptr<detail::StatsCallback> stats_callback)
: promise_(std::move(promise)), stats_callback_(std::move(stats_callback)) {
}
void set_result(Result<SocketFd> result) override {
@ -1032,22 +1030,19 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
Promise<ConnectionData> promise_;
StateManager::ConnectionToken connection_token_;
bool was_connected_{false};
std::unique_ptr<detail::StatsCallback> stats_callback_;
unique_ptr<detail::StatsCallback> stats_callback_;
};
LOG(INFO) << "Start " << (proxy.use_socks5_proxy() ? "Socks5" : "HTTP") << ": " << extra.debug_str;
auto token = next_token();
auto callback = td::make_unique<Callback>(std::move(promise), std::move(stats_callback));
if (proxy.use_socks5_proxy()) {
children_[token] = {
true, create_actor<Socks5>("Socks5", std::move(socket_fd), extra.mtproto_ip, proxy.proxy().user().str(),
proxy.proxy().password().str(),
std::make_unique<Callback>(std::move(promise), std::move(stats_callback)),
create_reference(token))};
proxy.proxy().password().str(), std::move(callback), create_reference(token))};
} else {
children_[token] = {
true, create_actor<HttpProxy>("HttpProxy", std::move(socket_fd), extra.mtproto_ip,
children_[token] = {true, create_actor<HttpProxy>("HttpProxy", std::move(socket_fd), extra.mtproto_ip,
proxy.proxy().user().str(), proxy.proxy().password().str(),
std::make_unique<Callback>(std::move(promise), std::move(stats_callback)),
create_reference(token))};
std::move(callback), create_reference(token))};
}
} else {
VLOG(connections) << "client_loop: create new direct connection " << extra.debug_str;
@ -1064,7 +1059,7 @@ void ConnectionCreator::client_create_raw_connection(Result<ConnectionData> r_co
mtproto::TransportType transport_type, size_t hash,
string debug_str, uint32 network_generation) {
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), hash, check_mode,
debug_str](Result<std::unique_ptr<mtproto::RawConnection>> result) mutable {
debug_str](Result<unique_ptr<mtproto::RawConnection>> result) mutable {
VLOG(connections) << "Ready connection " << (check_mode ? "(" : "(un") << "checked) "
<< (result.is_ok() ? result.ok().get() : nullptr) << " " << debug_str;
send_closure(std::move(actor_id), &ConnectionCreator::client_add_connection, hash, std::move(result), check_mode);
@ -1075,7 +1070,7 @@ void ConnectionCreator::client_create_raw_connection(Result<ConnectionData> r_co
}
auto connection_data = r_connection_data.move_as_ok();
auto raw_connection = std::make_unique<mtproto::RawConnection>(
auto raw_connection = make_unique<mtproto::RawConnection>(
std::move(connection_data.socket_fd), std::move(transport_type), std::move(connection_data.stats_callback));
raw_connection->set_connection_token(std::move(connection_data.connection_token));
@ -1101,8 +1096,7 @@ void ConnectionCreator::client_set_timeout_at(ClientInfo &client, double wakeup_
<< wakeup_at - Time::now_cached();
}
void ConnectionCreator::client_add_connection(size_t hash,
Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection,
void ConnectionCreator::client_add_connection(size_t hash, Result<unique_ptr<mtproto::RawConnection>> r_raw_connection,
bool check_flag) {
auto &client = clients_[hash];
CHECK(client.pending_connections > 0);

View File

@ -154,8 +154,8 @@ class ConnectionCreator : public NetQueryCallback {
void on_pong(size_t hash);
void on_mtproto_error(size_t hash);
void request_raw_connection(DcId dc_id, bool allow_media_only, bool is_media,
Promise<std::unique_ptr<mtproto::RawConnection>> promise, size_t hash = 0);
void request_raw_connection_by_ip(IPAddress ip_address, Promise<std::unique_ptr<mtproto::RawConnection>> promise);
Promise<unique_ptr<mtproto::RawConnection>> promise, size_t hash = 0);
void request_raw_connection_by_ip(IPAddress ip_address, Promise<unique_ptr<mtproto::RawConnection>> promise);
void set_net_stats_callback(std::shared_ptr<NetStatsCallback> common_callback,
std::shared_ptr<NetStatsCallback> media_callback);
@ -224,8 +224,8 @@ class ConnectionCreator : public NetQueryCallback {
Slot slot;
size_t pending_connections{0};
size_t checking_connections{0};
std::vector<std::pair<std::unique_ptr<mtproto::RawConnection>, double>> ready_connections;
std::vector<Promise<std::unique_ptr<mtproto::RawConnection>>> queries;
std::vector<std::pair<unique_ptr<mtproto::RawConnection>, double>> ready_connections;
std::vector<Promise<unique_ptr<mtproto::RawConnection>>> queries;
static constexpr double READY_CONNECTIONS_TIMEOUT = 10;
@ -276,10 +276,9 @@ class ConnectionCreator : public NetQueryCallback {
void save_dc_options();
Result<SocketFd> do_request_connection(DcId dc_id, bool allow_media_only);
Result<std::pair<std::unique_ptr<mtproto::RawConnection>, bool>> do_request_raw_connection(DcId dc_id,
Result<std::pair<unique_ptr<mtproto::RawConnection>, bool>> do_request_raw_connection(DcId dc_id,
bool allow_media_only,
bool is_media,
size_t hash);
bool is_media, size_t hash);
void on_network(bool network_flag, uint32 network_generation);
void on_online(bool online_flag);
@ -291,13 +290,12 @@ class ConnectionCreator : public NetQueryCallback {
struct ConnectionData {
SocketFd socket_fd;
StateManager::ConnectionToken connection_token;
std::unique_ptr<detail::StatsCallback> stats_callback;
unique_ptr<detail::StatsCallback> stats_callback;
};
void client_create_raw_connection(Result<ConnectionData> r_connection_data, bool check_mode,
mtproto::TransportType transport_type, size_t hash, string debug_str,
uint32 network_generation);
void client_add_connection(size_t hash, Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection,
bool check_flag);
void client_add_connection(size_t hash, Result<unique_ptr<mtproto::RawConnection>> r_raw_connection, bool check_flag);
void client_set_timeout_at(ClientInfo &client, double wakeup_at);
void on_get_proxy_info(telegram_api::object_ptr<telegram_api::help_ProxyData> proxy_data_ptr);

View File

@ -62,7 +62,7 @@ void DcAuthManager::add_dc(std::shared_ptr<AuthDataShared> auth_data) {
if (!main_dc_id_.is_exact()) {
main_dc_id_ = info.dc_id;
}
info.shared_auth_data->add_auth_key_listener(std::make_unique<Listener>(actor_shared(this, info.dc_id.get_raw_id())));
info.shared_auth_data->add_auth_key_listener(make_unique<Listener>(actor_shared(this, info.dc_id.get_raw_id())));
dcs_.emplace_back(std::move(info));
loop();
}

View File

@ -169,7 +169,7 @@ void DcOptionsSet::reset() {
}
DcOptionsSet::DcOptionInfo *DcOptionsSet::register_dc_option(DcOption &&option) {
auto info = std::make_unique<DcOptionInfo>(std::move(option), options_.size());
auto info = make_unique<DcOptionInfo>(std::move(option), options_.size());
init_option_stat(info.get());
auto result = info.get();
options_.push_back(std::move(info));
@ -180,7 +180,7 @@ void DcOptionsSet::init_option_stat(DcOptionInfo *option_info) {
const auto &ip_address = option_info->option.get_ip_address();
auto it_ok = option_to_stat_id_.insert(std::make_pair(ip_address, 0));
if (it_ok.second) {
it_ok.first->second = option_stats_.create(std::make_unique<OptionStat>());
it_ok.first->second = option_stats_.create(make_unique<OptionStat>());
}
option_info->stat_id = it_ok.first->second;
}

View File

@ -99,10 +99,10 @@ class DcOptionsSet {
}
};
std::vector<std::unique_ptr<DcOptionInfo>> options_;
std::vector<unique_ptr<DcOptionInfo>> options_;
std::vector<DcOptionId> ordered_options_;
std::map<IPAddress, int64> option_to_stat_id_;
Container<std::unique_ptr<OptionStat>> option_stats_;
Container<unique_ptr<OptionStat>> option_stats_;
DcOptionInfo *register_dc_option(DcOption &&option);
void init_option_stat(DcOptionInfo *option_info);

View File

@ -61,7 +61,7 @@ void NetStatsManager::init() {
id++;
}
stat.key = "net_stats_" + name.str();
stat.stats.set_callback(std::make_unique<NetStatsInternalCallback>(actor_id(this), id));
stat.stats.set_callback(make_unique<NetStatsInternalCallback>(actor_id(this), id));
});
}

View File

@ -120,7 +120,7 @@ bool PublicRsaKeyShared::has_keys() {
return !options_.empty();
}
void PublicRsaKeyShared::add_listener(std::unique_ptr<Listener> listener) {
void PublicRsaKeyShared::add_listener(unique_ptr<Listener> listener) {
if (listener->notify()) {
auto lock = rw_mutex_.lock_write();
listeners_.push_back(std::move(listener));

View File

@ -38,7 +38,7 @@ class PublicRsaKeyShared : public PublicRsaKeyInterface {
void drop_keys() override;
bool has_keys();
void add_listener(std::unique_ptr<Listener> listener);
void add_listener(unique_ptr<Listener> listener);
DcId dc_id() const {
return dc_id_;
@ -51,7 +51,7 @@ class PublicRsaKeyShared : public PublicRsaKeyInterface {
RSA rsa;
};
std::vector<RsaOption> options_;
std::vector<std::unique_ptr<Listener>> listeners_;
std::vector<unique_ptr<Listener>> listeners_;
RwMutex rw_mutex_;
RSA *get_rsa_locked(int64 fingerprint);

View File

@ -33,7 +33,7 @@ void PublicRsaKeyWatchdog::add_public_rsa_key(std::shared_ptr<PublicRsaKeyShared
ActorId<PublicRsaKeyWatchdog> parent_;
};
key->add_listener(std::make_unique<Listener>(actor_id(this)));
key->add_listener(make_unique<Listener>(actor_id(this)));
sync_key(key);
keys_.push_back(std::move(key));
loop();

View File

@ -41,10 +41,9 @@ namespace detail {
class GenAuthKeyActor : public Actor {
public:
GenAuthKeyActor(std::unique_ptr<mtproto::AuthKeyHandshake> handshake,
std::unique_ptr<mtproto::AuthKeyHandshakeContext> context,
Promise<std::unique_ptr<mtproto::RawConnection>> connection_promise,
Promise<std::unique_ptr<mtproto::AuthKeyHandshake>> handshake_promise,
GenAuthKeyActor(unique_ptr<mtproto::AuthKeyHandshake> handshake, unique_ptr<mtproto::AuthKeyHandshakeContext> context,
Promise<unique_ptr<mtproto::RawConnection>> connection_promise,
Promise<unique_ptr<mtproto::AuthKeyHandshake>> handshake_promise,
std::shared_ptr<Session::Callback> callback)
: handshake_(std::move(handshake))
, context_(std::move(context))
@ -61,10 +60,10 @@ class GenAuthKeyActor : public Actor {
private:
uint32 network_generation_ = 0;
std::unique_ptr<mtproto::AuthKeyHandshake> handshake_;
std::unique_ptr<mtproto::AuthKeyHandshakeContext> context_;
Promise<std::unique_ptr<mtproto::RawConnection>> connection_promise_;
Promise<std::unique_ptr<mtproto::AuthKeyHandshake>> handshake_promise_;
unique_ptr<mtproto::AuthKeyHandshake> handshake_;
unique_ptr<mtproto::AuthKeyHandshakeContext> context_;
Promise<unique_ptr<mtproto::RawConnection>> connection_promise_;
Promise<unique_ptr<mtproto::AuthKeyHandshake>> handshake_promise_;
std::shared_ptr<Session::Callback> callback_;
CancellationToken cancellation_token_{true};
@ -75,8 +74,7 @@ class GenAuthKeyActor : public Actor {
// std::tuple<Result<int>> b(std::forward_as_tuple(Result<int>()));
callback_->request_raw_connection(PromiseCreator::cancellable_lambda(
cancellation_token_,
[actor_id = actor_id(this)](Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection) {
cancellation_token_, [actor_id = actor_id(this)](Result<unique_ptr<mtproto::RawConnection>> r_raw_connection) {
send_closure(actor_id, &GenAuthKeyActor::on_connection, std::move(r_raw_connection), false);
}));
}
@ -91,7 +89,7 @@ class GenAuthKeyActor : public Actor {
stop();
}
void on_connection(Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection, bool dummy) {
void on_connection(Result<unique_ptr<mtproto::RawConnection>> r_raw_connection, bool dummy) {
if (r_raw_connection.is_error()) {
connection_promise_.set_error(r_raw_connection.move_as_error());
handshake_promise_.set_value(std::move(handshake_));
@ -865,7 +863,7 @@ void Session::connection_open(ConnectionInfo *info, bool ask_info) {
// NB: rely on constant location of info
auto promise = PromiseCreator::cancellable_lambda(
info->cancellation_token_,
[actor_id = actor_id(this), info = info](Result<std::unique_ptr<mtproto::RawConnection>> res) {
[actor_id = actor_id(this), info = info](Result<unique_ptr<mtproto::RawConnection>> res) {
send_closure(actor_id, &Session::connection_open_finish, info, std::move(res));
});
@ -880,7 +878,7 @@ void Session::connection_open(ConnectionInfo *info, bool ask_info) {
info->wakeup_at = Time::now_cached() + 1000;
}
void Session::connection_add(std::unique_ptr<mtproto::RawConnection> raw_connection) {
void Session::connection_add(unique_ptr<mtproto::RawConnection> raw_connection) {
VLOG(dc) << "Cache connection " << raw_connection.get();
cached_connection_ = std::move(raw_connection);
cached_connection_timestamp_ = Time::now();
@ -897,7 +895,7 @@ void Session::connection_check_mode(ConnectionInfo *info) {
}
void Session::connection_open_finish(ConnectionInfo *info,
Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection) {
Result<unique_ptr<mtproto::RawConnection>> r_raw_connection) {
if (close_flag_ || info->state != ConnectionInfo::State::Connecting) {
VLOG(dc) << "Ignore raw connection while closing";
return;
@ -1024,7 +1022,7 @@ bool Session::connection_send_bind_key(ConnectionInfo *info) {
return true;
}
void Session::on_handshake_ready(Result<std::unique_ptr<mtproto::AuthKeyHandshake>> r_handshake) {
void Session::on_handshake_ready(Result<unique_ptr<mtproto::AuthKeyHandshake>> r_handshake) {
auto handshake_id = narrow_cast<HandshakeId>(get_link_token() - 1);
bool is_main = handshake_id == MainAuthKeyHandshake;
auto &info = handshake_info_[handshake_id];
@ -1078,7 +1076,7 @@ void Session::create_gen_auth_key_actor(HandshakeId handshake_id) {
info.flag_ = true;
bool is_main = handshake_id == MainAuthKeyHandshake;
if (!info.handshake_) {
info.handshake_ = std::make_unique<mtproto::AuthKeyHandshake>(dc_id_, is_main && !is_cdn_ ? 0 : 24 * 60 * 60);
info.handshake_ = make_unique<mtproto::AuthKeyHandshake>(dc_id_, is_main && !is_cdn_ ? 0 : 24 * 60 * 60);
}
class AuthKeyHandshakeContext : public mtproto::AuthKeyHandshakeContext {
public:
@ -1098,8 +1096,8 @@ void Session::create_gen_auth_key_actor(HandshakeId handshake_id) {
};
info.actor_ = create_actor<detail::GenAuthKeyActor>(
"GenAuthKey", std::move(info.handshake_),
std::make_unique<AuthKeyHandshakeContext>(DhCache::instance(), shared_auth_data_->public_rsa_key()),
PromiseCreator::lambda([self = actor_id(this)](Result<std::unique_ptr<mtproto::RawConnection>> r_connection) {
td::make_unique<AuthKeyHandshakeContext>(DhCache::instance(), shared_auth_data_->public_rsa_key()),
PromiseCreator::lambda([self = actor_id(this)](Result<unique_ptr<mtproto::RawConnection>> r_connection) {
if (r_connection.is_error()) {
if (r_connection.error().code() != 1) {
LOG(WARNING) << "Failed to open connection: " << r_connection.error();
@ -1110,7 +1108,7 @@ void Session::create_gen_auth_key_actor(HandshakeId handshake_id) {
}),
PromiseCreator::lambda(
[self = actor_shared(this, handshake_id + 1), handshake_perf = PerfWarningTimer("handshake", 1000.1)](
Result<std::unique_ptr<mtproto::AuthKeyHandshake>> handshake) mutable {
Result<unique_ptr<mtproto::AuthKeyHandshake>> handshake) mutable {
// later is just to avoid lost hangup
send_closure_later(std::move(self), &Session::on_handshake_ready, std::move(handshake));
}),

View File

@ -54,7 +54,7 @@ class Session final
virtual ~Callback() = default;
virtual void on_failed() = 0;
virtual void on_closed() = 0;
virtual void request_raw_connection(Promise<std::unique_ptr<mtproto::RawConnection>>) = 0;
virtual void request_raw_connection(Promise<unique_ptr<mtproto::RawConnection>>) = 0;
virtual void on_tmp_auth_key_updated(mtproto::AuthKey auth_key) = 0;
virtual void on_server_salt_updated(std::vector<mtproto::ServerSalt> server_salts) {
}
@ -139,7 +139,7 @@ class Session final
StateManager::ConnectionToken connection_token_;
double cached_connection_timestamp_ = 0;
std::unique_ptr<mtproto::RawConnection> cached_connection_;
unique_ptr<mtproto::RawConnection> cached_connection_;
std::shared_ptr<Callback> callback_;
mtproto::AuthData auth_data_;
@ -159,13 +159,13 @@ class Session final
struct HandshakeInfo {
bool flag_ = false;
ActorOwn<detail::GenAuthKeyActor> actor_;
std::unique_ptr<mtproto::AuthKeyHandshake> handshake_;
unique_ptr<mtproto::AuthKeyHandshake> handshake_;
};
enum HandshakeId : int32 { MainAuthKeyHandshake = 0, TmpAuthKeyHandshake = 1 };
std::array<HandshakeInfo, 2> handshake_info_;
double wakeup_at_;
void on_handshake_ready(Result<std::unique_ptr<mtproto::AuthKeyHandshake>> r_handshake);
void on_handshake_ready(Result<unique_ptr<mtproto::AuthKeyHandshake>> r_handshake);
void create_gen_auth_key_actor(HandshakeId handshake_id);
void auth_loop();
@ -211,9 +211,9 @@ class Session final
void resend_query(NetQueryPtr query);
void connection_open(ConnectionInfo *info, bool ask_info = false);
void connection_add(std::unique_ptr<mtproto::RawConnection> raw_connection);
void connection_add(unique_ptr<mtproto::RawConnection> raw_connection);
void connection_check_mode(ConnectionInfo *info);
void connection_open_finish(ConnectionInfo *info, Result<std::unique_ptr<mtproto::RawConnection>> r_raw_connection);
void connection_open_finish(ConnectionInfo *info, Result<unique_ptr<mtproto::RawConnection>> r_raw_connection);
void connection_online_update(bool force = false);
void connection_close(ConnectionInfo *info);

View File

@ -41,7 +41,7 @@ class SessionCallback : public Session::Callback {
void on_closed() override {
send_closure(parent_, &SessionProxy::on_closed);
}
void request_raw_connection(Promise<std::unique_ptr<mtproto::RawConnection>> promise) override {
void request_raw_connection(Promise<unique_ptr<mtproto::RawConnection>> promise) override {
send_closure(G()->connection_creator(), &ConnectionCreator::request_raw_connection, dc_id_, allow_media_only_,
is_media_, std::move(promise), hash_);
}
@ -90,7 +90,7 @@ void SessionProxy::start_up() {
ActorShared<SessionProxy> session_proxy_;
};
auth_state_ = auth_data_->get_auth_state().first;
auth_data_->add_auth_key_listener(std::make_unique<Listener>(actor_shared(this)));
auth_data_->add_auth_key_listener(make_unique<Listener>(actor_shared(this)));
if (is_main_ && !need_wait_for_key_) {
open_session();
}

View File

@ -43,11 +43,11 @@ class TempAuthKeyWatchdog : public NetQueryCallback {
};
public:
using RegisteredAuthKey = std::unique_ptr<RegisteredAuthKeyImpl>;
using RegisteredAuthKey = unique_ptr<RegisteredAuthKeyImpl>;
static RegisteredAuthKey register_auth_key_id(int64 id) {
send_closure(G()->temp_auth_key_watchdog(), &TempAuthKeyWatchdog::register_auth_key_id_impl, id);
return std::make_unique<RegisteredAuthKeyImpl>(id);
return make_unique<RegisteredAuthKeyImpl>(id);
}
private:

View File

@ -50,11 +50,11 @@ class MultiPromise : public MultiPromiseInterface {
}
MultiPromise() = default;
explicit MultiPromise(std::unique_ptr<MultiPromiseInterface> impl) : impl_(std::move(impl)) {
explicit MultiPromise(unique_ptr<MultiPromiseInterface> impl) : impl_(std::move(impl)) {
}
private:
std::unique_ptr<MultiPromiseInterface> impl_;
unique_ptr<MultiPromiseInterface> impl_;
};
class MultiPromiseActor final
@ -103,13 +103,13 @@ class MultiPromiseActorSafe : public MultiPromiseInterface {
~MultiPromiseActorSafe() override;
private:
std::unique_ptr<MultiPromiseActor> multi_promise_ = std::make_unique<MultiPromiseActor>();
unique_ptr<MultiPromiseActor> multi_promise_ = make_unique<MultiPromiseActor>();
};
class MultiPromiseCreator {
public:
static MultiPromise create() {
return MultiPromise(std::make_unique<MultiPromiseActor>());
return MultiPromise(make_unique<MultiPromiseActor>());
}
};

View File

@ -112,12 +112,12 @@ class Promise {
}
return promise_->is_cancelled();
}
std::unique_ptr<PromiseInterface<T>> release() {
unique_ptr<PromiseInterface<T>> release() {
return std::move(promise_);
}
Promise() = default;
explicit Promise(std::unique_ptr<PromiseInterface<T>> promise) : promise_(std::move(promise)) {
explicit Promise(unique_ptr<PromiseInterface<T>> promise) : promise_(std::move(promise)) {
}
Promise(SafePromise<T> &&other);
Promise &operator=(SafePromise<T> &&other);
@ -127,7 +127,7 @@ class Promise {
}
private:
std::unique_ptr<PromiseInterface<T>> promise_;
unique_ptr<PromiseInterface<T>> promise_;
};
template <class T>
@ -598,39 +598,39 @@ class PromiseCreator {
template <class OkT, class ArgT = detail::drop_result_t<detail::get_arg_t<OkT>>>
static Promise<ArgT> lambda(OkT &&ok) {
return Promise<ArgT>(std::make_unique<detail::LambdaPromise<ArgT, std::decay_t<OkT>, Ignore>>(std::forward<OkT>(ok),
Ignore(), true));
return Promise<ArgT>(
td::make_unique<detail::LambdaPromise<ArgT, std::decay_t<OkT>, Ignore>>(std::forward<OkT>(ok), Ignore(), true));
}
template <class OkT, class FailT, class ArgT = detail::get_arg_t<OkT>>
static Promise<ArgT> lambda(OkT &&ok, FailT &&fail) {
return Promise<ArgT>(std::make_unique<detail::LambdaPromise<ArgT, std::decay_t<OkT>, std::decay_t<FailT>>>(
return Promise<ArgT>(td::make_unique<detail::LambdaPromise<ArgT, std::decay_t<OkT>, std::decay_t<FailT>>>(
std::forward<OkT>(ok), std::forward<FailT>(fail), false));
}
template <class OkT, class ArgT = detail::drop_result_t<detail::get_arg_t<OkT>>>
static auto cancellable_lambda(CancellationToken cancellation_token, OkT &&ok) {
return Promise<ArgT>(
std::make_unique<detail::CancellablePromise<detail::LambdaPromise<ArgT, std::decay_t<OkT>, Ignore>>>(
td::make_unique<detail::CancellablePromise<detail::LambdaPromise<ArgT, std::decay_t<OkT>, Ignore>>>(
std::move(cancellation_token), std::forward<OkT>(ok), Ignore(), true));
}
static Promise<> event(EventFull &&ok) {
return Promise<>(std::make_unique<detail::EventPromise>(std::move(ok)));
return Promise<>(td::make_unique<detail::EventPromise>(std::move(ok)));
}
static Promise<> event(EventFull ok, EventFull fail) {
return Promise<>(std::make_unique<detail::EventPromise>(std::move(ok), std::move(fail)));
return Promise<>(td::make_unique<detail::EventPromise>(std::move(ok), std::move(fail)));
}
template <class... ArgsT>
static Promise<> join(ArgsT &&... args) {
return Promise<>(std::make_unique<detail::JoinPromise<ArgsT...>>(std::forward<ArgsT>(args)...));
return Promise<>(td::make_unique<detail::JoinPromise<ArgsT...>>(std::forward<ArgsT>(args)...));
}
template <class T>
static Promise<T> from_promise_actor(PromiseActor<T> &&from) {
return Promise<T>(std::make_unique<PromiseActor<T>>(std::move(from)));
return Promise<T>(td::make_unique<PromiseActor<T>>(std::move(from)));
}
};

View File

@ -56,7 +56,7 @@ class ActorInfo
void on_actor_moved(Actor *actor_new_ptr);
template <class ActorT>
ActorOwn<ActorT> transfer_ownership_to_scheduler(std::unique_ptr<ActorT> actor);
ActorOwn<ActorT> transfer_ownership_to_scheduler(unique_ptr<ActorT> actor);
void clear();
void destroy_actor();

View File

@ -96,7 +96,7 @@ inline void ActorInfo::destroy_actor() {
}
template <class ActorT>
ActorOwn<ActorT> ActorInfo::transfer_ownership_to_scheduler(std::unique_ptr<ActorT> actor) {
ActorOwn<ActorT> ActorInfo::transfer_ownership_to_scheduler(unique_ptr<ActorT> actor) {
CHECK(!empty());
CHECK(deleter_ == Deleter::None);
ActorT *actor_ptr = actor.release();

View File

@ -57,7 +57,7 @@ void ConcurrentScheduler::init(int32 threads_n) {
}
#if TD_PORT_WINDOWS
iocp_ = std::make_unique<detail::Iocp>();
iocp_ = make_unique<detail::Iocp>();
iocp_->init();
#endif

View File

@ -92,7 +92,7 @@ class ConcurrentScheduler : private Scheduler::Callback {
std::vector<thread> threads_;
#endif
#if TD_PORT_WINDOWS
std::unique_ptr<detail::Iocp> iocp_;
unique_ptr<detail::Iocp> iocp_;
td::thread iocp_thread_;
#endif

View File

@ -203,7 +203,7 @@ class Scheduler {
static TD_THREAD_LOCAL ActorContext *context_;
Callback *callback_ = nullptr;
std::unique_ptr<ObjectPool<ActorInfo>> actor_info_pool_;
unique_ptr<ObjectPool<ActorInfo>> actor_info_pool_;
int32 actor_count_;
ListNode pending_actors_list_;

View File

@ -127,7 +127,7 @@ ActorOwn<ActorT> Scheduler::register_actor_impl(Slice name, ActorT *actor_ptr, A
}
template <class ActorT>
ActorOwn<ActorT> Scheduler::register_existing_actor(std::unique_ptr<ActorT> actor_ptr) {
ActorOwn<ActorT> Scheduler::register_existing_actor(unique_ptr<ActorT> actor_ptr) {
CHECK(!actor_ptr->empty());
auto actor_info = actor_ptr->get_info();
CHECK(actor_info->migrate_dest_flag_atomic().first == sched_id_);

View File

@ -17,7 +17,7 @@ TEST(MultiTimeout, bug) {
sched.init(threads_n);
sched.start();
std::unique_ptr<MultiTimeout> multi_timeout;
unique_ptr<MultiTimeout> multi_timeout;
struct Data {
MultiTimeout *multi_timeout;
};
@ -25,7 +25,7 @@ TEST(MultiTimeout, bug) {
{
auto guard = sched.get_main_guard();
multi_timeout = std::make_unique<MultiTimeout>("MultiTimeout");
multi_timeout = make_unique<MultiTimeout>("MultiTimeout");
data.multi_timeout = multi_timeout.get();
multi_timeout->set_callback([](void *void_data, int64 key) {
auto &data = *static_cast<Data *>(void_data);

View File

@ -114,7 +114,7 @@ class QueryActor final : public Actor {
explicit QueryActor(int threads_n) : threads_n_(threads_n) {
}
void set_callback(std::unique_ptr<Callback> callback) {
void set_callback(unique_ptr<Callback> callback) {
callback_ = std::move(callback);
}
void set_workers(std::vector<ActorId<Worker>> workers) {
@ -440,14 +440,14 @@ TEST(Actors, main) {
class DoAfterStop : public Actor {
public:
void loop() override {
ptr = std::make_unique<int>(10);
ptr = make_unique<int>(10);
stop();
CHECK(*ptr == 10);
Scheduler::instance()->finish();
}
private:
std::unique_ptr<int> ptr;
unique_ptr<int> ptr;
};
TEST(Actors, do_after_stop) {

View File

@ -45,7 +45,7 @@ class PowerWorker final : public Actor {
}
private:
std::unique_ptr<Callback> callback_;
unique_ptr<Callback> callback_;
};
class Manager final : public Actor {

View File

@ -76,7 +76,7 @@ class BinlogKeyValue : public KeyValueSyncInterface {
magic_ = override_magic;
}
binlog_ = std::make_unique<BinlogT>();
binlog_ = std::make_shared<BinlogT>();
TRY_STATUS(binlog_->init(name,
[&](const BinlogEvent &binlog_event) {
Event event;

View File

@ -137,9 +137,9 @@ class SqliteKeyValueAsync : public SqliteKeyValueAsyncInterface {
ActorOwn<Impl> impl_;
};
std::unique_ptr<SqliteKeyValueAsyncInterface> create_sqlite_key_value_async(std::shared_ptr<SqliteKeyValueSafe> kv,
unique_ptr<SqliteKeyValueAsyncInterface> create_sqlite_key_value_async(std::shared_ptr<SqliteKeyValueSafe> kv,
int32 scheduler_id) {
return std::make_unique<SqliteKeyValueAsync>(std::move(kv), scheduler_id);
return td::make_unique<SqliteKeyValueAsync>(std::move(kv), scheduler_id);
}
} // namespace td

View File

@ -25,6 +25,6 @@ class SqliteKeyValueAsyncInterface {
virtual void close(Promise<> promise) = 0;
};
std::unique_ptr<SqliteKeyValueAsyncInterface> create_sqlite_key_value_async(std::shared_ptr<SqliteKeyValueSafe> kv,
unique_ptr<SqliteKeyValueAsyncInterface> create_sqlite_key_value_async(std::shared_ptr<SqliteKeyValueSafe> kv,
int32 scheduler_id = 1);
} // namespace td

View File

@ -183,9 +183,9 @@ Status Binlog::init(string path, const Callback &callback, DbKey db_key, DbKey o
db_key_ = std::move(db_key);
old_db_key_ = std::move(old_db_key);
processor_ = std::make_unique<detail::BinlogEventsProcessor>();
processor_ = make_unique<detail::BinlogEventsProcessor>();
// Turn off BinlogEventsBuffer
// events_buffer_ = std::make_unique<detail::BinlogEventsBuffer>();
// events_buffer_ = make_unique<detail::BinlogEventsBuffer>();
// try to restore binlog from regenerated version
if (stat(path).is_error()) {

View File

@ -122,8 +122,8 @@ class Binlog {
uint64 fd_events_{0};
string path_;
std::vector<BinlogEvent> pending_events_;
std::unique_ptr<detail::BinlogEventsProcessor> processor_;
std::unique_ptr<detail::BinlogEventsBuffer> events_buffer_;
unique_ptr<detail::BinlogEventsProcessor> processor_;
unique_ptr<detail::BinlogEventsBuffer> events_buffer_;
bool in_flush_events_buffer_{false};
uint64 last_id_{0};
double need_flush_since_ = 0;

View File

@ -16,7 +16,7 @@ namespace td {
namespace detail {
class BinlogActor : public Actor {
public:
BinlogActor(std::unique_ptr<Binlog> binlog, uint64 seq_no) : binlog_(std::move(binlog)), processor_(seq_no) {
BinlogActor(unique_ptr<Binlog> binlog, uint64 seq_no) : binlog_(std::move(binlog)), processor_(seq_no) {
}
void close(Promise<> promise) {
binlog_->close().ensure();
@ -68,7 +68,7 @@ class BinlogActor : public Actor {
}
private:
std::unique_ptr<Binlog> binlog_;
unique_ptr<Binlog> binlog_;
OrderedEventsProcessor<Event> processor_;
@ -163,20 +163,20 @@ class BinlogActor : public Actor {
ConcurrentBinlog::ConcurrentBinlog() = default;
ConcurrentBinlog::~ConcurrentBinlog() = default;
ConcurrentBinlog::ConcurrentBinlog(std::unique_ptr<Binlog> binlog, int scheduler_id) {
ConcurrentBinlog::ConcurrentBinlog(unique_ptr<Binlog> binlog, int scheduler_id) {
init_impl(std::move(binlog), scheduler_id);
}
Result<BinlogInfo> ConcurrentBinlog::init(string path, const Callback &callback, DbKey db_key, DbKey old_db_key,
int scheduler_id) {
auto binlog = std::make_unique<Binlog>();
auto binlog = make_unique<Binlog>();
TRY_STATUS(binlog->init(std::move(path), callback, std::move(db_key), std::move(old_db_key)));
auto info = binlog->get_info();
init_impl(std::move(binlog), scheduler_id);
return info;
}
void ConcurrentBinlog::init_impl(std::unique_ptr<Binlog> binlog, int32 scheduler_id) {
void ConcurrentBinlog::init_impl(unique_ptr<Binlog> binlog, int32 scheduler_id) {
path_ = binlog->get_path().str();
last_id_ = binlog->peek_next_id();
binlog_actor_ = create_actor_on_scheduler<detail::BinlogActor>(PSLICE() << "Binlog " << path_, scheduler_id,

View File

@ -33,7 +33,7 @@ class ConcurrentBinlog : public BinlogInterface {
DbKey old_db_key = DbKey::empty(), int scheduler_id = -1) TD_WARN_UNUSED_RESULT;
ConcurrentBinlog();
explicit ConcurrentBinlog(std::unique_ptr<Binlog> binlog, int scheduler_id = -1);
explicit ConcurrentBinlog(unique_ptr<Binlog> binlog, int scheduler_id = -1);
ConcurrentBinlog(const ConcurrentBinlog &other) = delete;
ConcurrentBinlog &operator=(const ConcurrentBinlog &other) = delete;
ConcurrentBinlog(ConcurrentBinlog &&other) = delete;
@ -56,7 +56,7 @@ class ConcurrentBinlog : public BinlogInterface {
}
private:
void init_impl(std::unique_ptr<Binlog> binlog, int scheduler_id);
void init_impl(unique_ptr<Binlog> binlog, int scheduler_id);
void close_impl(Promise<> promise) override;
void close_and_destroy_impl(Promise<> promise) override;
void add_raw_event_impl(uint64 id, BufferSlice &&raw_event, Promise<> promise, BinlogDebugInfo info) override;

View File

@ -42,7 +42,7 @@ class HttpQuery {
int get_retry_after() const;
};
using HttpQueryPtr = std::unique_ptr<HttpQuery>;
using HttpQueryPtr = unique_ptr<HttpQuery>;
StringBuilder &operator<<(StringBuilder &sb, const HttpQuery &q);

View File

@ -87,7 +87,7 @@ class NetStats {
}
// do it before get_callback
void set_callback(std::unique_ptr<Callback> callback) {
void set_callback(unique_ptr<Callback> callback) {
impl_->set_callback(std::move(callback));
}
@ -102,7 +102,7 @@ class NetStats {
});
return res;
}
void set_callback(std::unique_ptr<Callback> callback) {
void set_callback(unique_ptr<Callback> callback) {
callback_ = std::move(callback);
}
@ -114,7 +114,7 @@ class NetStats {
std::atomic<uint64> write_size{0};
};
SchedulerLocalStorage<LocalNetStats> local_net_stats_;
std::unique_ptr<Callback> callback_;
unique_ptr<Callback> callback_;
void on_read(uint64 size) final {
auto &stats = local_net_stats_.get();

View File

@ -514,11 +514,11 @@ SslStream &SslStream::operator=(SslStream &&) = default;
SslStream::~SslStream() = default;
Result<SslStream> SslStream::create(CSlice host, CSlice cert_file, VerifyPeer verify_peer) {
auto impl = std::make_unique<detail::SslStreamImpl>();
auto impl = make_unique<detail::SslStreamImpl>();
TRY_STATUS(impl->init(host, cert_file, verify_peer));
return SslStream(std::move(impl));
}
SslStream::SslStream(std::unique_ptr<detail::SslStreamImpl> impl) : impl_(std::move(impl)) {
SslStream::SslStream(unique_ptr<detail::SslStreamImpl> impl) : impl_(std::move(impl)) {
}
ByteFlowInterface &SslStream::read_byte_flow() {
return impl_->read_byte_flow();

View File

@ -38,9 +38,9 @@ class SslStream {
}
private:
std::unique_ptr<detail::SslStreamImpl> impl_;
unique_ptr<detail::SslStreamImpl> impl_;
explicit SslStream(std::unique_ptr<detail::SslStreamImpl> impl);
explicit SslStream(unique_ptr<detail::SslStreamImpl> impl);
};
} // namespace td

View File

@ -14,7 +14,7 @@ namespace td {
int VERBOSITY_NAME(proxy) = VERBOSITY_NAME(DEBUG);
TransparentProxy::TransparentProxy(SocketFd socket_fd, IPAddress ip_address, string username, string password,
std::unique_ptr<Callback> callback, ActorShared<> parent)
unique_ptr<Callback> callback, ActorShared<> parent)
: fd_(std::move(socket_fd))
, ip_address_(std::move(ip_address))
, username_(std::move(username))

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