gecko-dev/toolkit/components/places/nsPlacesIndexes.h
Marco Bonardo eb7475a826 Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
  1. moz_pages_w_icons
     This is the way to join with moz_places, through page_url_hash and page_url.
     We are not using the place id to avoid possible mismatches between places.sqlite
     and favicons.sqlite. This way the database is "portable" and reusable even
     if places.sqlite changes.
  2. moz_icons
     Contains icons payloads, each payload can either be an SVG or a PNG. These
     are the only stored formats, any other format is rescaled and converted to
     PNG. ICO files are split into single frames and stored as multiple PNGs.
     SVG are distinguishable through width == UINT16_MAX
     In future the table will also contain mask-icon color for SVG and average
     color for PNGs.
     The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
     means icons like "domain/favicon.ico" that can also be reused for any page
     under that domain.
  3. moz_icons_to_pages
     This is the relation table between icons and pages.
     Each page can have multiple icons, each icon can be used by multiple pages.
     There is a FOREIGN_KEY constraint between this (child) table and icons
     or pages (parents), so that it's not possible to insert non-existing ids
     in this table, and if an entry is removed from a parent table, the relation
     will be automatically removed from here.
     Note though that removing from the relation table won't remove from the
     parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.


MozReview-Commit-ID: CUCoL9smRyt

--HG--
extra : rebase_source : 4d25966596dcdf63c9c872425c5bf147406d25ac
2016-11-14 16:22:46 +01:00

139 lines
3.3 KiB
C

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsPlacesIndexes_h__
#define nsPlacesIndexes_h__
#define CREATE_PLACES_IDX(__name, __table, __columns, __type) \
NS_LITERAL_CSTRING( \
"CREATE " __type " INDEX IF NOT EXISTS " __table "_" __name \
" ON " __table " (" __columns ")" \
)
/**
* moz_places
*/
#define CREATE_IDX_MOZ_PLACES_URL_HASH \
CREATE_PLACES_IDX( \
"url_hashindex", "moz_places", "url_hash", "" \
)
#define CREATE_IDX_MOZ_PLACES_FAVICON \
CREATE_PLACES_IDX( \
"faviconindex", "moz_places", "favicon_id", "" \
)
#define CREATE_IDX_MOZ_PLACES_REVHOST \
CREATE_PLACES_IDX( \
"hostindex", "moz_places", "rev_host", "" \
)
#define CREATE_IDX_MOZ_PLACES_VISITCOUNT \
CREATE_PLACES_IDX( \
"visitcount", "moz_places", "visit_count", "" \
)
#define CREATE_IDX_MOZ_PLACES_FRECENCY \
CREATE_PLACES_IDX( \
"frecencyindex", "moz_places", "frecency", "" \
)
#define CREATE_IDX_MOZ_PLACES_LASTVISITDATE \
CREATE_PLACES_IDX( \
"lastvisitdateindex", "moz_places", "last_visit_date", "" \
)
#define CREATE_IDX_MOZ_PLACES_GUID \
CREATE_PLACES_IDX( \
"guid_uniqueindex", "moz_places", "guid", "UNIQUE" \
)
/**
* moz_historyvisits
*/
#define CREATE_IDX_MOZ_HISTORYVISITS_PLACEDATE \
CREATE_PLACES_IDX( \
"placedateindex", "moz_historyvisits", "place_id, visit_date", "" \
)
#define CREATE_IDX_MOZ_HISTORYVISITS_FROMVISIT \
CREATE_PLACES_IDX( \
"fromindex", "moz_historyvisits", "from_visit", "" \
)
#define CREATE_IDX_MOZ_HISTORYVISITS_VISITDATE \
CREATE_PLACES_IDX( \
"dateindex", "moz_historyvisits", "visit_date", "" \
)
/**
* moz_bookmarks
*/
#define CREATE_IDX_MOZ_BOOKMARKS_PLACETYPE \
CREATE_PLACES_IDX( \
"itemindex", "moz_bookmarks", "fk, type", "" \
)
#define CREATE_IDX_MOZ_BOOKMARKS_PARENTPOSITION \
CREATE_PLACES_IDX( \
"parentindex", "moz_bookmarks", "parent, position", "" \
)
#define CREATE_IDX_MOZ_BOOKMARKS_PLACELASTMODIFIED \
CREATE_PLACES_IDX( \
"itemlastmodifiedindex", "moz_bookmarks", "fk, lastModified", "" \
)
#define CREATE_IDX_MOZ_BOOKMARKS_GUID \
CREATE_PLACES_IDX( \
"guid_uniqueindex", "moz_bookmarks", "guid", "UNIQUE" \
)
/**
* moz_annos
*/
#define CREATE_IDX_MOZ_ANNOS_PLACEATTRIBUTE \
CREATE_PLACES_IDX( \
"placeattributeindex", "moz_annos", "place_id, anno_attribute_id", "UNIQUE" \
)
/**
* moz_items_annos
*/
#define CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE \
CREATE_PLACES_IDX( \
"itemattributeindex", "moz_items_annos", "item_id, anno_attribute_id", "UNIQUE" \
)
/**
* moz_keywords
*/
#define CREATE_IDX_MOZ_KEYWORDS_PLACEPOSTDATA \
CREATE_PLACES_IDX( \
"placepostdata_uniqueindex", "moz_keywords", "place_id, post_data", "UNIQUE" \
)
// moz_pages_w_icons
#define CREATE_IDX_MOZ_PAGES_W_ICONS_ICONURLHASH \
CREATE_PLACES_IDX( \
"urlhashindex", "moz_pages_w_icons", "page_url_hash", "" \
)
// moz_icons
#define CREATE_IDX_MOZ_ICONS_ICONURLHASH \
CREATE_PLACES_IDX( \
"iconurlhashindex", "moz_icons", "fixed_icon_url_hash", "" \
)
#endif // nsPlacesIndexes_h__