Commit 1c6b231b authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Reland "Reland "Reland "Turn on Media History by default"""

This is a reland of 9b0c684e

Original change's description:
> Reland "Reland "Turn on Media History by default""
>
> This is a reland of c670ba45
>
> Original change's description:
> > Reland "Turn on Media History by default"
> >
> > This is a reland of ccf0e2f9
> >
> > Fixes TSAN issue in the constructor of sql::Database
> > by moving it to the main thread.
> >
> > Original change's description:
> > > Turn on Media History by default
> > >
> > > BUG=1024351
> > >
> > > Change-Id: Id01595e63f5f776a226087741ef602ba30b80328
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2295224
> > > Auto-Submit: Becca Hughes <beccahughes@chromium.org>
> > > Commit-Queue: Tommy Steimel <steimel@chromium.org>
> > > Reviewed-by: Tommy Steimel <steimel@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#787954}
> >
> > Bug: 1024351
> > Change-Id: I19be665637f5c28261f7197547ddc5fe6671127e
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2296884
> > Reviewed-by: Tommy Steimel <steimel@chromium.org>
> > Commit-Queue: Becca Hughes <beccahughes@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#788312}
>
> Bug: 1024351
> Change-Id: Ie371d56df987c19a10017050ead02922a530f2ed
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300224
> Reviewed-by: Tommy Steimel <steimel@chromium.org>
> Commit-Queue: Becca Hughes <beccahughes@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#788721}

Bug: 1024351
Change-Id: I91cc6ee379d46ab5ef0b30436aeda90695629f4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2307485Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790018}
parent 8da815e6
......@@ -22,8 +22,7 @@ MediaHistoryKeyedService* MediaHistoryKeyedServiceFactory::GetForProfile(
// static
MediaHistoryKeyedServiceFactory*
MediaHistoryKeyedServiceFactory::GetInstance() {
static base::NoDestructor<MediaHistoryKeyedServiceFactory> factory;
return factory.get();
return base::Singleton<MediaHistoryKeyedServiceFactory>::get();
}
MediaHistoryKeyedServiceFactory::MediaHistoryKeyedServiceFactory()
......
......@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_MEDIA_HISTORY_MEDIA_HISTORY_KEYED_SERVICE_FACTORY_H_
#define CHROME_BROWSER_MEDIA_HISTORY_MEDIA_HISTORY_KEYED_SERVICE_FACTORY_H_
#include "base/no_destructor.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class KeyedService;
......@@ -29,7 +29,7 @@ class MediaHistoryKeyedServiceFactory
bool ServiceIsCreatedWithBrowserContext() const override;
private:
friend class base::NoDestructor<MediaHistoryKeyedServiceFactory>;
friend struct base::DefaultSingletonTraits<MediaHistoryKeyedServiceFactory>;
MediaHistoryKeyedServiceFactory();
~MediaHistoryKeyedServiceFactory() override;
......
......@@ -174,6 +174,8 @@ MediaHistoryStore::MediaHistoryStore(
scoped_refptr<base::UpdateableSequencedTaskRunner> db_task_runner)
: db_task_runner_(db_task_runner),
db_path_(GetDBPath(profile)),
db_(std::make_unique<sql::Database>()),
meta_table_(std::make_unique<sql::MetaTable>()),
origin_table_(new MediaHistoryOriginTable(db_task_runner_)),
playback_table_(new MediaHistoryPlaybackTable(db_task_runner_)),
session_table_(new MediaHistorySessionTable(db_task_runner_)),
......@@ -186,7 +188,14 @@ MediaHistoryStore::MediaHistoryStore(
feed_items_table_(IsMediaFeedsEnabled()
? new MediaHistoryFeedItemsTable(db_task_runner_)
: nullptr),
initialization_successful_(false) {}
initialization_successful_(false) {
db_->set_histogram_tag("MediaHistory");
db_->set_exclusive_locking();
// To recover from corruption.
db_->set_error_callback(
base::BindRepeating(&DatabaseErrorCallback, db_.get(), db_path_));
}
MediaHistoryStore::~MediaHistoryStore() {
// The connection pointer needs to be deleted on the DB sequence since there
......@@ -304,16 +313,6 @@ void MediaHistoryStore::Initialize(const bool should_reset) {
MediaHistoryStore::InitResult MediaHistoryStore::InitializeInternal() {
DCHECK(db_task_runner_->RunsTasksInCurrentSequence());
db_ = std::make_unique<sql::Database>();
db_->set_histogram_tag("MediaHistory");
db_->set_exclusive_locking();
// To recover from corruption.
db_->set_error_callback(
base::BindRepeating(&DatabaseErrorCallback, db_.get(), db_path_));
meta_table_ = std::make_unique<sql::MetaTable>();
if (db_path_.empty()) {
if (IsCancelled() || !db_ || !db_->OpenInMemory()) {
LOG(ERROR) << "Failed to open the in-memory database.";
......@@ -336,8 +335,6 @@ MediaHistoryStore::InitResult MediaHistoryStore::InitializeInternal() {
}
}
db_->Preload();
if (IsCancelled() || !db_ || !db_->Execute("PRAGMA foreign_keys=1")) {
LOG(ERROR) << "Failed to enable foreign keys on the media history store.";
......
......@@ -410,7 +410,7 @@ const base::Feature kUseNewMediaCache{"use-new-media-cache",
// Enables using the media history store to store media engagement metrics.
const base::Feature kUseMediaHistoryStore{"UseMediaHistoryStore",
base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_ENABLED_BY_DEFAULT};
// Use R16 texture for 9-16 bit channel instead of half-float conversion by CPU.
const base::Feature kUseR16Texture{"use-r16-texture",
......
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