| File: | var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp |
| Warning: | line 424, column 5 Value stored to 'rv' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 | * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
| 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | #include "FaviconHelpers.h" |
| 8 | |
| 9 | #include "nsICacheEntry.h" |
| 10 | #include "nsICachingChannel.h" |
| 11 | #include "nsIClassOfService.h" |
| 12 | #include "nsIAsyncVerifyRedirectCallback.h" |
| 13 | #include "nsIHttpChannel.h" |
| 14 | #include "nsIPrincipal.h" |
| 15 | |
| 16 | #include "nsComponentManagerUtils.h" |
| 17 | #include "nsNavHistory.h" |
| 18 | #include "nsFaviconService.h" |
| 19 | |
| 20 | #include "mozilla/dom/PlacesFavicon.h" |
| 21 | #include "mozilla/dom/PlacesObservers.h" |
| 22 | #include "mozilla/storage.h" |
| 23 | #include "mozilla/ScopeExit.h" |
| 24 | #include "mozilla/Telemetry.h" |
| 25 | #include "mozilla/StaticPrefs_network.h" |
| 26 | #include "nsNetUtil.h" |
| 27 | #include "nsPrintfCString.h" |
| 28 | #include "nsStreamUtils.h" |
| 29 | #include "nsStringStream.h" |
| 30 | #include "nsIPrivateBrowsingChannel.h" |
| 31 | #include "nsISupportsPriority.h" |
| 32 | #include <algorithm> |
| 33 | #include <deque> |
| 34 | #include "mozilla/gfx/2D.h" |
| 35 | #include "imgIContainer.h" |
| 36 | #include "ImageOps.h" |
| 37 | #include "imgIEncoder.h" |
| 38 | |
| 39 | using namespace mozilla; |
| 40 | using namespace mozilla::places; |
| 41 | using namespace mozilla::storage; |
| 42 | |
| 43 | namespace mozilla { |
| 44 | namespace places { |
| 45 | |
| 46 | namespace { |
| 47 | |
| 48 | /** |
| 49 | * Fetches information about a page from the database. |
| 50 | * |
| 51 | * @param aDB |
| 52 | * Database connection to history tables. |
| 53 | * @param _page |
| 54 | * Page that should be fetched. |
| 55 | */ |
| 56 | nsresult FetchPageInfo(const RefPtr<Database>& aDB, PageData& _page) { |
| 57 | MOZ_ASSERT(_page.spec.Length(), "Must have a non-empty spec!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(_page.spec.Length())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(_page.spec.Length()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("_page.spec.Length()" " (" "Must have a non-empty spec!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 57); AnnotateMozCrashReason("MOZ_ASSERT" "(" "_page.spec.Length()" ") (" "Must have a non-empty spec!" ")"); do { *((volatile int *)__null) = 57; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 58 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 58); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 58; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 59 | |
| 60 | // The subquery finds the bookmarked uri we want to set the icon for, |
| 61 | // walking up redirects. |
| 62 | nsCString query = nsPrintfCString( |
| 63 | "SELECT h.id, pi.id, h.guid, ( " |
| 64 | "WITH RECURSIVE " |
| 65 | "destinations(visit_type, from_visit, place_id, rev_host, bm) AS ( " |
| 66 | "SELECT v.visit_type, v.from_visit, p.id, p.rev_host, b.id " |
| 67 | "FROM moz_places p " |
| 68 | "LEFT JOIN moz_historyvisits v ON v.place_id = p.id " |
| 69 | "LEFT JOIN moz_bookmarks b ON b.fk = p.id " |
| 70 | "WHERE p.id = h.id " |
| 71 | "UNION " |
| 72 | "SELECT src.visit_type, src.from_visit, src.place_id, p.rev_host, b.id " |
| 73 | "FROM moz_places p " |
| 74 | "JOIN moz_historyvisits src ON src.place_id = p.id " |
| 75 | "JOIN destinations dest ON dest.from_visit = src.id AND dest.visit_type " |
| 76 | "IN (%d, %d) " |
| 77 | "LEFT JOIN moz_bookmarks b ON b.fk = src.place_id " |
| 78 | "WHERE instr(p.rev_host, dest.rev_host) = 1 " |
| 79 | "OR instr(dest.rev_host, p.rev_host) = 1 " |
| 80 | ") " |
| 81 | "SELECT url " |
| 82 | "FROM moz_places p " |
| 83 | "JOIN destinations r ON r.place_id = p.id " |
| 84 | "WHERE bm NOTNULL " |
| 85 | "LIMIT 1 " |
| 86 | "), fixup_url(get_unreversed_host(h.rev_host)) AS host " |
| 87 | "FROM moz_places h " |
| 88 | "LEFT JOIN moz_pages_w_icons pi ON page_url_hash = hash(:page_url) AND " |
| 89 | "page_url = :page_url " |
| 90 | "WHERE h.url_hash = hash(:page_url) AND h.url = :page_url", |
| 91 | nsINavHistoryService::TRANSITION_REDIRECT_PERMANENT, |
| 92 | nsINavHistoryService::TRANSITION_REDIRECT_TEMPORARY); |
| 93 | |
| 94 | nsCOMPtr<mozIStorageStatement> stmt = aDB->GetStatement(query); |
| 95 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 95); return NS_ERROR_UNEXPECTED; } } while (false); |
| 96 | mozStorageStatementScoper scoper(stmt); |
| 97 | |
| 98 | nsresult rv = URIBinder::Bind(stmt, "page_url"_ns, _page.spec); |
| 99 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 99); return rv; } } while (false); |
| 100 | |
| 101 | bool hasResult; |
| 102 | rv = stmt->ExecuteStep(&hasResult); |
| 103 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 103); return rv; } } while (false); |
| 104 | if (!hasResult) { |
| 105 | // The page does not exist. |
| 106 | return NS_ERROR_NOT_AVAILABLE; |
| 107 | } |
| 108 | |
| 109 | rv = stmt->GetInt64(0, &_page.placeId); |
| 110 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 110); return rv; } } while (false); |
| 111 | // May be null, and in such a case this will be 0. |
| 112 | _page.id = stmt->AsInt64(1); |
| 113 | rv = stmt->GetUTF8String(2, _page.guid); |
| 114 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 114); return rv; } } while (false); |
| 115 | // Bookmarked url can be nullptr. |
| 116 | bool isNull; |
| 117 | rv = stmt->GetIsNull(3, &isNull); |
| 118 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 118); return rv; } } while (false); |
| 119 | // The page could not be bookmarked. |
| 120 | if (!isNull) { |
| 121 | rv = stmt->GetUTF8String(3, _page.bookmarkedSpec); |
| 122 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 122); return rv; } } while (false); |
| 123 | } |
| 124 | |
| 125 | if (_page.host.IsEmpty()) { |
| 126 | rv = stmt->GetUTF8String(4, _page.host); |
| 127 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 127); return rv; } } while (false); |
| 128 | } |
| 129 | |
| 130 | if (!_page.canAddToHistory) { |
| 131 | // Either history is disabled or the scheme is not supported. In such a |
| 132 | // case we want to update the icon only if the page is bookmarked. |
| 133 | |
| 134 | if (_page.bookmarkedSpec.IsEmpty()) { |
| 135 | // The page is not bookmarked. Since updating the icon with a disabled |
| 136 | // history would be a privacy leak, bail out as if the page did not exist. |
| 137 | return NS_ERROR_NOT_AVAILABLE; |
| 138 | } else { |
| 139 | // The page, or a redirect to it, is bookmarked. If the bookmarked spec |
| 140 | // is different from the requested one, use it. |
| 141 | if (!_page.bookmarkedSpec.Equals(_page.spec)) { |
| 142 | _page.spec = _page.bookmarkedSpec; |
| 143 | rv = FetchPageInfo(aDB, _page); |
| 144 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 144); return rv; } } while (false); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return NS_OK; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Stores information about an icon in the database. |
| 154 | * |
| 155 | * @param aDB |
| 156 | * Database connection to history tables. |
| 157 | * @param aIcon |
| 158 | * Icon that should be stored. |
| 159 | * @param aMustReplace |
| 160 | * If set to true, the function will bail out with NS_ERROR_NOT_AVAILABLE |
| 161 | * if it can't find a previous stored icon to replace. |
| 162 | * @note Should be wrapped in a transaction. |
| 163 | */ |
| 164 | nsresult SetIconInfo(const RefPtr<Database>& aDB, IconData& aIcon, |
| 165 | bool aMustReplace = false) { |
| 166 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 166); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 166; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 167 | MOZ_ASSERT(aIcon.payloads.Length() > 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIcon.payloads.Length() > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIcon.payloads.Length() > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aIcon.payloads.Length() > 0", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 167); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIcon.payloads.Length() > 0" ")"); do { *((volatile int*)__null) = 167; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 168 | MOZ_ASSERT(!aIcon.spec.IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aIcon.spec.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aIcon.spec.IsEmpty()))), 0) )) { do { } while (false); MOZ_ReportAssertionFailure("!aIcon.spec.IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 168); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aIcon.spec.IsEmpty()" ")"); do { *((volatile int*)__null) = 168; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 169 | MOZ_ASSERT(aIcon.expiration > 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIcon.expiration > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIcon.expiration > 0))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aIcon.expiration > 0" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 169); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIcon.expiration > 0" ")"); do { *((volatile int*)__null) = 169; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 170 | |
| 171 | // There are multiple cases possible at this point: |
| 172 | // 1. We must insert some payloads and no payloads exist in the table. This |
| 173 | // would be a straight INSERT. |
| 174 | // 2. The table contains the same number of payloads we are inserting. This |
| 175 | // would be a straight UPDATE. |
| 176 | // 3. The table contains more payloads than we are inserting. This would be |
| 177 | // an UPDATE and a DELETE. |
| 178 | // 4. The table contains less payloads than we are inserting. This would be |
| 179 | // an UPDATE and an INSERT. |
| 180 | // We can't just remove all the old entries and insert the new ones, cause |
| 181 | // we'd lose the referential integrity with pages. For the same reason we |
| 182 | // cannot use INSERT OR REPLACE, since it's implemented as DELETE AND INSERT. |
| 183 | // Thus, we follow this strategy: |
| 184 | // * SELECT all existing icon ids |
| 185 | // * For each payload, either UPDATE OR INSERT reusing icon ids. |
| 186 | // * If any previous icon ids is leftover, DELETE it. |
| 187 | |
| 188 | nsCOMPtr<mozIStorageStatement> selectStmt = aDB->GetStatement( |
| 189 | "SELECT id FROM moz_icons " |
| 190 | "WHERE fixed_icon_url_hash = hash(fixup_url(:url)) " |
| 191 | "AND icon_url = :url "); |
| 192 | NS_ENSURE_STATE(selectStmt)do { if ((__builtin_expect(!!(!(selectStmt)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "selectStmt" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 192); return NS_ERROR_UNEXPECTED; } } while (false); |
| 193 | mozStorageStatementScoper scoper(selectStmt); |
| 194 | nsresult rv = URIBinder::Bind(selectStmt, "url"_ns, aIcon.spec); |
| 195 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 195); return rv; } } while (false); |
| 196 | std::deque<int64_t> ids; |
| 197 | bool hasResult = false; |
| 198 | while (NS_SUCCEEDED(selectStmt->ExecuteStep(&hasResult))((bool)(__builtin_expect(!!(!NS_FAILED_impl(selectStmt->ExecuteStep (&hasResult))), 1))) && hasResult) { |
| 199 | int64_t id = selectStmt->AsInt64(0); |
| 200 | MOZ_ASSERT(id > 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(id > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(id > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("id > 0", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 200); AnnotateMozCrashReason("MOZ_ASSERT" "(" "id > 0" ")" ); do { *((volatile int*)__null) = 200; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 201 | ids.push_back(id); |
| 202 | } |
| 203 | if (aMustReplace && ids.empty()) { |
| 204 | return NS_ERROR_NOT_AVAILABLE; |
| 205 | } |
| 206 | |
| 207 | nsCOMPtr<mozIStorageStatement> insertStmt = aDB->GetStatement( |
| 208 | "INSERT INTO moz_icons " |
| 209 | "(icon_url, fixed_icon_url_hash, width, root, expire_ms, data) " |
| 210 | "VALUES (:url, hash(fixup_url(:url)), :width, :root, :expire, :data) "); |
| 211 | NS_ENSURE_STATE(insertStmt)do { if ((__builtin_expect(!!(!(insertStmt)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "insertStmt" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 211); return NS_ERROR_UNEXPECTED; } } while (false); |
| 212 | // ReplaceFaviconData may replace data for an already existing icon, and in |
| 213 | // that case it won't have the page uri at hand, thus it can't tell if the |
| 214 | // icon is a root icon or not. For that reason, never overwrite a root = 1. |
| 215 | nsCOMPtr<mozIStorageStatement> updateStmt = aDB->GetStatement( |
| 216 | "UPDATE moz_icons SET width = :width, " |
| 217 | "expire_ms = :expire, " |
| 218 | "data = :data, " |
| 219 | "root = (root OR :root) " |
| 220 | "WHERE id = :id "); |
| 221 | NS_ENSURE_STATE(updateStmt)do { if ((__builtin_expect(!!(!(updateStmt)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "updateStmt" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 221); return NS_ERROR_UNEXPECTED; } } while (false); |
| 222 | |
| 223 | for (auto& payload : aIcon.payloads) { |
| 224 | // Sanity checks. |
| 225 | MOZ_ASSERT(payload.mimeType.EqualsLiteral(PNG_MIME_TYPE) ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(payload.mimeType.EqualsLiteral("image/png") || payload .mimeType.EqualsLiteral("image/svg+xml"))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(payload.mimeType.EqualsLiteral ("image/png") || payload.mimeType.EqualsLiteral("image/svg+xml" )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" " (" "Only png and svg payloads are supported" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 227); AnnotateMozCrashReason("MOZ_ASSERT" "(" "payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" ") (" "Only png and svg payloads are supported" ")"); do { * ((volatile int*)__null) = 227; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) |
| 226 | payload.mimeType.EqualsLiteral(SVG_MIME_TYPE),do { static_assert( mozilla::detail::AssertionConditionType< decltype(payload.mimeType.EqualsLiteral("image/png") || payload .mimeType.EqualsLiteral("image/svg+xml"))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(payload.mimeType.EqualsLiteral ("image/png") || payload.mimeType.EqualsLiteral("image/svg+xml" )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" " (" "Only png and svg payloads are supported" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 227); AnnotateMozCrashReason("MOZ_ASSERT" "(" "payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" ") (" "Only png and svg payloads are supported" ")"); do { * ((volatile int*)__null) = 227; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) |
| 227 | "Only png and svg payloads are supported")do { static_assert( mozilla::detail::AssertionConditionType< decltype(payload.mimeType.EqualsLiteral("image/png") || payload .mimeType.EqualsLiteral("image/svg+xml"))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(payload.mimeType.EqualsLiteral ("image/png") || payload.mimeType.EqualsLiteral("image/svg+xml" )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" " (" "Only png and svg payloads are supported" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 227); AnnotateMozCrashReason("MOZ_ASSERT" "(" "payload.mimeType.EqualsLiteral(\"image/png\") || payload.mimeType.EqualsLiteral(\"image/svg+xml\")" ") (" "Only png and svg payloads are supported" ")"); do { * ((volatile int*)__null) = 227; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); |
| 228 | MOZ_ASSERT(!payload.mimeType.EqualsLiteral(SVG_MIME_TYPE) ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(!payload.mimeType.EqualsLiteral("image/svg+xml") || payload .width == (65535))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!payload.mimeType.EqualsLiteral ("image/svg+xml") || payload.width == (65535)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" " (" "SVG payloads should have max width" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" ") (" "SVG payloads should have max width" ")"); do { *((volatile int*)__null) = 230; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) |
| 229 | payload.width == UINT16_MAX,do { static_assert( mozilla::detail::AssertionConditionType< decltype(!payload.mimeType.EqualsLiteral("image/svg+xml") || payload .width == (65535))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!payload.mimeType.EqualsLiteral ("image/svg+xml") || payload.width == (65535)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" " (" "SVG payloads should have max width" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" ") (" "SVG payloads should have max width" ")"); do { *((volatile int*)__null) = 230; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) |
| 230 | "SVG payloads should have max width")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!payload.mimeType.EqualsLiteral("image/svg+xml") || payload .width == (65535))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!payload.mimeType.EqualsLiteral ("image/svg+xml") || payload.width == (65535)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" " (" "SVG payloads should have max width" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!payload.mimeType.EqualsLiteral(\"image/svg+xml\") || payload.width == (65535)" ") (" "SVG payloads should have max width" ")"); do { *((volatile int*)__null) = 230; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
| 231 | MOZ_ASSERT(payload.width > 0, "Payload should have a width")do { static_assert( mozilla::detail::AssertionConditionType< decltype(payload.width > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(payload.width > 0))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("payload.width > 0" " (" "Payload should have a width" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 231); AnnotateMozCrashReason("MOZ_ASSERT" "(" "payload.width > 0" ") (" "Payload should have a width" ")"); do { *((volatile int *)__null) = 231; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 232 | #ifdef DEBUG1 |
| 233 | // Done to ensure we fetch the id. See the MOZ_ASSERT below. |
| 234 | payload.id = 0; |
| 235 | #endif |
| 236 | if (!ids.empty()) { |
| 237 | // Pop the first existing id for reuse. |
| 238 | int64_t id = ids.front(); |
| 239 | ids.pop_front(); |
| 240 | mozStorageStatementScoper scoper(updateStmt); |
| 241 | rv = updateStmt->BindInt64ByName("id"_ns, id); |
| 242 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 242); return rv; } } while (false); |
| 243 | rv = updateStmt->BindInt32ByName("width"_ns, payload.width); |
| 244 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 244); return rv; } } while (false); |
| 245 | rv = updateStmt->BindInt64ByName("expire"_ns, aIcon.expiration / 1000); |
| 246 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 246); return rv; } } while (false); |
| 247 | rv = updateStmt->BindInt32ByName("root"_ns, aIcon.rootIcon); |
| 248 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 248); return rv; } } while (false); |
| 249 | rv = updateStmt->BindBlobByName("data"_ns, TO_INTBUFFER(payload.data)reinterpret_cast<uint8_t*>(const_cast<char*>(payload .data.get())), |
| 250 | payload.data.Length()); |
| 251 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 251); return rv; } } while (false); |
| 252 | rv = updateStmt->Execute(); |
| 253 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 253); return rv; } } while (false); |
| 254 | // Set the new payload id. |
| 255 | payload.id = id; |
| 256 | } else { |
| 257 | // Insert a new entry. |
| 258 | mozStorageStatementScoper scoper(insertStmt); |
| 259 | rv = URIBinder::Bind(insertStmt, "url"_ns, aIcon.spec); |
| 260 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 260); return rv; } } while (false); |
| 261 | rv = insertStmt->BindInt32ByName("width"_ns, payload.width); |
| 262 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 262); return rv; } } while (false); |
| 263 | |
| 264 | rv = insertStmt->BindInt32ByName("root"_ns, aIcon.rootIcon); |
| 265 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 265); return rv; } } while (false); |
| 266 | rv = insertStmt->BindInt64ByName("expire"_ns, aIcon.expiration / 1000); |
| 267 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 267); return rv; } } while (false); |
| 268 | rv = insertStmt->BindBlobByName("data"_ns, TO_INTBUFFER(payload.data)reinterpret_cast<uint8_t*>(const_cast<char*>(payload .data.get())), |
| 269 | payload.data.Length()); |
| 270 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 270); return rv; } } while (false); |
| 271 | rv = insertStmt->Execute(); |
| 272 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 272); return rv; } } while (false); |
| 273 | // Set the new payload id. |
| 274 | payload.id = nsFaviconService::sLastInsertedIconId; |
| 275 | } |
| 276 | MOZ_ASSERT(payload.id > 0, "Payload should have an id")do { static_assert( mozilla::detail::AssertionConditionType< decltype(payload.id > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(payload.id > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("payload.id > 0" " (" "Payload should have an id" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 276); AnnotateMozCrashReason("MOZ_ASSERT" "(" "payload.id > 0" ") (" "Payload should have an id" ")"); do { *((volatile int *)__null) = 276; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 277 | } |
| 278 | |
| 279 | if (!ids.empty()) { |
| 280 | // Remove any old leftover payload. |
| 281 | nsAutoCString sql("DELETE FROM moz_icons WHERE id IN ("); |
| 282 | for (int64_t id : ids) { |
| 283 | sql.AppendInt(id); |
| 284 | sql.AppendLiteral(","); |
| 285 | } |
| 286 | sql.AppendLiteral(" 0)"); // Non-existing id to match the trailing comma. |
| 287 | nsCOMPtr<mozIStorageStatement> stmt = aDB->GetStatement(sql); |
| 288 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 288); return NS_ERROR_UNEXPECTED; } } while (false); |
| 289 | mozStorageStatementScoper scoper(stmt); |
| 290 | rv = stmt->Execute(); |
| 291 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 291); return rv; } } while (false); |
| 292 | } |
| 293 | |
| 294 | return NS_OK; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Fetches information on a icon url from the database. |
| 299 | * |
| 300 | * @param aDBConn |
| 301 | * Database connection to history tables. |
| 302 | * @param aPreferredWidth |
| 303 | * The preferred size to fetch. |
| 304 | * @param _icon |
| 305 | * Icon that should be fetched. |
| 306 | */ |
| 307 | nsresult FetchIconInfo(const RefPtr<Database>& aDB, uint16_t aPreferredWidth, |
| 308 | IconData& _icon) { |
| 309 | MOZ_ASSERT(_icon.spec.Length(), "Must have a non-empty spec!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(_icon.spec.Length())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(_icon.spec.Length()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("_icon.spec.Length()" " (" "Must have a non-empty spec!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 309); AnnotateMozCrashReason("MOZ_ASSERT" "(" "_icon.spec.Length()" ") (" "Must have a non-empty spec!" ")"); do { *((volatile int *)__null) = 309; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 310 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 310); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 310; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 311 | |
| 312 | if (_icon.status & ICON_STATUS_CACHED1 << 3) { |
| 313 | // The icon data has already been set by ReplaceFaviconData. |
| 314 | return NS_OK; |
| 315 | } |
| 316 | |
| 317 | nsCOMPtr<mozIStorageStatement> stmt = aDB->GetStatement( |
| 318 | "/* do not warn (bug no: not worth having a compound index) */ " |
| 319 | "SELECT id, expire_ms, data, width, root " |
| 320 | "FROM moz_icons " |
| 321 | "WHERE fixed_icon_url_hash = hash(fixup_url(:url)) " |
| 322 | "AND icon_url = :url " |
| 323 | "ORDER BY width DESC "); |
| 324 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 324); return NS_ERROR_UNEXPECTED; } } while (false); |
| 325 | mozStorageStatementScoper scoper(stmt); |
| 326 | |
| 327 | DebugOnly<nsresult> rv = URIBinder::Bind(stmt, "url"_ns, _icon.spec); |
| 328 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 328); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 328; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 329 | |
| 330 | bool hasResult = false; |
| 331 | while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult))((bool)(__builtin_expect(!!(!NS_FAILED_impl(stmt->ExecuteStep (&hasResult))), 1))) && hasResult) { |
| 332 | IconPayload payload; |
| 333 | rv = stmt->GetInt64(0, &payload.id); |
| 334 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 334); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 334; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 335 | |
| 336 | // Expiration can be nullptr. |
| 337 | bool isNull; |
| 338 | rv = stmt->GetIsNull(1, &isNull); |
| 339 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 339); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 339; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 340 | if (!isNull) { |
| 341 | int64_t expire_ms; |
| 342 | rv = stmt->GetInt64(1, &expire_ms); |
| 343 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 343); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 343; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 344 | _icon.expiration = expire_ms * 1000; |
| 345 | } |
| 346 | |
| 347 | uint8_t* data; |
| 348 | uint32_t dataLen = 0; |
| 349 | rv = stmt->GetBlob(2, &dataLen, &data); |
| 350 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 350); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 350; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 351 | payload.data.Adopt(TO_CHARBUFFER(data)reinterpret_cast<char*>(const_cast<uint8_t*>(data )), dataLen); |
| 352 | |
| 353 | int32_t width; |
| 354 | rv = stmt->GetInt32(3, &width); |
| 355 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 355); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 355; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 356 | payload.width = width; |
| 357 | if (payload.width == UINT16_MAX(65535)) { |
| 358 | payload.mimeType.AssignLiteral(SVG_MIME_TYPE"image/svg+xml"); |
| 359 | } else { |
| 360 | payload.mimeType.AssignLiteral(PNG_MIME_TYPE"image/png"); |
| 361 | } |
| 362 | |
| 363 | int32_t rootIcon; |
| 364 | rv = stmt->GetInt32(4, &rootIcon); |
| 365 | MOZ_ASSERT(NS_SUCCEEDED(rv))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) )))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1) ))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 365); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))" ")"); do { *((volatile int*)__null) = 365; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 366 | _icon.rootIcon = rootIcon; |
| 367 | |
| 368 | if (aPreferredWidth == 0 || _icon.payloads.Length() == 0) { |
| 369 | _icon.payloads.AppendElement(payload); |
| 370 | } else if (payload.width >= aPreferredWidth) { |
| 371 | // Only retain the best matching payload. |
| 372 | _icon.payloads.ReplaceElementAt(0, payload); |
| 373 | } else { |
| 374 | break; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | return NS_OK; |
| 379 | } |
| 380 | |
| 381 | nsresult FetchIconPerSpec(const RefPtr<Database>& aDB, |
| 382 | const nsACString& aPageSpec, |
| 383 | const nsACString& aPageHost, IconData& aIconData, |
| 384 | uint16_t aPreferredWidth) { |
| 385 | MOZ_ASSERT(!aPageSpec.IsEmpty(), "Page spec must not be empty.")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aPageSpec.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aPageSpec.IsEmpty()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!aPageSpec.IsEmpty()" " (" "Page spec must not be empty." ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 385); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aPageSpec.IsEmpty()" ") (" "Page spec must not be empty." ")"); do { *((volatile int *)__null) = 385; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 386 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 386); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 386; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 387 | |
| 388 | // This selects both associated and root domain icons, ordered by width, |
| 389 | // where an associated icon has priority over a root domain icon. |
| 390 | // Regardless, note that while this way we are far more efficient, we lost |
| 391 | // associations with root domain icons, so it's possible we'll return one |
| 392 | // for a specific size when an associated icon for that size doesn't exist. |
| 393 | nsCOMPtr<mozIStorageStatement> stmt = aDB->GetStatement( |
| 394 | "/* do not warn (bug no: not worth having a compound index) */ " |
| 395 | "SELECT width, icon_url, root " |
| 396 | "FROM moz_icons i " |
| 397 | "JOIN moz_icons_to_pages ON i.id = icon_id " |
| 398 | "JOIN moz_pages_w_icons p ON p.id = page_id " |
| 399 | "WHERE page_url_hash = hash(:url) AND page_url = :url " |
| 400 | "OR (:hash_idx AND page_url_hash = hash(substr(:url, 0, :hash_idx)) " |
| 401 | "AND page_url = substr(:url, 0, :hash_idx)) " |
| 402 | "UNION ALL " |
| 403 | "SELECT width, icon_url, root " |
| 404 | "FROM moz_icons i " |
| 405 | "WHERE fixed_icon_url_hash = hash(fixup_url(:host) || '/favicon.ico') " |
| 406 | "ORDER BY width DESC, root ASC"); |
| 407 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 407); return NS_ERROR_UNEXPECTED; } } while (false); |
| 408 | mozStorageStatementScoper scoper(stmt); |
| 409 | |
| 410 | nsresult rv = URIBinder::Bind(stmt, "url"_ns, aPageSpec); |
| 411 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 411); return rv; } } while (false); |
| 412 | rv = stmt->BindUTF8StringByName("host"_ns, aPageHost); |
| 413 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 413); return rv; } } while (false); |
| 414 | int32_t hashIdx = PromiseFlatCStringTPromiseFlatString<char>(aPageSpec).RFind("#"); |
| 415 | rv = stmt->BindInt32ByName("hash_idx"_ns, hashIdx + 1); |
| 416 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 416); return rv; } } while (false); |
| 417 | |
| 418 | // Return the biggest icon close to the preferred width. It may be bigger |
| 419 | // or smaller if the preferred width isn't found. |
| 420 | bool hasResult; |
| 421 | int32_t lastWidth = 0; |
| 422 | while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult))((bool)(__builtin_expect(!!(!NS_FAILED_impl(stmt->ExecuteStep (&hasResult))), 1))) && hasResult) { |
| 423 | int32_t width; |
| 424 | rv = stmt->GetInt32(0, &width); |
Value stored to 'rv' is never read | |
| 425 | if (lastWidth == width) { |
| 426 | // We already found an icon for this width. We always prefer the first |
| 427 | // icon found, because it's a non-root icon, per the root ASC ordering. |
| 428 | continue; |
| 429 | } |
| 430 | if (!aIconData.spec.IsEmpty() && width < aPreferredWidth) { |
| 431 | // We found the best match, or we already found a match so we don't need |
| 432 | // to fallback to the root domain icon. |
| 433 | break; |
| 434 | } |
| 435 | lastWidth = width; |
| 436 | rv = stmt->GetUTF8String(1, aIconData.spec); |
| 437 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 437); return rv; } } while (false); |
| 438 | } |
| 439 | |
| 440 | return NS_OK; |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Tries to compute the expiration time for a icon from the channel. |
| 445 | * |
| 446 | * @param aChannel |
| 447 | * The network channel used to fetch the icon. |
| 448 | * @return a valid expiration value for the fetched icon. |
| 449 | */ |
| 450 | PRTime GetExpirationTimeFromChannel(nsIChannel* aChannel) { |
| 451 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 451); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 451; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 452 | |
| 453 | // Attempt to get an expiration time from the cache. If this fails, we'll |
| 454 | // make one up. |
| 455 | PRTime now = PR_Now(); |
| 456 | PRTime expiration = -1; |
| 457 | nsCOMPtr<nsICachingChannel> cachingChannel = do_QueryInterface(aChannel); |
| 458 | if (cachingChannel) { |
| 459 | nsCOMPtr<nsISupports> cacheToken; |
| 460 | nsresult rv = cachingChannel->GetCacheToken(getter_AddRefs(cacheToken)); |
| 461 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 462 | nsCOMPtr<nsICacheEntry> cacheEntry = do_QueryInterface(cacheToken); |
| 463 | uint32_t seconds; |
| 464 | rv = cacheEntry->GetExpirationTime(&seconds); |
| 465 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 466 | // Set the expiration, but make sure we honor our cap. |
| 467 | expiration = now + std::min((PRTime)seconds * PR_USEC_PER_SEC1000000L, |
| 468 | MAX_FAVICON_EXPIRATION((PRTime)7 * 24 * 60 * 60 * 1000000L)); |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | // If we did not obtain a time from the cache, use the cap value. |
| 473 | return expiration < now + MIN_FAVICON_EXPIRATION((PRTime)1 * 24 * 60 * 60 * 1000000L) |
| 474 | ? now + MAX_FAVICON_EXPIRATION((PRTime)7 * 24 * 60 * 60 * 1000000L) |
| 475 | : expiration; |
| 476 | } |
| 477 | |
| 478 | } // namespace |
| 479 | |
| 480 | //////////////////////////////////////////////////////////////////////////////// |
| 481 | //// AsyncFetchAndSetIconForPage |
| 482 | |
| 483 | NS_IMPL_ISUPPORTS_INHERITED(AsyncFetchAndSetIconForPage, Runnable,nsresult AsyncFetchAndSetIconForPage::QueryInterface(const nsIID & aIID, void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!" , "aInstancePtr", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 485); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static_assert(4 > 0, "Need more arguments to NS_INTERFACE_TABLE_INHERITED" ); static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<AsyncFetchAndSetIconForPage, nsIStreamListener >, int32_t( reinterpret_cast<char*>(static_cast<nsIStreamListener *>((AsyncFetchAndSetIconForPage*)0x1000)) - reinterpret_cast <char*>((AsyncFetchAndSetIconForPage*)0x1000))}, {& mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIInterfaceRequestor>, int32_t( reinterpret_cast<char *>(static_cast<nsIInterfaceRequestor*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIChannelEventSink>, int32_t( reinterpret_cast<char* >(static_cast<nsIChannelEventSink*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , mozIPlacesPendingOperation>, int32_t( reinterpret_cast< char*>(static_cast<mozIPlacesPendingOperation*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, { nullptr, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID, aInstancePtr , table); if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv) ), 1)))) return rv; return Runnable::QueryInterface(aIID, aInstancePtr ); } MozExternalRefCountType AsyncFetchAndSetIconForPage::AddRef (void) { static_assert(!std::is_destructible_v<AsyncFetchAndSetIconForPage >, "Reference-counted class " "AsyncFetchAndSetIconForPage" " should not have a public destructor. " "Make this class's destructor non-public" ); nsrefcnt r = Runnable::AddRef(); if constexpr (::mozilla:: detail::ShouldLogInheritedRefcnt<AsyncFetchAndSetIconForPage >) { NS_LogAddRef((this), (r), ("AsyncFetchAndSetIconForPage" ), (uint32_t)(sizeof(*this))); } return r; } MozExternalRefCountType AsyncFetchAndSetIconForPage::Release(void) { nsrefcnt r = Runnable ::Release(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt <AsyncFetchAndSetIconForPage>) { NS_LogRelease((this), ( r), ("AsyncFetchAndSetIconForPage")); } return r; } |
| 484 | nsIStreamListener, nsIInterfaceRequestor,nsresult AsyncFetchAndSetIconForPage::QueryInterface(const nsIID & aIID, void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!" , "aInstancePtr", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 485); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static_assert(4 > 0, "Need more arguments to NS_INTERFACE_TABLE_INHERITED" ); static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<AsyncFetchAndSetIconForPage, nsIStreamListener >, int32_t( reinterpret_cast<char*>(static_cast<nsIStreamListener *>((AsyncFetchAndSetIconForPage*)0x1000)) - reinterpret_cast <char*>((AsyncFetchAndSetIconForPage*)0x1000))}, {& mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIInterfaceRequestor>, int32_t( reinterpret_cast<char *>(static_cast<nsIInterfaceRequestor*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIChannelEventSink>, int32_t( reinterpret_cast<char* >(static_cast<nsIChannelEventSink*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , mozIPlacesPendingOperation>, int32_t( reinterpret_cast< char*>(static_cast<mozIPlacesPendingOperation*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, { nullptr, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID, aInstancePtr , table); if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv) ), 1)))) return rv; return Runnable::QueryInterface(aIID, aInstancePtr ); } MozExternalRefCountType AsyncFetchAndSetIconForPage::AddRef (void) { static_assert(!std::is_destructible_v<AsyncFetchAndSetIconForPage >, "Reference-counted class " "AsyncFetchAndSetIconForPage" " should not have a public destructor. " "Make this class's destructor non-public" ); nsrefcnt r = Runnable::AddRef(); if constexpr (::mozilla:: detail::ShouldLogInheritedRefcnt<AsyncFetchAndSetIconForPage >) { NS_LogAddRef((this), (r), ("AsyncFetchAndSetIconForPage" ), (uint32_t)(sizeof(*this))); } return r; } MozExternalRefCountType AsyncFetchAndSetIconForPage::Release(void) { nsrefcnt r = Runnable ::Release(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt <AsyncFetchAndSetIconForPage>) { NS_LogRelease((this), ( r), ("AsyncFetchAndSetIconForPage")); } return r; } |
| 485 | nsIChannelEventSink, mozIPlacesPendingOperation)nsresult AsyncFetchAndSetIconForPage::QueryInterface(const nsIID & aIID, void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!" , "aInstancePtr", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 485); MOZ_PretendNoReturn(); } } while (0); nsresult rv = NS_ERROR_FAILURE ; static_assert(4 > 0, "Need more arguments to NS_INTERFACE_TABLE_INHERITED" ); static const QITableEntry table[] = { {&mozilla::detail ::kImplementedIID<AsyncFetchAndSetIconForPage, nsIStreamListener >, int32_t( reinterpret_cast<char*>(static_cast<nsIStreamListener *>((AsyncFetchAndSetIconForPage*)0x1000)) - reinterpret_cast <char*>((AsyncFetchAndSetIconForPage*)0x1000))}, {& mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIInterfaceRequestor>, int32_t( reinterpret_cast<char *>(static_cast<nsIInterfaceRequestor*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , nsIChannelEventSink>, int32_t( reinterpret_cast<char* >(static_cast<nsIChannelEventSink*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, {&mozilla::detail::kImplementedIID<AsyncFetchAndSetIconForPage , mozIPlacesPendingOperation>, int32_t( reinterpret_cast< char*>(static_cast<mozIPlacesPendingOperation*>((AsyncFetchAndSetIconForPage *)0x1000)) - reinterpret_cast<char*>((AsyncFetchAndSetIconForPage *)0x1000))}, { nullptr, 0 } } ; static_assert((sizeof(table) / sizeof(table[0])) > 1, "need at least 1 interface"); rv = NS_TableDrivenQI(static_cast<void*>(this), aIID, aInstancePtr , table); if (((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv) ), 1)))) return rv; return Runnable::QueryInterface(aIID, aInstancePtr ); } MozExternalRefCountType AsyncFetchAndSetIconForPage::AddRef (void) { static_assert(!std::is_destructible_v<AsyncFetchAndSetIconForPage >, "Reference-counted class " "AsyncFetchAndSetIconForPage" " should not have a public destructor. " "Make this class's destructor non-public" ); nsrefcnt r = Runnable::AddRef(); if constexpr (::mozilla:: detail::ShouldLogInheritedRefcnt<AsyncFetchAndSetIconForPage >) { NS_LogAddRef((this), (r), ("AsyncFetchAndSetIconForPage" ), (uint32_t)(sizeof(*this))); } return r; } MozExternalRefCountType AsyncFetchAndSetIconForPage::Release(void) { nsrefcnt r = Runnable ::Release(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt <AsyncFetchAndSetIconForPage>) { NS_LogRelease((this), ( r), ("AsyncFetchAndSetIconForPage")); } return r; } |
| 486 | |
| 487 | AsyncFetchAndSetIconForPage::AsyncFetchAndSetIconForPage( |
| 488 | IconData& aIcon, PageData& aPage, bool aFaviconLoadPrivate, |
| 489 | nsIFaviconDataCallback* aCallback, nsIPrincipal* aLoadingPrincipal, |
| 490 | uint64_t aRequestContextID) |
| 491 | : Runnable("places::AsyncFetchAndSetIconForPage"), |
| 492 | mCallback(new nsMainThreadPtrHolder<nsIFaviconDataCallback>( |
| 493 | "AsyncFetchAndSetIconForPage::mCallback", aCallback)), |
| 494 | mIcon(aIcon), |
| 495 | mPage(aPage), |
| 496 | mFaviconLoadPrivate(aFaviconLoadPrivate), |
| 497 | mLoadingPrincipal(new nsMainThreadPtrHolder<nsIPrincipal>( |
| 498 | "AsyncFetchAndSetIconForPage::mLoadingPrincipal", aLoadingPrincipal)), |
| 499 | mCanceled(false), |
| 500 | mRequestContextID(aRequestContextID) { |
| 501 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 501); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 501; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 502 | } |
| 503 | |
| 504 | NS_IMETHODIMPnsresult |
| 505 | AsyncFetchAndSetIconForPage::Run() { |
| 506 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 506); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 506; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 507 | |
| 508 | // Try to fetch the icon from the database. |
| 509 | RefPtr<Database> DB = Database::GetDatabase(); |
| 510 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 510); return NS_ERROR_UNEXPECTED; } } while (false); |
| 511 | nsresult rv = FetchIconInfo(DB, 0, mIcon); |
| 512 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 512); return rv; } } while (false); |
| 513 | |
| 514 | bool isInvalidIcon = !mIcon.payloads.Length() || PR_Now() > mIcon.expiration; |
| 515 | bool fetchIconFromNetwork = |
| 516 | mIcon.fetchMode == FETCH_ALWAYS || |
| 517 | (mIcon.fetchMode == FETCH_IF_MISSING && isInvalidIcon); |
| 518 | |
| 519 | // Check if we can associate the icon to this page. |
| 520 | rv = FetchPageInfo(DB, mPage); |
| 521 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 522 | if (rv == NS_ERROR_NOT_AVAILABLE) { |
| 523 | // We have never seen this page. If we can add the page to history, |
| 524 | // we will try to do it later, otherwise just bail out. |
| 525 | if (!mPage.canAddToHistory) { |
| 526 | return NS_OK; |
| 527 | } |
| 528 | } |
| 529 | return rv; |
| 530 | } |
| 531 | |
| 532 | if (!fetchIconFromNetwork) { |
| 533 | // There is already a valid icon or we don't want to fetch a new one, |
| 534 | // directly proceed with association. |
| 535 | RefPtr<AsyncAssociateIconToPage> event = |
| 536 | new AsyncAssociateIconToPage(mIcon, mPage, mCallback); |
| 537 | // We're already on the async thread. |
| 538 | return event->Run(); |
| 539 | } |
| 540 | |
| 541 | // Fetch the icon from the network, the request starts from the main-thread. |
| 542 | // When done this will associate the icon to the page and notify. |
| 543 | nsCOMPtr<nsIRunnable> event = |
| 544 | NewRunnableMethod("places::AsyncFetchAndSetIconForPage::FetchFromNetwork", |
| 545 | this, &AsyncFetchAndSetIconForPage::FetchFromNetwork); |
| 546 | return NS_DispatchToMainThread(event); |
| 547 | } |
| 548 | |
| 549 | nsresult AsyncFetchAndSetIconForPage::FetchFromNetwork() { |
| 550 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 550); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 550; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 551 | |
| 552 | if (mCanceled) { |
| 553 | return NS_OK; |
| 554 | } |
| 555 | |
| 556 | // Ensure data is cleared, since it's going to be overwritten. |
| 557 | mIcon.payloads.Clear(); |
| 558 | |
| 559 | IconPayload payload; |
| 560 | mIcon.payloads.AppendElement(payload); |
| 561 | |
| 562 | nsCOMPtr<nsIURI> iconURI; |
| 563 | nsresult rv = NS_NewURI(getter_AddRefs(iconURI), mIcon.spec); |
| 564 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 564); return rv; } } while (false); |
| 565 | nsCOMPtr<nsIChannel> channel; |
| 566 | rv = NS_NewChannel(getter_AddRefs(channel), iconURI, mLoadingPrincipal, |
| 567 | nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_INHERITS_SEC_CONTEXT | |
| 568 | nsILoadInfo::SEC_ALLOW_CHROME | |
| 569 | nsILoadInfo::SEC_DISALLOW_SCRIPT, |
| 570 | nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON); |
| 571 | |
| 572 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 572); return rv; } } while (false); |
| 573 | nsCOMPtr<nsIInterfaceRequestor> listenerRequestor = |
| 574 | do_QueryInterface(reinterpret_cast<nsISupports*>(this)); |
| 575 | NS_ENSURE_STATE(listenerRequestor)do { if ((__builtin_expect(!!(!(listenerRequestor)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "listenerRequestor" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 575); return NS_ERROR_UNEXPECTED; } } while (false); |
| 576 | rv = channel->SetNotificationCallbacks(listenerRequestor); |
| 577 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 577); return rv; } } while (false); |
| 578 | nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(channel); |
| 579 | if (pbChannel) { |
| 580 | rv = pbChannel->SetPrivate(mFaviconLoadPrivate); |
| 581 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 581); return rv; } } while (false); |
| 582 | } |
| 583 | |
| 584 | nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(channel); |
| 585 | if (priorityChannel) { |
| 586 | priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST); |
| 587 | } |
| 588 | |
| 589 | if (StaticPrefs::network_http_tailing_enabled()) { |
| 590 | nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(channel); |
| 591 | if (cos) { |
| 592 | cos->AddClassFlags(nsIClassOfService::Tail | |
| 593 | nsIClassOfService::Throttleable); |
| 594 | } |
| 595 | |
| 596 | nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); |
| 597 | if (httpChannel) { |
| 598 | Unused << httpChannel->SetRequestContextID(mRequestContextID); |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | rv = channel->AsyncOpen(this); |
| 603 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 604 | mRequest = channel; |
| 605 | } |
| 606 | return rv; |
| 607 | } |
| 608 | |
| 609 | NS_IMETHODIMPnsresult |
| 610 | AsyncFetchAndSetIconForPage::Cancel() { |
| 611 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 611); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 611; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 612 | if (mCanceled) { |
| 613 | return NS_ERROR_UNEXPECTED; |
| 614 | } |
| 615 | mCanceled = true; |
| 616 | if (mRequest) { |
| 617 | mRequest->CancelWithReason(NS_BINDING_ABORTED, |
| 618 | "AsyncFetchAndSetIconForPage::Cancel"_ns); |
| 619 | } |
| 620 | return NS_OK; |
| 621 | } |
| 622 | |
| 623 | NS_IMETHODIMPnsresult |
| 624 | AsyncFetchAndSetIconForPage::OnStartRequest(nsIRequest* aRequest) { |
| 625 | // mRequest should already be set from ::FetchFromNetwork, but in the case of |
| 626 | // a redirect we might get a new request, and we should make sure we keep a |
| 627 | // reference to the most current request. |
| 628 | mRequest = aRequest; |
| 629 | if (mCanceled) { |
| 630 | mRequest->Cancel(NS_BINDING_ABORTED); |
| 631 | } |
| 632 | // Don't store icons responding with Cache-Control: no-store, but always |
| 633 | // allow root domain icons. |
| 634 | nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest); |
| 635 | if (httpChannel) { |
| 636 | bool isNoStore; |
| 637 | nsAutoCString path; |
| 638 | nsCOMPtr<nsIURI> uri; |
| 639 | if (NS_SUCCEEDED(httpChannel->GetURI(getter_AddRefs(uri)))((bool)(__builtin_expect(!!(!NS_FAILED_impl(httpChannel->GetURI (getter_AddRefs(uri)))), 1))) && |
| 640 | NS_SUCCEEDED(uri->GetFilePath(path))((bool)(__builtin_expect(!!(!NS_FAILED_impl(uri->GetFilePath (path))), 1))) && |
| 641 | !path.EqualsLiteral("/favicon.ico") && |
| 642 | NS_SUCCEEDED(httpChannel->IsNoStoreResponse(&isNoStore))((bool)(__builtin_expect(!!(!NS_FAILED_impl(httpChannel->IsNoStoreResponse (&isNoStore))), 1))) && isNoStore) { |
| 643 | // Abandon the network fetch. |
| 644 | mRequest->CancelWithReason( |
| 645 | NS_BINDING_ABORTED, "AsyncFetchAndSetIconForPage::OnStartRequest"_ns); |
| 646 | } |
| 647 | } |
| 648 | return NS_OK; |
| 649 | } |
| 650 | |
| 651 | NS_IMETHODIMPnsresult |
| 652 | AsyncFetchAndSetIconForPage::OnDataAvailable(nsIRequest* aRequest, |
| 653 | nsIInputStream* aInputStream, |
| 654 | uint64_t aOffset, |
| 655 | uint32_t aCount) { |
| 656 | MOZ_ASSERT(mIcon.payloads.Length() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mIcon.payloads.Length() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mIcon.payloads.Length() == 1 ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mIcon.payloads.Length() == 1", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 656); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mIcon.payloads.Length() == 1" ")"); do { *((volatile int*)__null) = 656; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 657 | // Limit downloads to 500KB. |
| 658 | const size_t kMaxDownloadSize = 500 * 1024; |
| 659 | if (mIcon.payloads[0].data.Length() + aCount > kMaxDownloadSize) { |
| 660 | mIcon.payloads.Clear(); |
| 661 | return NS_ERROR_FILE_TOO_BIG; |
| 662 | } |
| 663 | |
| 664 | nsAutoCString buffer; |
| 665 | nsresult rv = NS_ConsumeStream(aInputStream, aCount, buffer); |
| 666 | if (rv != NS_BASE_STREAM_WOULD_BLOCK && NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 667 | return rv; |
| 668 | } |
| 669 | |
| 670 | if (!mIcon.payloads[0].data.Append(buffer, fallible)) { |
| 671 | mIcon.payloads.Clear(); |
| 672 | return NS_ERROR_OUT_OF_MEMORY; |
| 673 | } |
| 674 | |
| 675 | return NS_OK; |
| 676 | } |
| 677 | |
| 678 | NS_IMETHODIMPnsresult |
| 679 | AsyncFetchAndSetIconForPage::GetInterface(const nsIID& uuid, void** aResult) { |
| 680 | return QueryInterface(uuid, aResult); |
| 681 | } |
| 682 | |
| 683 | NS_IMETHODIMPnsresult |
| 684 | AsyncFetchAndSetIconForPage::AsyncOnChannelRedirect( |
| 685 | nsIChannel* oldChannel, nsIChannel* newChannel, uint32_t flags, |
| 686 | nsIAsyncVerifyRedirectCallback* cb) { |
| 687 | // If we've been canceled, stop the redirect with NS_BINDING_ABORTED, and |
| 688 | // handle the cancel on the original channel. |
| 689 | (void)cb->OnRedirectVerifyCallback(mCanceled ? NS_BINDING_ABORTED : NS_OK); |
| 690 | return NS_OK; |
| 691 | } |
| 692 | |
| 693 | NS_IMETHODIMPnsresult |
| 694 | AsyncFetchAndSetIconForPage::OnStopRequest(nsIRequest* aRequest, |
| 695 | nsresult aStatusCode) { |
| 696 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 696); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 696; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 697 | |
| 698 | // Don't need to track this anymore. |
| 699 | mRequest = nullptr; |
| 700 | if (mCanceled) { |
| 701 | return NS_OK; |
| 702 | } |
| 703 | |
| 704 | nsFaviconService* favicons = nsFaviconService::GetFaviconService(); |
| 705 | NS_ENSURE_STATE(favicons)do { if ((__builtin_expect(!!(!(favicons)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "favicons" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 705); return NS_ERROR_UNEXPECTED; } } while (false); |
| 706 | |
| 707 | nsresult rv; |
| 708 | |
| 709 | // If fetching the icon failed, bail out. |
| 710 | if (NS_FAILED(aStatusCode)((bool)(__builtin_expect(!!(NS_FAILED_impl(aStatusCode)), 0)) ) || mIcon.payloads.Length() == 0) { |
| 711 | return NS_OK; |
| 712 | } |
| 713 | |
| 714 | nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); |
| 715 | // aRequest should always QI to nsIChannel. |
| 716 | MOZ_ASSERT(channel)do { static_assert( mozilla::detail::AssertionConditionType< decltype(channel)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(channel))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("channel", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 716); AnnotateMozCrashReason("MOZ_ASSERT" "(" "channel" ")" ); do { *((volatile int*)__null) = 716; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 717 | |
| 718 | MOZ_ASSERT(mIcon.payloads.Length() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mIcon.payloads.Length() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mIcon.payloads.Length() == 1 ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "mIcon.payloads.Length() == 1", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 718); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mIcon.payloads.Length() == 1" ")"); do { *((volatile int*)__null) = 718; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 719 | IconPayload& payload = mIcon.payloads[0]; |
| 720 | |
| 721 | nsAutoCString contentType; |
| 722 | channel->GetContentType(contentType); |
| 723 | // Bug 366324 - We don't want to sniff for SVG, so rely on server-specified |
| 724 | // type. |
| 725 | if (contentType.EqualsLiteral(SVG_MIME_TYPE"image/svg+xml")) { |
| 726 | payload.mimeType.AssignLiteral(SVG_MIME_TYPE"image/svg+xml"); |
| 727 | payload.width = UINT16_MAX(65535); |
| 728 | } else { |
| 729 | NS_SniffContent(NS_DATA_SNIFFER_CATEGORY"content-sniffing-services", aRequest, |
| 730 | TO_INTBUFFER(payload.data)reinterpret_cast<uint8_t*>(const_cast<char*>(payload .data.get())), payload.data.Length(), |
| 731 | payload.mimeType); |
| 732 | } |
| 733 | |
| 734 | // If the icon does not have a valid MIME type, bail out. |
| 735 | if (payload.mimeType.IsEmpty()) { |
| 736 | return NS_OK; |
| 737 | } |
| 738 | |
| 739 | mIcon.expiration = GetExpirationTimeFromChannel(channel); |
| 740 | |
| 741 | // Telemetry probes to measure the favicon file sizes for each different file |
| 742 | // type. This allow us to measure common file sizes while also observing each |
| 743 | // type popularity. |
| 744 | if (payload.mimeType.EqualsLiteral(PNG_MIME_TYPE"image/png")) { |
| 745 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_PNG_SIZES, |
| 746 | payload.data.Length()); |
| 747 | } else if (payload.mimeType.EqualsLiteral("image/x-icon") || |
| 748 | payload.mimeType.EqualsLiteral("image/vnd.microsoft.icon")) { |
| 749 | Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_ICO_SIZES, |
| 750 | payload.data.Length()); |
| 751 | } else if (payload.mimeType.EqualsLiteral("image/jpeg") || |
| 752 | payload.mimeType.EqualsLiteral("image/pjpeg")) { |
| 753 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_JPEG_SIZES, |
| 754 | payload.data.Length()); |
| 755 | } else if (payload.mimeType.EqualsLiteral("image/gif")) { |
| 756 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_GIF_SIZES, |
| 757 | payload.data.Length()); |
| 758 | } else if (payload.mimeType.EqualsLiteral("image/bmp") || |
| 759 | payload.mimeType.EqualsLiteral("image/x-windows-bmp")) { |
| 760 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_BMP_SIZES, |
| 761 | payload.data.Length()); |
| 762 | } else if (payload.mimeType.EqualsLiteral(SVG_MIME_TYPE"image/svg+xml")) { |
| 763 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_SVG_SIZES, |
| 764 | payload.data.Length()); |
| 765 | } else { |
| 766 | Telemetry::Accumulate(Telemetry::PLACES_FAVICON_OTHER_SIZES, |
| 767 | payload.data.Length()); |
| 768 | } |
| 769 | |
| 770 | rv = favicons->OptimizeIconSizes(mIcon); |
| 771 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 771); return rv; } } while (false); |
| 772 | |
| 773 | mIcon.status = ICON_STATUS_CHANGED1 << 0; |
| 774 | |
| 775 | RefPtr<Database> DB = Database::GetDatabase(); |
| 776 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 776); return NS_ERROR_UNEXPECTED; } } while (false); |
| 777 | RefPtr<AsyncAssociateIconToPage> event = |
| 778 | new AsyncAssociateIconToPage(mIcon, mPage, mCallback); |
| 779 | DB->DispatchToAsyncThread(event); |
| 780 | |
| 781 | return NS_OK; |
| 782 | } |
| 783 | |
| 784 | //////////////////////////////////////////////////////////////////////////////// |
| 785 | //// AsyncAssociateIconToPage |
| 786 | |
| 787 | AsyncAssociateIconToPage::AsyncAssociateIconToPage( |
| 788 | const IconData& aIcon, const PageData& aPage, |
| 789 | const nsMainThreadPtrHandle<nsIFaviconDataCallback>& aCallback) |
| 790 | : Runnable("places::AsyncAssociateIconToPage"), |
| 791 | mCallback(aCallback), |
| 792 | mIcon(aIcon), |
| 793 | mPage(aPage) { |
| 794 | // May be created in both threads. |
| 795 | } |
| 796 | |
| 797 | NS_IMETHODIMPnsresult |
| 798 | AsyncAssociateIconToPage::Run() { |
| 799 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 799); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 799; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 800 | MOZ_ASSERT(!mPage.guid.IsEmpty(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mPage.guid.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mPage.guid.IsEmpty()))), 0) )) { do { } while (false); MOZ_ReportAssertionFailure("!mPage.guid.IsEmpty()" " (" "Page info should have been fetched already" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 801); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mPage.guid.IsEmpty()" ") (" "Page info should have been fetched already" ")"); do { *((volatile int*)__null) = 801; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) |
| 801 | "Page info should have been fetched already")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mPage.guid.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mPage.guid.IsEmpty()))), 0) )) { do { } while (false); MOZ_ReportAssertionFailure("!mPage.guid.IsEmpty()" " (" "Page info should have been fetched already" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 801); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mPage.guid.IsEmpty()" ") (" "Page info should have been fetched already" ")"); do { *((volatile int*)__null) = 801; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); |
| 802 | MOZ_ASSERT(mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty()" " (" "The page should be addable to history or a bookmark" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 803); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty()" ") (" "The page should be addable to history or a bookmark" ")" ); do { *((volatile int*)__null) = 803; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
| 803 | "The page should be addable to history or a bookmark")do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty()" " (" "The page should be addable to history or a bookmark" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 803); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPage.canAddToHistory || !mPage.bookmarkedSpec.IsEmpty()" ") (" "The page should be addable to history or a bookmark" ")" ); do { *((volatile int*)__null) = 803; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 804 | |
| 805 | bool shouldUpdateIcon = mIcon.status & ICON_STATUS_CHANGED1 << 0; |
| 806 | if (!shouldUpdateIcon) { |
| 807 | for (const auto& payload : mIcon.payloads) { |
| 808 | // If the entry is missing from the database, we should add it. |
| 809 | if (payload.id == 0) { |
| 810 | shouldUpdateIcon = true; |
| 811 | break; |
| 812 | } |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | RefPtr<Database> DB = Database::GetDatabase(); |
| 817 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 817); return NS_ERROR_UNEXPECTED; } } while (false); |
| 818 | |
| 819 | mozStorageTransaction transaction( |
| 820 | DB->MainConn(), false, mozIStorageConnection::TRANSACTION_IMMEDIATE); |
| 821 | |
| 822 | // XXX Handle the error, bug 1696133. |
| 823 | Unused << NS_WARN_IF(NS_FAILED(transaction.Start()))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(transaction .Start())), 0))), "NS_FAILED(transaction.Start())", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 823); |
| 824 | |
| 825 | nsresult rv; |
| 826 | if (shouldUpdateIcon) { |
| 827 | rv = SetIconInfo(DB, mIcon); |
| 828 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 829 | (void)transaction.Commit(); |
| 830 | return rv; |
| 831 | } |
| 832 | |
| 833 | mIcon.status = (mIcon.status & ~(ICON_STATUS_CACHED1 << 3)) | ICON_STATUS_SAVED1 << 1; |
| 834 | } |
| 835 | |
| 836 | // If the page does not have an id, don't try to insert a new one, cause we |
| 837 | // don't know where the page comes from. Not doing so we may end adding |
| 838 | // a page that otherwise we'd explicitly ignore, like a POST or an error page. |
| 839 | if (mPage.placeId == 0) { |
| 840 | rv = transaction.Commit(); |
| 841 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 841); return rv; } } while (false); |
| 842 | return NS_OK; |
| 843 | } |
| 844 | |
| 845 | // Expire old favicons to keep up with website changes. Associated icons must |
| 846 | // be expired also when storing a root favicon, because a page may change to |
| 847 | // only have a root favicon. |
| 848 | // Note that here we could also be in the process of adding further payloads |
| 849 | // to a page, and we don't want to expire just added payloads. For this |
| 850 | // reason we only remove expired payloads. |
| 851 | // Oprhan icons are not removed at this time because it'd be expensive. The |
| 852 | // privacy implications are limited, since history removal methods also expire |
| 853 | // orphan icons. |
| 854 | if (mPage.id > 0) { |
| 855 | nsCOMPtr<mozIStorageStatement> stmt; |
| 856 | stmt = DB->GetStatement( |
| 857 | "DELETE FROM moz_icons_to_pages " |
| 858 | "WHERE page_id = :page_id " |
| 859 | "AND expire_ms < strftime('%s','now','localtime','utc') * 1000 "); |
| 860 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 860); return NS_ERROR_UNEXPECTED; } } while (false); |
| 861 | mozStorageStatementScoper scoper(stmt); |
| 862 | rv = stmt->BindInt64ByName("page_id"_ns, mPage.id); |
| 863 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 863); return rv; } } while (false); |
| 864 | rv = stmt->Execute(); |
| 865 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 865); return rv; } } while (false); |
| 866 | } |
| 867 | |
| 868 | // Don't associate pages to root domain icons, since those will be returned |
| 869 | // regardless. This saves a lot of work and database space since we don't |
| 870 | // need to store urls and relations. |
| 871 | // Though, this is possible only if both the page and the icon have the same |
| 872 | // host, otherwise we couldn't relate them. |
| 873 | if (!mIcon.rootIcon || !mIcon.host.Equals(mPage.host)) { |
| 874 | // The page may have associated payloads already, and those could have to be |
| 875 | // expired. For example at a certain point a page could decide to stop |
| 876 | // serving its usual 16px and 32px pngs, and use an svg instead. On the |
| 877 | // other side, we could also be in the process of adding more payloads to |
| 878 | // this page, and we should not expire the payloads we just added. For this, |
| 879 | // we use the expiration field as an indicator and remove relations based on |
| 880 | // it being elapsed. We don't remove orphan icons at this time since it |
| 881 | // would have a cost. The privacy hit is limited since history removal |
| 882 | // methods already expire orphan icons. |
| 883 | if (mPage.id == 0) { |
| 884 | // We need to create the page entry. |
| 885 | nsCOMPtr<mozIStorageStatement> stmt; |
| 886 | stmt = DB->GetStatement( |
| 887 | "INSERT OR IGNORE INTO moz_pages_w_icons (page_url, page_url_hash) " |
| 888 | "VALUES (:page_url, hash(:page_url)) "); |
| 889 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 889); return NS_ERROR_UNEXPECTED; } } while (false); |
| 890 | mozStorageStatementScoper scoper(stmt); |
| 891 | rv = URIBinder::Bind(stmt, "page_url"_ns, mPage.spec); |
| 892 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 892); return rv; } } while (false); |
| 893 | rv = stmt->Execute(); |
| 894 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 894); return rv; } } while (false); |
| 895 | } |
| 896 | |
| 897 | // Then we can create the relations. |
| 898 | nsCOMPtr<mozIStorageStatement> stmt; |
| 899 | stmt = DB->GetStatement( |
| 900 | "INSERT INTO moz_icons_to_pages (page_id, icon_id, expire_ms) " |
| 901 | "VALUES ((SELECT id from moz_pages_w_icons WHERE page_url_hash = " |
| 902 | "hash(:page_url) AND page_url = :page_url), " |
| 903 | ":icon_id, :expire) " |
| 904 | "ON CONFLICT(page_id, icon_id) DO " |
| 905 | "UPDATE SET expire_ms = :expire "); |
| 906 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 906); return NS_ERROR_UNEXPECTED; } } while (false); |
| 907 | |
| 908 | // For some reason using BindingParamsArray here fails execution, so we must |
| 909 | // execute the statements one by one. |
| 910 | // In the future we may want to investigate the reasons, sounds like related |
| 911 | // to contraints. |
| 912 | for (const auto& payload : mIcon.payloads) { |
| 913 | mozStorageStatementScoper scoper(stmt); |
| 914 | nsCOMPtr<mozIStorageBindingParams> params; |
| 915 | rv = URIBinder::Bind(stmt, "page_url"_ns, mPage.spec); |
| 916 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 916); return rv; } } while (false); |
| 917 | rv = stmt->BindInt64ByName("icon_id"_ns, payload.id); |
| 918 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 918); return rv; } } while (false); |
| 919 | rv = stmt->BindInt64ByName("expire"_ns, mIcon.expiration / 1000); |
| 920 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 920); return rv; } } while (false); |
| 921 | rv = stmt->Execute(); |
| 922 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 922); return rv; } } while (false); |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | mIcon.status |= ICON_STATUS_ASSOCIATED1 << 2; |
| 927 | |
| 928 | rv = transaction.Commit(); |
| 929 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 929); return rv; } } while (false); |
| 930 | |
| 931 | // Finally, dispatch an event to the main thread to notify observers. |
| 932 | nsCOMPtr<nsIRunnable> event = |
| 933 | new NotifyIconObservers(mIcon, mPage, mCallback); |
| 934 | rv = NS_DispatchToMainThread(event); |
| 935 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 935); return rv; } } while (false); |
| 936 | |
| 937 | // If there is a bookmarked page that redirects to this one, try to update its |
| 938 | // icon as well. |
| 939 | if (!mPage.bookmarkedSpec.IsEmpty() && |
| 940 | !mPage.bookmarkedSpec.Equals(mPage.spec)) { |
| 941 | // Create a new page struct to avoid polluting it with old data. |
| 942 | PageData bookmarkedPage; |
| 943 | bookmarkedPage.spec = mPage.bookmarkedSpec; |
| 944 | RefPtr<Database> DB = Database::GetDatabase(); |
| 945 | if (DB && NS_SUCCEEDED(FetchPageInfo(DB, bookmarkedPage))((bool)(__builtin_expect(!!(!NS_FAILED_impl(FetchPageInfo(DB, bookmarkedPage))), 1)))) { |
| 946 | // This will be silent, so be sure to not pass in the current callback. |
| 947 | nsMainThreadPtrHandle<nsIFaviconDataCallback> nullCallback; |
| 948 | RefPtr<AsyncAssociateIconToPage> event = |
| 949 | new AsyncAssociateIconToPage(mIcon, bookmarkedPage, nullCallback); |
| 950 | Unused << event->Run(); |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | return NS_OK; |
| 955 | } |
| 956 | |
| 957 | //////////////////////////////////////////////////////////////////////////////// |
| 958 | //// AsyncSetIconForPage |
| 959 | |
| 960 | AsyncSetIconForPage::AsyncSetIconForPage(const IconData& aIcon, |
| 961 | const PageData& aPage, |
| 962 | PlacesCompletionCallback* aCallback) |
| 963 | : Runnable("places::AsyncSetIconForPage"), |
| 964 | mCallback(new nsMainThreadPtrHolder<PlacesCompletionCallback>( |
| 965 | "AsyncSetIconForPage::mCallback", aCallback, false)), |
| 966 | mIcon(aIcon), |
| 967 | mPage(aPage) {} |
| 968 | |
| 969 | NS_IMETHODIMPnsresult |
| 970 | AsyncSetIconForPage::Run() { |
| 971 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 971); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 971; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 972 | MOZ_ASSERT(mIcon.payloads.Length(), "The icon should have valid data")do { static_assert( mozilla::detail::AssertionConditionType< decltype(mIcon.payloads.Length())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mIcon.payloads.Length()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("mIcon.payloads.Length()" " (" "The icon should have valid data" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 972); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mIcon.payloads.Length()" ") (" "The icon should have valid data" ")"); do { *((volatile int*)__null) = 972; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
| 973 | MOZ_ASSERT(mPage.spec.Length(), "The page should have spec")do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPage.spec.Length())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPage.spec.Length()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mPage.spec.Length()" " (" "The page should have spec" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 973); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPage.spec.Length()" ") (" "The page should have spec" ")"); do { *((volatile int *)__null) = 973; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); |
| 974 | MOZ_ASSERT(mPage.guid.IsEmpty(), "The page should not have guid")do { static_assert( mozilla::detail::AssertionConditionType< decltype(mPage.guid.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mPage.guid.IsEmpty()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("mPage.guid.IsEmpty()" " (" "The page should not have guid" ")", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 974); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mPage.guid.IsEmpty()" ") (" "The page should not have guid" ")"); do { *((volatile int*)__null) = 974; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); |
| 975 | |
| 976 | nsresult rv = NS_OK; |
| 977 | auto guard = MakeScopeExit([&]() { |
| 978 | if (mCallback) { |
| 979 | NS_DispatchToMainThread( |
| 980 | NS_NewRunnableFunction("AsyncSetIconForPage::Callback", |
| 981 | [rv, callback = std::move(mCallback)]() { |
| 982 | (void)callback->Complete(rv); |
| 983 | })); |
| 984 | } |
| 985 | }); |
| 986 | |
| 987 | // Fetch the page data. |
| 988 | RefPtr<Database> DB = Database::GetDatabase(); |
| 989 | if (MOZ_UNLIKELY(!DB)(__builtin_expect(!!(!DB), 0))) { |
| 990 | return (rv = NS_ERROR_UNEXPECTED); |
| 991 | } |
| 992 | rv = FetchPageInfo(DB, mPage); |
| 993 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 993); return rv; } } while (false); |
| 994 | |
| 995 | nsMainThreadPtrHandle<nsIFaviconDataCallback> nullCallback; |
| 996 | AsyncAssociateIconToPage event(mIcon, mPage, nullCallback); |
| 997 | return (rv = event.Run()); |
| 998 | } |
| 999 | |
| 1000 | //////////////////////////////////////////////////////////////////////////////// |
| 1001 | //// AsyncGetFaviconURLForPage |
| 1002 | |
| 1003 | AsyncGetFaviconURLForPage::AsyncGetFaviconURLForPage( |
| 1004 | const nsACString& aPageSpec, const nsACString& aPageHost, |
| 1005 | uint16_t aPreferredWidth, nsIFaviconDataCallback* aCallback) |
| 1006 | : Runnable("places::AsyncGetFaviconURLForPage"), |
| 1007 | mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX(65535) : aPreferredWidth), |
| 1008 | mCallback(new nsMainThreadPtrHolder<nsIFaviconDataCallback>( |
| 1009 | "AsyncGetFaviconURLForPage::mCallback", aCallback)) { |
| 1010 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1010); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1010; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1011 | mPageSpec.Assign(aPageSpec); |
| 1012 | mPageHost.Assign(aPageHost); |
| 1013 | } |
| 1014 | |
| 1015 | NS_IMETHODIMPnsresult |
| 1016 | AsyncGetFaviconURLForPage::Run() { |
| 1017 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1017); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1017; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1018 | |
| 1019 | RefPtr<Database> DB = Database::GetDatabase(); |
| 1020 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1020); return NS_ERROR_UNEXPECTED; } } while (false); |
| 1021 | IconData iconData; |
| 1022 | nsresult rv = |
| 1023 | FetchIconPerSpec(DB, mPageSpec, mPageHost, iconData, mPreferredWidth); |
| 1024 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1024); return rv; } } while (false); |
| 1025 | |
| 1026 | // Now notify our callback of the icon spec we retrieved, even if empty. |
| 1027 | PageData pageData; |
| 1028 | pageData.spec.Assign(mPageSpec); |
| 1029 | |
| 1030 | nsCOMPtr<nsIRunnable> event = |
| 1031 | new NotifyIconObservers(iconData, pageData, mCallback); |
| 1032 | rv = NS_DispatchToMainThread(event); |
| 1033 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1033); return rv; } } while (false); |
| 1034 | |
| 1035 | return NS_OK; |
| 1036 | } |
| 1037 | |
| 1038 | //////////////////////////////////////////////////////////////////////////////// |
| 1039 | //// AsyncGetFaviconDataForPage |
| 1040 | |
| 1041 | AsyncGetFaviconDataForPage::AsyncGetFaviconDataForPage( |
| 1042 | const nsACString& aPageSpec, const nsACString& aPageHost, |
| 1043 | uint16_t aPreferredWidth, nsIFaviconDataCallback* aCallback) |
| 1044 | : Runnable("places::AsyncGetFaviconDataForPage"), |
| 1045 | mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX(65535) : aPreferredWidth), |
| 1046 | mCallback(new nsMainThreadPtrHolder<nsIFaviconDataCallback>( |
| 1047 | "AsyncGetFaviconDataForPage::mCallback", aCallback)) { |
| 1048 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1048); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1048; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1049 | mPageSpec.Assign(aPageSpec); |
| 1050 | mPageHost.Assign(aPageHost); |
| 1051 | } |
| 1052 | |
| 1053 | NS_IMETHODIMPnsresult |
| 1054 | AsyncGetFaviconDataForPage::Run() { |
| 1055 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1055); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1055; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1056 | |
| 1057 | RefPtr<Database> DB = Database::GetDatabase(); |
| 1058 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1058); return NS_ERROR_UNEXPECTED; } } while (false); |
| 1059 | IconData iconData; |
| 1060 | nsresult rv = |
| 1061 | FetchIconPerSpec(DB, mPageSpec, mPageHost, iconData, mPreferredWidth); |
| 1062 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1062); return rv; } } while (false); |
| 1063 | |
| 1064 | if (!iconData.spec.IsEmpty()) { |
| 1065 | rv = FetchIconInfo(DB, mPreferredWidth, iconData); |
| 1066 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { |
| 1067 | iconData.spec.Truncate(); |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | PageData pageData; |
| 1072 | pageData.spec.Assign(mPageSpec); |
| 1073 | |
| 1074 | nsCOMPtr<nsIRunnable> event = |
| 1075 | new NotifyIconObservers(iconData, pageData, mCallback); |
| 1076 | rv = NS_DispatchToMainThread(event); |
| 1077 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1077); return rv; } } while (false); |
| 1078 | return NS_OK; |
| 1079 | } |
| 1080 | |
| 1081 | //////////////////////////////////////////////////////////////////////////////// |
| 1082 | //// NotifyIconObservers |
| 1083 | |
| 1084 | NotifyIconObservers::NotifyIconObservers( |
| 1085 | const IconData& aIcon, const PageData& aPage, |
| 1086 | const nsMainThreadPtrHandle<nsIFaviconDataCallback>& aCallback) |
| 1087 | : Runnable("places::NotifyIconObservers"), |
| 1088 | mCallback(aCallback), |
| 1089 | mIcon(aIcon), |
| 1090 | mPage(aPage) {} |
| 1091 | |
| 1092 | // MOZ_CAN_RUN_SCRIPT_BOUNDARY until Runnable::Run is marked |
| 1093 | // MOZ_CAN_RUN_SCRIPT. See bug 1535398. |
| 1094 | MOZ_CAN_RUN_SCRIPT_BOUNDARY |
| 1095 | NS_IMETHODIMPnsresult |
| 1096 | NotifyIconObservers::Run() { |
| 1097 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1097); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1097; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1098 | |
| 1099 | nsCOMPtr<nsIURI> iconURI; |
| 1100 | if (!mIcon.spec.IsEmpty()) { |
| 1101 | if (!NS_WARN_IF(NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(NS_NewURI (getter_AddRefs(iconURI), mIcon.spec))), 0))), "NS_FAILED(NS_NewURI(getter_AddRefs(iconURI), mIcon.spec))" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1102) |
| 1102 | NS_FAILED(NS_NewURI(getter_AddRefs(iconURI), mIcon.spec)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(NS_NewURI (getter_AddRefs(iconURI), mIcon.spec))), 0))), "NS_FAILED(NS_NewURI(getter_AddRefs(iconURI), mIcon.spec))" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1102)) { |
| 1103 | // Notify observers only if something changed. |
| 1104 | if (mIcon.status & ICON_STATUS_SAVED1 << 1 || |
| 1105 | mIcon.status & ICON_STATUS_ASSOCIATED1 << 2) { |
| 1106 | nsCOMPtr<nsIURI> pageURI; |
| 1107 | if (!NS_WARN_IF(NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(NS_NewURI (getter_AddRefs(pageURI), mPage.spec))), 0))), "NS_FAILED(NS_NewURI(getter_AddRefs(pageURI), mPage.spec))" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1108) |
| 1108 | NS_FAILED(NS_NewURI(getter_AddRefs(pageURI), mPage.spec)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(NS_NewURI (getter_AddRefs(pageURI), mPage.spec))), 0))), "NS_FAILED(NS_NewURI(getter_AddRefs(pageURI), mPage.spec))" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1108)) { |
| 1109 | // Invalide page-icon image cache, since the icon is about to change. |
| 1110 | nsFaviconService* favicons = nsFaviconService::GetFaviconService(); |
| 1111 | MOZ_ASSERT(favicons)do { static_assert( mozilla::detail::AssertionConditionType< decltype(favicons)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(favicons))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("favicons", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1111); AnnotateMozCrashReason("MOZ_ASSERT" "(" "favicons" ")" ); do { *((volatile int*)__null) = 1111; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1112 | if (favicons) { |
| 1113 | nsCString pageIconSpec("page-icon:"); |
| 1114 | pageIconSpec.Append(mPage.spec); |
| 1115 | nsCOMPtr<nsIURI> pageIconURI; |
| 1116 | if (NS_SUCCEEDED(((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewURI(getter_AddRefs (pageIconURI), pageIconSpec))), 1))) |
| 1117 | NS_NewURI(getter_AddRefs(pageIconURI), pageIconSpec))((bool)(__builtin_expect(!!(!NS_FAILED_impl(NS_NewURI(getter_AddRefs (pageIconURI), pageIconSpec))), 1)))) { |
| 1118 | favicons->ClearImageCache(pageIconURI); |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | // Notify about the favicon change. |
| 1123 | dom::Sequence<OwningNonNull<dom::PlacesEvent>> events; |
| 1124 | RefPtr<dom::PlacesFavicon> faviconEvent = new dom::PlacesFavicon(); |
| 1125 | AppendUTF8toUTF16(mPage.spec, faviconEvent->mUrl); |
| 1126 | AppendUTF8toUTF16(mIcon.spec, faviconEvent->mFaviconUrl); |
| 1127 | faviconEvent->mPageGuid.Assign(mPage.guid); |
| 1128 | bool success = |
| 1129 | !!events.AppendElement(faviconEvent.forget(), fallible); |
| 1130 | MOZ_RELEASE_ASSERT(success)do { static_assert( mozilla::detail::AssertionConditionType< decltype(success)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(success))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("success", "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1130); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "success" ")"); do { *((volatile int*)__null) = 1130; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1131 | dom::PlacesObservers::NotifyListeners(events); |
| 1132 | } |
| 1133 | } |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | if (!mCallback) { |
| 1138 | return NS_OK; |
| 1139 | } |
| 1140 | |
| 1141 | if (mIcon.payloads.Length() > 0) { |
| 1142 | IconPayload& payload = mIcon.payloads[0]; |
| 1143 | return mCallback->OnComplete(iconURI, payload.data.Length(), |
| 1144 | TO_INTBUFFER(payload.data)reinterpret_cast<uint8_t*>(const_cast<char*>(payload .data.get())), payload.mimeType, |
| 1145 | payload.width); |
| 1146 | } |
| 1147 | return mCallback->OnComplete(iconURI, 0, TO_INTBUFFER(EmptyCString())reinterpret_cast<uint8_t*>(const_cast<char*>(EmptyCString ().get())), ""_ns, |
| 1148 | 0); |
| 1149 | } |
| 1150 | |
| 1151 | //////////////////////////////////////////////////////////////////////////////// |
| 1152 | //// AsyncCopyFavicons |
| 1153 | |
| 1154 | AsyncCopyFavicons::AsyncCopyFavicons(PageData& aFromPage, PageData& aToPage, |
| 1155 | nsIFaviconDataCallback* aCallback) |
| 1156 | : Runnable("places::AsyncCopyFavicons"), |
| 1157 | mFromPage(aFromPage), |
| 1158 | mToPage(aToPage), |
| 1159 | mCallback(new nsMainThreadPtrHolder<nsIFaviconDataCallback>( |
| 1160 | "AsyncCopyFavicons::mCallback", aCallback)) { |
| 1161 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1161); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1161; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1162 | } |
| 1163 | |
| 1164 | NS_IMETHODIMPnsresult |
| 1165 | AsyncCopyFavicons::Run() { |
| 1166 | MOZ_ASSERT(!NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1166); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 1166; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 1167 | |
| 1168 | IconData icon; |
| 1169 | |
| 1170 | // Ensure we'll callback and dispatch notifications to the main-thread. |
| 1171 | auto cleanup = MakeScopeExit([&]() { |
| 1172 | // If we bailed out early, just return a null icon uri, since we didn't |
| 1173 | // copy anything. |
| 1174 | if (!(icon.status & ICON_STATUS_ASSOCIATED1 << 2)) { |
| 1175 | icon.spec.Truncate(); |
| 1176 | } |
| 1177 | nsCOMPtr<nsIRunnable> event = |
| 1178 | new NotifyIconObservers(icon, mToPage, mCallback); |
| 1179 | NS_DispatchToMainThread(event); |
| 1180 | }); |
| 1181 | |
| 1182 | RefPtr<Database> DB = Database::GetDatabase(); |
| 1183 | NS_ENSURE_STATE(DB)do { if ((__builtin_expect(!!(!(DB)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "DB" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1183); return NS_ERROR_UNEXPECTED; } } while (false); |
| 1184 | |
| 1185 | nsresult rv = FetchPageInfo(DB, mToPage); |
| 1186 | if (rv == NS_ERROR_NOT_AVAILABLE || !mToPage.placeId) { |
| 1187 | // We have never seen this page, or we can't add this page to history and |
| 1188 | // and it's not a bookmark. We won't add the page. |
| 1189 | return NS_OK; |
| 1190 | } |
| 1191 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1191); return rv; } } while (false); |
| 1192 | |
| 1193 | // Get just one icon, to check whether the page has any, and to notify |
| 1194 | // later. |
| 1195 | rv = FetchIconPerSpec(DB, mFromPage.spec, ""_ns, icon, UINT16_MAX(65535)); |
| 1196 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1196); return rv; } } while (false); |
| 1197 | |
| 1198 | if (icon.spec.IsEmpty()) { |
| 1199 | // There's nothing to copy. |
| 1200 | return NS_OK; |
| 1201 | } |
| 1202 | |
| 1203 | // Insert an entry in moz_pages_w_icons if needed. |
| 1204 | if (!mToPage.id) { |
| 1205 | // We need to create the page entry. |
| 1206 | nsCOMPtr<mozIStorageStatement> stmt; |
| 1207 | stmt = DB->GetStatement( |
| 1208 | "INSERT OR IGNORE INTO moz_pages_w_icons (page_url, page_url_hash) " |
| 1209 | "VALUES (:page_url, hash(:page_url)) "); |
| 1210 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1210); return NS_ERROR_UNEXPECTED; } } while (false); |
| 1211 | mozStorageStatementScoper scoper(stmt); |
| 1212 | rv = URIBinder::Bind(stmt, "page_url"_ns, mToPage.spec); |
| 1213 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1213); return rv; } } while (false); |
| 1214 | rv = stmt->Execute(); |
| 1215 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1215); return rv; } } while (false); |
| 1216 | // Required to to fetch the id and the guid. |
| 1217 | rv = FetchPageInfo(DB, mToPage); |
| 1218 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1218); return rv; } } while (false); |
| 1219 | } |
| 1220 | |
| 1221 | // Create the relations. |
| 1222 | nsCOMPtr<mozIStorageStatement> stmt = DB->GetStatement( |
| 1223 | "INSERT OR IGNORE INTO moz_icons_to_pages (page_id, icon_id, expire_ms) " |
| 1224 | "SELECT :id, icon_id, expire_ms " |
| 1225 | "FROM moz_icons_to_pages " |
| 1226 | "WHERE page_id = (SELECT id FROM moz_pages_w_icons WHERE page_url_hash = " |
| 1227 | "hash(:url) AND page_url = :url) "); |
| 1228 | NS_ENSURE_STATE(stmt)do { if ((__builtin_expect(!!(!(stmt)), 0))) { NS_DebugBreak( NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "stmt" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1228); return NS_ERROR_UNEXPECTED; } } while (false); |
| 1229 | mozStorageStatementScoper scoper(stmt); |
| 1230 | rv = stmt->BindInt64ByName("id"_ns, mToPage.id); |
| 1231 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1231); return rv; } } while (false); |
| 1232 | rv = URIBinder::Bind(stmt, "url"_ns, mFromPage.spec); |
| 1233 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1233); return rv; } } while (false); |
| 1234 | rv = stmt->Execute(); |
| 1235 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/places/FaviconHelpers.cpp" , 1235); return rv; } } while (false); |
| 1236 | |
| 1237 | // Setting this will make us send pageChanged notifications. |
| 1238 | // The scope exit will take care of the callback and notifications. |
| 1239 | icon.status |= ICON_STATUS_ASSOCIATED1 << 2; |
| 1240 | |
| 1241 | return NS_OK; |
| 1242 | } |
| 1243 | |
| 1244 | } // namespace places |
| 1245 | } // namespace mozilla |