Commit da7e98db authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

favicons: move favicon types into own file

This will make it easier to move the database into the favicon
directory.

BUG=1076463
TEST=covered by tests

Change-Id: I98c64f1794530771ebcee70928b5d1e2f3d5445e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308933Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790647}
parent f3e99037
......@@ -22,6 +22,8 @@ static_library("browser") {
"expire_history_backend.h",
"favicon_database.cc",
"favicon_database.h",
"favicon_types.cc",
"favicon_types.h",
"history_backend.cc",
"history_backend.h",
"history_backend_client.h",
......
......@@ -8,10 +8,9 @@
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/favicon_types.h"
#include "sql/database.h"
#include "sql/init_status.h"
#include "sql/meta_table.h"
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/history/core/browser/favicon_types.h"
namespace history {
// IconMapping ----------------------------------------------------------------
IconMapping::IconMapping() = default;
IconMapping::IconMapping(const IconMapping&) = default;
IconMapping::IconMapping(IconMapping&&) noexcept = default;
IconMapping::~IconMapping() = default;
IconMapping& IconMapping::operator=(const IconMapping&) = default;
// IconMappingsForExpiry ------------------------------------------------------
IconMappingsForExpiry::IconMappingsForExpiry() = default;
IconMappingsForExpiry::IconMappingsForExpiry(
const IconMappingsForExpiry& other) = default;
IconMappingsForExpiry::~IconMappingsForExpiry() = default;
// FaviconBitmap --------------------------------------------------------------
FaviconBitmap::FaviconBitmap() = default;
FaviconBitmap::FaviconBitmap(const FaviconBitmap& other) = default;
FaviconBitmap::~FaviconBitmap() = default;
// FaviconBitmapIDSize ---------------------------------------------------------
FaviconBitmapIDSize::FaviconBitmapIDSize() = default;
FaviconBitmapIDSize::~FaviconBitmapIDSize() = default;
} // namespace history
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_HISTORY_CORE_BROWSER_FAVICON_TYPES_H_
#define COMPONENTS_HISTORY_CORE_BROWSER_FAVICON_TYPES_H_
#include <vector>
#include "base/memory/ref_counted_memory.h"
#include "base/time/time.h"
#include "components/favicon_base/favicon_types.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
namespace history {
using FaviconBitmapID = int64_t; // Identifier for a bitmap in a favicon.
using IconMappingID = int64_t; // For page url and icon mapping.
// Used for the mapping between the page and icon.
struct IconMapping {
IconMapping();
IconMapping(const IconMapping&);
IconMapping(IconMapping&&) noexcept;
~IconMapping();
IconMapping& operator=(const IconMapping&);
// The unique id of the mapping.
IconMappingID mapping_id = 0;
// The url of a web page.
GURL page_url;
// The unique id of the icon.
favicon_base::FaviconID icon_id = 0;
// The url of the icon.
GURL icon_url;
// The type of icon.
favicon_base::IconType icon_type = favicon_base::IconType::kInvalid;
};
// Defines a favicon bitmap and its associated pixel size.
struct FaviconBitmapIDSize {
FaviconBitmapIDSize();
~FaviconBitmapIDSize();
// The unique id of the favicon bitmap.
FaviconBitmapID bitmap_id = 0;
// The pixel dimensions of the associated bitmap.
gfx::Size pixel_size;
};
enum FaviconBitmapType {
// The bitmap gets downloaded while visiting its page. Their life-time is
// bound to the life-time of the corresponding visit in history.
// - These bitmaps are re-downloaded when visiting the page again and the
// last_updated timestamp is old enough.
ON_VISIT,
// The bitmap gets downloaded because it is demanded by some Chrome UI (while
// not visiting its page). For this reason, their life-time cannot be bound to
// the life-time of the corresponding visit in history.
// - These bitmaps are evicted from the database based on the last time they
// were requested.
// - Furthermore, on-demand bitmaps are immediately marked as expired. Hence,
// they are always replaced by ON_VISIT favicons whenever their page gets
// visited.
ON_DEMAND
};
// Defines all associated mappings of a given favicon.
struct IconMappingsForExpiry {
IconMappingsForExpiry();
IconMappingsForExpiry(const IconMappingsForExpiry& other);
~IconMappingsForExpiry();
// URL of a given favicon.
GURL icon_url;
// URLs of all pages mapped to a given favicon
std::vector<GURL> page_urls;
};
// Defines a favicon bitmap stored in the history backend.
struct FaviconBitmap {
FaviconBitmap();
FaviconBitmap(const FaviconBitmap& other);
~FaviconBitmap();
// The unique id of the bitmap.
FaviconBitmapID bitmap_id = 0;
// The id of the favicon to which the bitmap belongs to.
favicon_base::FaviconID icon_id = 0;
// Time at which |bitmap_data| was last updated.
base::Time last_updated;
// Time at which |bitmap_data| was last requested.
base::Time last_requested;
// The bits of the bitmap.
scoped_refptr<base::RefCountedMemory> bitmap_data;
// The pixel dimensions of bitmap_data.
gfx::Size pixel_size;
};
} // namespace history
#endif // COMPONENTS_HISTORY_CORE_BROWSER_FAVICON_TYPES_H_
......@@ -288,39 +288,6 @@ DomainMetricSet::DomainMetricSet(const DomainMetricSet&) = default;
DomainMetricSet::~DomainMetricSet() {}
DomainMetricSet& DomainMetricSet::operator=(const DomainMetricSet&) = default;
// IconMapping ----------------------------------------------------------------
IconMapping::IconMapping() {}
IconMapping::IconMapping(const IconMapping&) = default;
IconMapping::IconMapping(IconMapping&&) noexcept = default;
IconMapping::~IconMapping() {}
IconMapping& IconMapping::operator=(const IconMapping&) = default;
// FaviconBitmapIDSize ---------------------------------------------------------
FaviconBitmapIDSize::FaviconBitmapIDSize() {}
FaviconBitmapIDSize::~FaviconBitmapIDSize() {}
// IconMappingsForExpiry ------------------------------------------------------
IconMappingsForExpiry::IconMappingsForExpiry() {}
IconMappingsForExpiry::IconMappingsForExpiry(
const IconMappingsForExpiry& other) = default;
IconMappingsForExpiry::~IconMappingsForExpiry() {}
// FaviconBitmap --------------------------------------------------------------
FaviconBitmap::FaviconBitmap() {}
FaviconBitmap::FaviconBitmap(const FaviconBitmap& other) = default;
FaviconBitmap::~FaviconBitmap() {}
// ExpireHistoryArgs ----------------------------------------------------------
ExpireHistoryArgs::ExpireHistoryArgs() {
......
......@@ -17,7 +17,6 @@
#include "base/callback.h"
#include "base/containers/stack_container.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
......@@ -27,7 +26,6 @@
#include "components/history/core/common/thumbnail_score.h"
#include "components/query_parser/query_parser.h"
#include "ui/base/page_transition_types.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
namespace history {
......@@ -37,9 +35,7 @@ class PageUsageData;
// Container for a list of URLs.
typedef std::vector<GURL> RedirectList;
typedef int64_t FaviconBitmapID; // Identifier for a bitmap in a favicon.
typedef int64_t SegmentID; // URL segments for the most visited view.
typedef int64_t IconMappingID; // For page url and icon mapping.
// The enumeration of all possible sources of visits is listed below.
// The source will be propagated along with a URL or a visit item
......@@ -506,100 +502,6 @@ struct HistoryLastVisitToHostResult {
base::Time last_visit;
};
// Favicons -------------------------------------------------------------------
// Used for the mapping between the page and icon.
struct IconMapping {
IconMapping();
IconMapping(const IconMapping&);
IconMapping(IconMapping&&) noexcept;
~IconMapping();
IconMapping& operator=(const IconMapping&);
// The unique id of the mapping.
IconMappingID mapping_id = 0;
// The url of a web page.
GURL page_url;
// The unique id of the icon.
favicon_base::FaviconID icon_id = 0;
// The url of the icon.
GURL icon_url;
// The type of icon.
favicon_base::IconType icon_type = favicon_base::IconType::kInvalid;
};
// Defines a favicon bitmap and its associated pixel size.
struct FaviconBitmapIDSize {
FaviconBitmapIDSize();
~FaviconBitmapIDSize();
// The unique id of the favicon bitmap.
FaviconBitmapID bitmap_id = 0;
// The pixel dimensions of the associated bitmap.
gfx::Size pixel_size;
};
enum FaviconBitmapType {
// The bitmap gets downloaded while visiting its page. Their life-time is
// bound to the life-time of the corresponding visit in history.
// - These bitmaps are re-downloaded when visiting the page again and the
// last_updated timestamp is old enough.
ON_VISIT,
// The bitmap gets downloaded because it is demanded by some Chrome UI (while
// not visiting its page). For this reason, their life-time cannot be bound to
// the life-time of the corresponding visit in history.
// - These bitmaps are evicted from the database based on the last time they
// were requested.
// - Furthermore, on-demand bitmaps are immediately marked as expired. Hence,
// they are always replaced by ON_VISIT favicons whenever their page gets
// visited.
ON_DEMAND
};
// Defines all associated mappings of a given favicon.
struct IconMappingsForExpiry {
IconMappingsForExpiry();
IconMappingsForExpiry(const IconMappingsForExpiry& other);
~IconMappingsForExpiry();
// URL of a given favicon.
GURL icon_url;
// URLs of all pages mapped to a given favicon
std::vector<GURL> page_urls;
};
// Defines a favicon bitmap stored in the history backend.
struct FaviconBitmap {
FaviconBitmap();
FaviconBitmap(const FaviconBitmap& other);
~FaviconBitmap();
// The unique id of the bitmap.
FaviconBitmapID bitmap_id = 0;
// The id of the favicon to which the bitmap belongs to.
favicon_base::FaviconID icon_id = 0;
// Time at which |bitmap_data| was last updated.
base::Time last_updated;
// Time at which |bitmap_data| was last requested.
base::Time last_requested;
// The bits of the bitmap.
scoped_refptr<base::RefCountedMemory> bitmap_data;
// The pixel dimensions of bitmap_data.
gfx::Size pixel_size;
};
struct ExpireHistoryArgs {
ExpireHistoryArgs();
ExpireHistoryArgs(const ExpireHistoryArgs& other);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment