Remove non-const WebPagesManager::get_web_page_instant_view.

GitOrigin-RevId: 344a549f1585c8b52156d96a5ed68b36818e3fd2
This commit is contained in:
levlam 2019-01-22 01:06:24 +03:00
parent e8d3674eb4
commit dcdf4fae36
2 changed files with 9 additions and 18 deletions

View File

@ -1855,7 +1855,7 @@ WebPageId WebPagesManager::get_web_page_instant_view(const string &url, bool for
WebPageId WebPagesManager::get_web_page_instant_view(WebPageId web_page_id, bool force_full, Promise<Unit> &&promise) { WebPageId WebPagesManager::get_web_page_instant_view(WebPageId web_page_id, bool force_full, Promise<Unit> &&promise) {
LOG(INFO) << "Trying to get web page instant view for " << web_page_id; LOG(INFO) << "Trying to get web page instant view for " << web_page_id;
const auto *web_page_instant_view = get_web_page_instant_view(web_page_id); auto web_page_instant_view = get_web_page_instant_view(web_page_id);
if (web_page_instant_view == nullptr) { if (web_page_instant_view == nullptr) {
promise.set_value(Unit()); promise.set_value(Unit());
return WebPageId(); return WebPageId();
@ -1889,7 +1889,7 @@ void WebPagesManager::load_web_page_instant_view(WebPageId web_page_id, bool for
} }
LOG(INFO) << "Load " << web_page_id << " instant view, have " << previous_queries << " previous queries"; LOG(INFO) << "Load " << web_page_id << " instant view, have " << previous_queries << " previous queries";
if (previous_queries == 0) { if (previous_queries == 0) {
const auto *web_page_instant_view = get_web_page_instant_view(web_page_id); auto web_page_instant_view = get_web_page_instant_view(web_page_id);
CHECK(web_page_instant_view != nullptr); CHECK(web_page_instant_view != nullptr);
if (G()->parameters().use_message_db && !web_page_instant_view->was_loaded_from_database) { if (G()->parameters().use_message_db && !web_page_instant_view->was_loaded_from_database) {
@ -1925,8 +1925,8 @@ void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_
// 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;
auto *web_page_instant_view = get_web_page_instant_view(web_page_id); auto web_page_it = web_pages_.find(web_page_id);
if (web_page_instant_view == nullptr) { if (web_page_it == web_pages_.end() || web_page_it->second->instant_view.is_empty) {
// possible if web page loses preview/instant view // possible if web page loses preview/instant view
LOG(WARNING) << "There is no instant view in " << web_page_id; LOG(WARNING) << "There is no instant view in " << web_page_id;
if (!value.empty()) { if (!value.empty()) {
@ -1935,7 +1935,9 @@ void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_
update_web_page_instant_view_load_requests(web_page_id, true, Unit()); update_web_page_instant_view_load_requests(web_page_id, true, Unit());
return; return;
} }
if (web_page_instant_view->was_loaded_from_database) { auto web_page = web_page_it->second.get();
auto &web_page_instant_view = web_page->instant_view;
if (web_page_instant_view.was_loaded_from_database) {
return; return;
} }
@ -1950,7 +1952,7 @@ void WebPagesManager::on_load_web_page_instant_view_from_database(WebPageId web_
} }
result.was_loaded_from_database = true; result.was_loaded_from_database = true;
update_web_page_instant_view(web_page_id, *web_page_instant_view, std::move(result)); update_web_page_instant_view(web_page_id, web_page_instant_view, std::move(result));
update_web_page_instant_view_load_requests(web_page_id, false, Unit()); update_web_page_instant_view_load_requests(web_page_id, false, Unit());
} }
@ -1980,7 +1982,7 @@ void WebPagesManager::update_web_page_instant_view_load_requests(WebPageId web_p
} }
LOG(INFO) << "Successfully loaded web page " << web_page_id; LOG(INFO) << "Successfully loaded web page " << web_page_id;
const auto *web_page_instant_view = get_web_page_instant_view(web_page_id); auto web_page_instant_view = get_web_page_instant_view(web_page_id);
if (web_page_instant_view == nullptr) { if (web_page_instant_view == nullptr) {
combine(promises[0], std::move(promises[1])); combine(promises[0], std::move(promises[1]));
for (auto &promise : promises[0]) { for (auto &promise : promises[0]) {
@ -2231,15 +2233,6 @@ const WebPagesManager::WebPage *WebPagesManager::get_web_page(WebPageId web_page
} }
} }
WebPagesManager::WebPageInstantView *WebPagesManager::get_web_page_instant_view(WebPageId web_page_id) {
auto p = web_pages_.find(web_page_id);
if (p == web_pages_.end() || p->second->instant_view.is_empty) {
return nullptr;
} else {
return &p->second->instant_view;
}
}
const WebPagesManager::WebPageInstantView *WebPagesManager::get_web_page_instant_view(WebPageId web_page_id) const { const WebPagesManager::WebPageInstantView *WebPagesManager::get_web_page_instant_view(WebPageId web_page_id) const {
auto web_page = get_web_page(web_page_id); auto web_page = get_web_page(web_page_id);
if (web_page == nullptr || web_page->instant_view.is_empty) { if (web_page == nullptr || web_page->instant_view.is_empty) {

View File

@ -144,8 +144,6 @@ class WebPagesManager : public Actor {
const WebPage *get_web_page(WebPageId web_page_id) const; const WebPage *get_web_page(WebPageId web_page_id) const;
WebPageInstantView *get_web_page_instant_view(WebPageId web_page_id);
const WebPageInstantView *get_web_page_instant_view(WebPageId web_page_id) const; const WebPageInstantView *get_web_page_instant_view(WebPageId web_page_id) const;
WebPageId get_web_page_instant_view(WebPageId web_page_id, bool force_full, Promise<Unit> &&promise); WebPageId get_web_page_instant_view(WebPageId web_page_id, bool force_full, Promise<Unit> &&promise);