refactor: use base::flat_set in WebContents::DidUpdateFaviconUrl() (#46531)

* refactor: add gin::Converter<std::span>::ToV8()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* feat: add ToV8(const base::flat_set<T>&)

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: use a flat_set in WebContents::TitleWasSet()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: add gin::Converter<std::array>::ToV8()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-04-07 16:36:37 +02:00 committed by GitHub
parent 1fe77cdcf2
commit 1ebad64192
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 6 deletions

View file

@ -16,6 +16,7 @@
#include "base/base64.h"
#include "base/containers/fixed_flat_map.h"
#include "base/containers/flat_set.h"
#include "base/containers/id_map.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
@ -2210,13 +2211,12 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry) {
void WebContents::DidUpdateFaviconURL(
content::RenderFrameHost* render_frame_host,
const std::vector<blink::mojom::FaviconURLPtr>& urls) {
std::set<GURL> unique_urls;
base::flat_set<GURL> unique_urls;
unique_urls.reserve(std::size(urls));
for (const auto& iter : urls) {
if (iter->icon_type != blink::mojom::FaviconIconType::kFavicon)
continue;
const GURL& url = iter->icon_url;
if (url.is_valid())
unique_urls.insert(url);
if (iter->icon_type == blink::mojom::FaviconIconType::kFavicon &&
iter->icon_url.is_valid())
unique_urls.insert(iter->icon_url);
}
Emit("page-favicon-updated", unique_urls);
}