Update WebPagesManager.cpp
This commit is contained in:
parent
9b6b31ba1f
commit
ebcc255b6f
@ -667,7 +667,7 @@ void WebPagesManager::on_get_web_page_instant_view_view_count(WebPageId web_page
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto *instant_view = &web_pages_[web_page_id]->instant_view;
|
auto *instant_view = &web_pages_[web_page_id]->instant_view;
|
||||||
CHECK(!instant_view->is_empty);
|
if (instant_view->is_empty) { return; }
|
||||||
if (instant_view->view_count >= view_count) {
|
if (instant_view->view_count >= view_count) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -705,7 +705,7 @@ void WebPagesManager::register_web_page(WebPageId web_page_id, FullMessageId ful
|
|||||||
|
|
||||||
LOG(INFO) << "Register " << web_page_id << " from " << full_message_id << " from " << source;
|
LOG(INFO) << "Register " << web_page_id << " from " << full_message_id << " from " << source;
|
||||||
bool is_inserted = web_page_messages_[web_page_id].insert(full_message_id).second;
|
bool is_inserted = web_page_messages_[web_page_id].insert(full_message_id).second;
|
||||||
LOG_CHECK(is_inserted) << source << " " << web_page_id << " " << full_message_id;
|
if (!is_inserted) { return; }
|
||||||
|
|
||||||
if (!td_->auth_manager_->is_bot() && !have_web_page_force(web_page_id)) {
|
if (!td_->auth_manager_->is_bot() && !have_web_page_force(web_page_id)) {
|
||||||
LOG(INFO) << "Waiting for " << web_page_id << " needed in " << full_message_id;
|
LOG(INFO) << "Waiting for " << web_page_id << " needed in " << full_message_id;
|
||||||
@ -724,7 +724,7 @@ void WebPagesManager::unregister_web_page(WebPageId web_page_id, FullMessageId f
|
|||||||
if (!is_deleted) {
|
if (!is_deleted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_CHECK(is_deleted) << source << " " << web_page_id << " " << full_message_id;
|
if (!is_deleted) { return; }
|
||||||
|
|
||||||
if (message_ids.empty()) {
|
if (message_ids.empty()) {
|
||||||
web_page_messages_.erase(web_page_id);
|
web_page_messages_.erase(web_page_id);
|
||||||
@ -770,9 +770,9 @@ void WebPagesManager::on_get_web_page_preview_success(int64 request_id, const st
|
|||||||
|
|
||||||
void WebPagesManager::on_get_web_page_preview_success(int64 request_id, const string &url, WebPageId web_page_id,
|
void WebPagesManager::on_get_web_page_preview_success(int64 request_id, const string &url, WebPageId web_page_id,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
CHECK(web_page_id == WebPageId() || have_web_page(web_page_id));
|
if (!(web_page_id == WebPageId() || have_web_page(web_page_id))) { return; }
|
||||||
|
|
||||||
CHECK(got_web_page_previews_.find(request_id) == got_web_page_previews_.end());
|
if (!(got_web_page_previews_.find(request_id) == got_web_page_previews_.end())) { return; }
|
||||||
got_web_page_previews_[request_id] = web_page_id;
|
got_web_page_previews_[request_id] = web_page_id;
|
||||||
|
|
||||||
if (web_page_id.is_valid() && !url.empty()) {
|
if (web_page_id.is_valid() && !url.empty()) {
|
||||||
@ -785,7 +785,7 @@ void WebPagesManager::on_get_web_page_preview_success(int64 request_id, const st
|
|||||||
void WebPagesManager::on_get_web_page_preview_fail(int64 request_id, const string &url, Status error,
|
void WebPagesManager::on_get_web_page_preview_fail(int64 request_id, const string &url, Status error,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
LOG(INFO) << "Clean up getting of web page preview with url \"" << url << '"';
|
LOG(INFO) << "Clean up getting of web page preview with url \"" << url << '"';
|
||||||
CHECK(error.is_error());
|
if (!error.is_error()) { return; }
|
||||||
promise.set_error(std::move(error));
|
promise.set_error(std::move(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,7 +918,7 @@ void WebPagesManager::load_web_page_instant_view(WebPageId web_page_id, bool for
|
|||||||
void WebPagesManager::reload_web_page_instant_view(WebPageId web_page_id) {
|
void WebPagesManager::reload_web_page_instant_view(WebPageId web_page_id) {
|
||||||
LOG(INFO) << "Reload " << web_page_id << " instant view";
|
LOG(INFO) << "Reload " << web_page_id << " instant view";
|
||||||
const WebPage *web_page = get_web_page(web_page_id);
|
const WebPage *web_page = get_web_page(web_page_id);
|
||||||
CHECK(web_page != nullptr && !web_page->instant_view.is_empty);
|
if (!(web_page != nullptr && !web_page->instant_view.is_empty)) { return; }
|
||||||
|
|
||||||
auto promise = PromiseCreator::lambda([web_page_id](Result<> result) {
|
auto promise = PromiseCreator::lambda([web_page_id](Result<> result) {
|
||||||
send_closure(G()->web_pages_manager(), &WebPagesManager::update_web_page_instant_view_load_requests, web_page_id,
|
send_closure(G()->web_pages_manager(), &WebPagesManager::update_web_page_instant_view_load_requests, web_page_id,
|
||||||
@ -934,7 +934,7 @@ void WebPagesManager::reload_web_page_instant_view(WebPageId web_page_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_page_id, string value) {
|
void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_page_id, string value) {
|
||||||
CHECK(G()->parameters().use_message_db);
|
if (!(G()->parameters().use_message_db)) { return; }
|
||||||
LOG(INFO) << "Successfully loaded " << web_page_id << " instant view of size " << value.size() << " from database";
|
LOG(INFO) << "Successfully loaded " << web_page_id << " instant view of size " << value.size() << " from database";
|
||||||
// G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto());
|
// G()->td_db()->get_sqlite_pmc()->erase(get_web_page_instant_view_database_key(web_page_id), Auto());
|
||||||
// return;
|
// return;
|
||||||
@ -1203,7 +1203,7 @@ void WebPagesManager::on_web_page_changed(WebPageId web_page_id, bool have_web_p
|
|||||||
for (auto full_message_id : it->second) {
|
for (auto full_message_id : it->second) {
|
||||||
full_message_ids.push_back(full_message_id);
|
full_message_ids.push_back(full_message_id);
|
||||||
}
|
}
|
||||||
CHECK(!full_message_ids.empty());
|
if (full_message_ids.empty()) { return; }
|
||||||
for (auto full_message_id : full_message_ids) {
|
for (auto full_message_id : full_message_ids) {
|
||||||
if (!have_web_page) {
|
if (!have_web_page) {
|
||||||
td_->messages_manager_->delete_pending_message_web_page(full_message_id);
|
td_->messages_manager_->delete_pending_message_web_page(full_message_id);
|
||||||
@ -1212,9 +1212,9 @@ void WebPagesManager::on_web_page_changed(WebPageId web_page_id, bool have_web_p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (have_web_page) {
|
if (have_web_page) {
|
||||||
CHECK(web_page_messages_[web_page_id].size() == full_message_ids.size());
|
if (!(web_page_messages_[web_page_id].size() == full_message_ids.size())) { return; }
|
||||||
} else {
|
} else {
|
||||||
CHECK(web_page_messages_.count(web_page_id) == 0);
|
if (!(web_page_messages_.count(web_page_id) == 0)) { return; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto get_it = pending_get_web_pages_.find(web_page_id);
|
auto get_it = pending_get_web_pages_.find(web_page_id);
|
||||||
@ -1500,7 +1500,7 @@ void WebPagesManager::on_load_web_page_from_database(WebPageId web_page_id, stri
|
|||||||
vector<Promise<Unit>> promises;
|
vector<Promise<Unit>> promises;
|
||||||
if (it != load_web_page_from_database_queries_.end()) {
|
if (it != load_web_page_from_database_queries_.end()) {
|
||||||
promises = std::move(it->second);
|
promises = std::move(it->second);
|
||||||
CHECK(!promises.empty());
|
if (promises.empty()) { return; }
|
||||||
load_web_page_from_database_queries_.erase(it);
|
load_web_page_from_database_queries_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user