Commit f57e03df authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Media History] Make store API private

This makes the store API private and moves
it to MediaHistoryKeyedService. This is so
we can create a read only version of MHKS
in the future for incognito.

BUG=1051239

Change-Id: Ia2f2b6f548eeb6d305dbdd1d7d3cf8de58878d04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088401Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746979}
parent 15ff40a3
......@@ -91,7 +91,7 @@ class MediaHistoryBrowserTest : public InProcessBrowserTest {
base::RunLoop run_loop;
std::vector<mojom::MediaHistoryPlaybackSessionRowPtr> out;
GetMediaHistoryStore()->GetPlaybackSessions(
GetMediaHistoryService()->GetPlaybackSessions(
max_sessions, std::move(filter),
base::BindLambdaForTesting(
[&](std::vector<mojom::MediaHistoryPlaybackSessionRowPtr>
......@@ -108,7 +108,7 @@ class MediaHistoryBrowserTest : public InProcessBrowserTest {
base::RunLoop run_loop;
mojom::MediaHistoryStatsPtr stats_out;
GetMediaHistoryStore()->GetMediaHistoryStats(
GetMediaHistoryService()->GetMediaHistoryStats(
base::BindLambdaForTesting([&](mojom::MediaHistoryStatsPtr stats) {
stats_out = std::move(stats);
run_loop.Quit();
......@@ -213,9 +213,8 @@ class MediaHistoryBrowserTest : public InProcessBrowserTest {
return content::MediaSession::Get(GetWebContents());
}
MediaHistoryStore* GetMediaHistoryStore() {
return MediaHistoryKeyedServiceFactory::GetForProfile(browser()->profile())
->GetMediaHistoryStore();
MediaHistoryKeyedService* GetMediaHistoryService() {
return MediaHistoryKeyedServiceFactory::GetForProfile(browser()->profile());
}
private:
......
......@@ -62,7 +62,7 @@ void MediaHistoryContentsObserver::WebContentsDestroyed() {
void MediaHistoryContentsObserver::MediaWatchTimeChanged(
const content::MediaPlayerWatchTime& watch_time) {
if (service_)
service_->GetMediaHistoryStore()->SavePlayback(watch_time);
service_->SavePlayback(watch_time);
}
void MediaHistoryContentsObserver::MediaSessionInfoChanged(
......@@ -112,8 +112,8 @@ void MediaHistoryContentsObserver::MaybeCommitMediaSession() {
return;
}
service_->GetMediaHistoryStore()->SavePlaybackSession(
current_url_, *cached_metadata_, cached_position_, cached_artwork_);
service_->SavePlaybackSession(current_url_, *cached_metadata_,
cached_position_, cached_artwork_);
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(MediaHistoryContentsObserver)
......@@ -86,4 +86,54 @@ void MediaHistoryKeyedService::OnURLsDeleted(
// should remove data by URL.
}
void MediaHistoryKeyedService::SavePlayback(
const content::MediaPlayerWatchTime& watch_time) {
media_history_store_->SavePlayback(watch_time);
}
void MediaHistoryKeyedService::GetMediaHistoryStats(
base::OnceCallback<void(mojom::MediaHistoryStatsPtr)> callback) {
media_history_store_->GetMediaHistoryStats(std::move(callback));
}
void MediaHistoryKeyedService::GetOriginRowsForDebug(
base::OnceCallback<void(std::vector<mojom::MediaHistoryOriginRowPtr>)>
callback) {
media_history_store_->GetOriginRowsForDebug(std::move(callback));
}
void MediaHistoryKeyedService::GetMediaHistoryPlaybackRowsForDebug(
base::OnceCallback<void(std::vector<mojom::MediaHistoryPlaybackRowPtr>)>
callback) {
media_history_store_->GetMediaHistoryPlaybackRowsForDebug(
std::move(callback));
}
void MediaHistoryKeyedService::GetPlaybackSessions(
base::Optional<unsigned int> num_sessions,
base::Optional<GetPlaybackSessionsFilter> filter,
base::OnceCallback<
void(std::vector<mojom::MediaHistoryPlaybackSessionRowPtr>)> callback) {
media_history_store_->GetPlaybackSessions(num_sessions, filter,
std::move(callback));
}
void MediaHistoryKeyedService::SavePlaybackSession(
const GURL& url,
const media_session::MediaMetadata& metadata,
const base::Optional<media_session::MediaPosition>& position,
const std::vector<media_session::MediaImage>& artwork) {
media_history_store_->SavePlaybackSession(url, metadata, position, artwork);
}
void MediaHistoryKeyedService::GetURLsInTableForTest(
const std::string& table,
base::OnceCallback<void(std::set<GURL>)> callback) {
media_history_store_->GetURLsInTableForTest(table, std::move(callback));
}
void MediaHistoryKeyedService::SaveMediaFeed(const GURL& url) {
media_history_store_->SaveMediaFeed(url);
}
} // namespace media_history
......@@ -12,6 +12,12 @@
class Profile;
namespace media_session {
struct MediaImage;
struct MediaMetadata;
struct MediaPosition;
} // namespace media_session
namespace history {
class HistoryService;
} // namespace history
......@@ -29,10 +35,6 @@ class MediaHistoryKeyedService : public KeyedService,
// Returns the instance attached to the given |profile|.
static MediaHistoryKeyedService* Get(Profile* profile);
MediaHistoryStore* GetMediaHistoryStore() {
return media_history_store_.get();
}
// Overridden from KeyedService:
void Shutdown() override;
......@@ -40,6 +42,53 @@ class MediaHistoryKeyedService : public KeyedService,
void OnURLsDeleted(history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) override;
// Saves a playback from a single player in the media history store.
void SavePlayback(const content::MediaPlayerWatchTime& watch_time);
void GetMediaHistoryStats(
base::OnceCallback<void(mojom::MediaHistoryStatsPtr)> callback);
// Returns all the rows in the origin table. This should only be used for
// debugging because it is very slow.
void GetOriginRowsForDebug(
base::OnceCallback<void(std::vector<mojom::MediaHistoryOriginRowPtr>)>
callback);
// Returns all the rows in the playback table. This is only used for
// debugging because it loads all rows in the table.
void GetMediaHistoryPlaybackRowsForDebug(
base::OnceCallback<void(std::vector<mojom::MediaHistoryPlaybackRowPtr>)>
callback);
// Gets the playback sessions from the media history store. The results will
// be ordered by most recent first and be limited to the first |num_sessions|.
// For each session it calls |filter| and if that returns |true| then that
// session will be included in the results.
using GetPlaybackSessionsFilter =
base::RepeatingCallback<bool(const base::TimeDelta& duration,
const base::TimeDelta& position)>;
void GetPlaybackSessions(
base::Optional<unsigned int> num_sessions,
base::Optional<GetPlaybackSessionsFilter> filter,
base::OnceCallback<void(
std::vector<mojom::MediaHistoryPlaybackSessionRowPtr>)> callback);
// Saves a playback session in the media history store.
void SavePlaybackSession(
const GURL& url,
const media_session::MediaMetadata& metadata,
const base::Optional<media_session::MediaPosition>& position,
const std::vector<media_session::MediaImage>& artwork);
// Saves a newly discovered media feed in the media history store.
void SaveMediaFeed(const GURL& url);
protected:
friend class MediaHistoryKeyedServiceTest;
void GetURLsInTableForTest(const std::string& table,
base::OnceCallback<void(std::set<GURL>)> callback);
private:
std::unique_ptr<MediaHistoryStore> media_history_store_;
......
......@@ -114,7 +114,7 @@ class MediaHistoryKeyedServiceTest : public ChromeRenderViewHostTestHarness {
base::RunLoop run_loop;
mojom::MediaHistoryStatsPtr stats_out;
service()->GetMediaHistoryStore()->GetMediaHistoryStats(base::BindOnce(
service()->GetMediaHistoryStats(base::BindOnce(
[](mojom::MediaHistoryStatsPtr* stats_out,
base::RepeatingClosure callback, mojom::MediaHistoryStatsPtr stats) {
stats_out->Swap(&stats);
......@@ -130,7 +130,7 @@ class MediaHistoryKeyedServiceTest : public ChromeRenderViewHostTestHarness {
base::RunLoop run_loop;
std::set<GURL> out;
service()->GetMediaHistoryStore()->GetURLsInTableForTest(
service()->GetURLsInTableForTest(
table, base::BindLambdaForTesting([&](std::set<GURL> urls) {
out = urls;
run_loop.Quit();
......@@ -176,7 +176,7 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenHistoryIsDeleted) {
base::TimeDelta::FromMilliseconds(321), true, false);
history->AddPage(url, base::Time::Now(), history::SOURCE_BROWSED);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
// Wait until the playbacks have finished saving.
content::RunAllTasksUntilIdle();
......@@ -253,10 +253,10 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) {
base::TimeDelta::FromMilliseconds(321), true, false);
history->AddPage(url1a, base::Time::Now(), history::SOURCE_BROWSED);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
service()->GetMediaHistoryStore()->SavePlaybackSession(
url1a, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url1a, media_session::MediaMetadata(),
base::nullopt,
CreateImageVector(url1a_image));
}
......@@ -267,10 +267,10 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) {
base::TimeDelta::FromMilliseconds(321), true, false);
history->AddPage(url1b, base::Time::Now(), history::SOURCE_BROWSED);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
service()->GetMediaHistoryStore()->SavePlaybackSession(
url1b, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url1b, media_session::MediaMetadata(),
base::nullopt,
CreateImageVector(url1b_image));
}
......@@ -281,10 +281,10 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) {
content::MediaPlayerWatchTime watch_time(
url1c, url1c.GetOrigin(), base::TimeDelta::FromMilliseconds(123),
base::TimeDelta::FromMilliseconds(321), true, false);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
service()->GetMediaHistoryStore()->SavePlaybackSession(
url1c, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url1c, media_session::MediaMetadata(),
base::nullopt,
CreateImageVector(shared_image));
}
......@@ -295,10 +295,10 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) {
base::TimeDelta::FromMilliseconds(321), true, false);
history->AddPage(url2a, base::Time::Now(), history::SOURCE_BROWSED);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
service()->GetMediaHistoryStore()->SavePlaybackSession(
url2a, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url2a, media_session::MediaMetadata(),
base::nullopt,
CreateImageVector(url2a_image));
}
......@@ -309,10 +309,10 @@ TEST_F(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenOriginIsDeleted) {
base::TimeDelta::FromMilliseconds(321), true, false);
history->AddPage(url2b, base::Time::Now(), history::SOURCE_BROWSED);
service()->GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
service()->GetMediaHistoryStore()->SavePlaybackSession(
url2b, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url2b, media_session::MediaMetadata(),
base::nullopt,
CreateImageVector(shared_image));
}
......
......@@ -49,6 +49,13 @@ class MediaHistoryStore {
scoped_refptr<base::UpdateableSequencedTaskRunner> db_task_runner);
~MediaHistoryStore();
using GetPlaybackSessionsFilter =
base::RepeatingCallback<bool(const base::TimeDelta& duration,
const base::TimeDelta& position)>;
protected:
friend class MediaHistoryKeyedService;
// Saves a playback from a single player in the media history store.
void SavePlayback(const content::MediaPlayerWatchTime& watch_time);
......@@ -71,9 +78,6 @@ class MediaHistoryStore {
// be ordered by most recent first and be limited to the first |num_sessions|.
// For each session it calls |filter| and if that returns |true| then that
// session will be included in the results.
using GetPlaybackSessionsFilter =
base::RepeatingCallback<bool(const base::TimeDelta& duration,
const base::TimeDelta& position)>;
void GetPlaybackSessions(
base::Optional<unsigned int> num_sessions,
base::Optional<GetPlaybackSessionsFilter> filter,
......@@ -92,10 +96,6 @@ class MediaHistoryStore {
scoped_refptr<base::UpdateableSequencedTaskRunner> GetDBTaskRunnerForTest();
protected:
friend class MediaHistoryKeyedService;
friend class MediaHistoryKeyedServiceTest;
void EraseDatabaseAndCreateNew();
void DeleteAllOriginData(const std::set<url::Origin>& origins);
......
......@@ -14,11 +14,16 @@
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/media/history/media_history_feeds_table.h"
#include "chrome/browser/media/history/media_history_images_table.h"
#include "chrome/browser/media/history/media_history_keyed_service.h"
#include "chrome/browser/media/history/media_history_session_images_table.h"
#include "chrome/browser/media/history/media_history_session_table.h"
#include "chrome/test/base/testing_profile.h"
#include "components/history/core/browser/history_database_params.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/test/test_history_database.h"
#include "content/public/browser/media_player_watch_time.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
......@@ -38,6 +43,16 @@ namespace {
// might be equal but it might be close too.
const int kTimeErrorMargin = 10000;
base::FilePath g_temp_history_dir;
std::unique_ptr<KeyedService> BuildTestHistoryService(
content::BrowserContext* context) {
std::unique_ptr<history::HistoryService> service(
new history::HistoryService());
service->Init(history::TestHistoryDatabaseParamsForPath(g_temp_history_dir));
return service;
}
} // namespace
class MediaHistoryStoreUnitTest : public testing::Test {
......@@ -48,13 +63,15 @@ class MediaHistoryStoreUnitTest : public testing::Test {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
TestingProfile::Builder profile_builder;
profile_builder.SetPath(temp_dir_.GetPath());
g_temp_history_dir = temp_dir_.GetPath();
profile_ = profile_builder.Build();
HistoryServiceFactory::GetInstance()->SetTestingFactory(
profile_.get(), base::BindRepeating(&BuildTestHistoryService));
// Set up the media history store.
scoped_refptr<base::UpdateableSequencedTaskRunner> task_runner =
base::ThreadPool::CreateUpdateableSequencedTaskRunner(
{base::MayBlock(), base::WithBaseSyncPrimitives()});
media_history_store_ = std::make_unique<MediaHistoryStore>(
profile_builder.Build().get(), task_runner);
service_ = std::make_unique<MediaHistoryKeyedService>(profile_.get());
// Sleep the thread to allow the media history store to asynchronously
// create the database and tables before proceeding with the tests and
......@@ -67,13 +84,17 @@ class MediaHistoryStoreUnitTest : public testing::Test {
ASSERT_TRUE(db_.Open(db_file));
}
void TearDown() override { content::RunAllTasksUntilIdle(); }
void TearDown() override {
service_->Shutdown();
content::RunAllTasksUntilIdle();
}
mojom::MediaHistoryStatsPtr GetStatsSync() {
base::RunLoop run_loop;
mojom::MediaHistoryStatsPtr stats_out;
GetMediaHistoryStore()->GetMediaHistoryStats(
service()->GetMediaHistoryStats(
base::BindLambdaForTesting([&](mojom::MediaHistoryStatsPtr stats) {
stats_out = std::move(stats);
run_loop.Quit();
......@@ -87,7 +108,7 @@ class MediaHistoryStoreUnitTest : public testing::Test {
base::RunLoop run_loop;
std::vector<mojom::MediaHistoryOriginRowPtr> out;
GetMediaHistoryStore()->GetOriginRowsForDebug(base::BindLambdaForTesting(
service()->GetOriginRowsForDebug(base::BindLambdaForTesting(
[&](std::vector<mojom::MediaHistoryOriginRowPtr> rows) {
out = std::move(rows);
run_loop.Quit();
......@@ -101,8 +122,7 @@ class MediaHistoryStoreUnitTest : public testing::Test {
base::RunLoop run_loop;
std::vector<mojom::MediaHistoryPlaybackRowPtr> out;
GetMediaHistoryStore()->GetMediaHistoryPlaybackRowsForDebug(
base::BindLambdaForTesting(
service()->GetMediaHistoryPlaybackRowsForDebug(base::BindLambdaForTesting(
[&](std::vector<mojom::MediaHistoryPlaybackRowPtr> rows) {
out = std::move(rows);
run_loop.Quit();
......@@ -112,9 +132,7 @@ class MediaHistoryStoreUnitTest : public testing::Test {
return out;
}
MediaHistoryStore* GetMediaHistoryStore() {
return media_history_store_.get();
}
MediaHistoryKeyedService* service() const { return service_.get(); }
private:
base::ScopedTempDir temp_dir_;
......@@ -125,7 +143,8 @@ class MediaHistoryStoreUnitTest : public testing::Test {
private:
sql::Database db_;
std::unique_ptr<MediaHistoryStore> media_history_store_;
std::unique_ptr<MediaHistoryKeyedService> service_;
std::unique_ptr<TestingProfile> profile_;
};
TEST_F(MediaHistoryStoreUnitTest, CreateDatabaseTables) {
......@@ -146,11 +165,11 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback) {
content::MediaPlayerWatchTime watch_time(url, url.GetOrigin(),
base::TimeDelta::FromSeconds(60),
base::TimeDelta(), true, false);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
const auto now_after_a = base::Time::Now().ToJsTime();
// Save the watch time a second time.
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
// Wait until the playbacks have finished saving.
content::RunAllTasksUntilIdle();
......@@ -203,7 +222,7 @@ TEST_F(MediaHistoryStoreUnitTest, GetStats) {
content::MediaPlayerWatchTime watch_time(
url, url.GetOrigin(), base::TimeDelta::FromMilliseconds(123),
base::TimeDelta::FromMilliseconds(321), true, false);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
}
{
......@@ -229,11 +248,11 @@ TEST_F(MediaHistoryStoreUnitTest, UrlShouldBeUniqueForSessions) {
}
// Save a couple of sessions on different URLs.
GetMediaHistoryStore()->SavePlaybackSession(
url_a, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url_a, media_session::MediaMetadata(),
base::nullopt,
std::vector<media_session::MediaImage>());
GetMediaHistoryStore()->SavePlaybackSession(
url_b, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url_b, media_session::MediaMetadata(),
base::nullopt,
std::vector<media_session::MediaImage>());
// Wait until the sessions have finished saving.
......@@ -251,8 +270,8 @@ TEST_F(MediaHistoryStoreUnitTest, UrlShouldBeUniqueForSessions) {
}
// Save a session on the first URL.
GetMediaHistoryStore()->SavePlaybackSession(
url_a, media_session::MediaMetadata(), base::nullopt,
service()->SavePlaybackSession(url_a, media_session::MediaMetadata(),
base::nullopt,
std::vector<media_session::MediaImage>());
// Wait until the sessions have finished saving.
......@@ -282,7 +301,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
content::MediaPlayerWatchTime watch_time(
url, url.GetOrigin(), base::TimeDelta::FromSeconds(30),
base::TimeDelta(), true /* has_video */, true /* has_audio */);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
content::RunAllTasksUntilIdle();
}
......@@ -291,7 +310,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
content::MediaPlayerWatchTime watch_time(
url, url.GetOrigin(), base::TimeDelta::FromSeconds(60),
base::TimeDelta(), true /* has_video */, true /* has_audio */);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
content::RunAllTasksUntilIdle();
}
......@@ -300,7 +319,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
content::MediaPlayerWatchTime watch_time(
url, url.GetOrigin(), base::TimeDelta::FromSeconds(30),
base::TimeDelta(), false /* has_video */, true /* has_audio */);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
content::RunAllTasksUntilIdle();
}
......@@ -309,7 +328,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
content::MediaPlayerWatchTime watch_time(
url, url.GetOrigin(), base::TimeDelta::FromSeconds(30),
base::TimeDelta(), true /* has_video */, false /* has_audio */);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
content::RunAllTasksUntilIdle();
}
......@@ -320,7 +339,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
content::MediaPlayerWatchTime watch_time(
url_alt, url_alt.GetOrigin(), base::TimeDelta::FromSeconds(30),
base::TimeDelta(), true /* has_video */, true /* has_audio */);
GetMediaHistoryStore()->SavePlayback(watch_time);
service()->SavePlayback(watch_time);
content::RunAllTasksUntilIdle();
}
......@@ -355,7 +374,7 @@ TEST_F(MediaHistoryStoreUnitTest, SavePlayback_IncrementAggregateWatchtime) {
}
TEST_F(MediaHistoryStoreUnitTest, SaveMediaFeed_Noop) {
GetMediaHistoryStore()->SaveMediaFeed(GURL("https://www.google.com/feed"));
service()->SaveMediaFeed(GURL("https://www.google.com/feed"));
content::RunAllTasksUntilIdle();
{
......@@ -387,8 +406,8 @@ TEST_F(MediaHistoryStoreFeedsTest, SaveMediaFeed) {
GURL url_b("https://www.google.co.uk/feed");
GURL url_c("https://www.google.com/feed2");
GetMediaHistoryStore()->SaveMediaFeed(url_a);
GetMediaHistoryStore()->SaveMediaFeed(url_b);
service()->SaveMediaFeed(url_a);
service()->SaveMediaFeed(url_b);
content::RunAllTasksUntilIdle();
{
......@@ -397,7 +416,7 @@ TEST_F(MediaHistoryStoreFeedsTest, SaveMediaFeed) {
EXPECT_EQ(2, stats->table_row_counts[MediaHistoryFeedsTable::kTableName]);
}
GetMediaHistoryStore()->SaveMediaFeed(url_c);
service()->SaveMediaFeed(url_c);
content::RunAllTasksUntilIdle();
{
......
......@@ -49,33 +49,33 @@ void MediaHistoryUI::BindInterface(
void MediaHistoryUI::GetMediaHistoryStats(
GetMediaHistoryStatsCallback callback) {
return GetMediaHistoryStore()->GetMediaHistoryStats(std::move(callback));
return GetMediaHistoryService()->GetMediaHistoryStats(std::move(callback));
}
void MediaHistoryUI::GetMediaHistoryOriginRows(
GetMediaHistoryOriginRowsCallback callback) {
return GetMediaHistoryStore()->GetOriginRowsForDebug(std::move(callback));
return GetMediaHistoryService()->GetOriginRowsForDebug(std::move(callback));
}
void MediaHistoryUI::GetMediaHistoryPlaybackRows(
GetMediaHistoryPlaybackRowsCallback callback) {
return GetMediaHistoryStore()->GetMediaHistoryPlaybackRowsForDebug(
return GetMediaHistoryService()->GetMediaHistoryPlaybackRowsForDebug(
std::move(callback));
}
void MediaHistoryUI::GetMediaHistoryPlaybackSessionRows(
GetMediaHistoryPlaybackSessionRowsCallback callback) {
return GetMediaHistoryStore()->GetPlaybackSessions(
return GetMediaHistoryService()->GetPlaybackSessions(
base::nullopt, base::nullopt, std::move(callback));
}
media_history::MediaHistoryStore* MediaHistoryUI::GetMediaHistoryStore() {
media_history::MediaHistoryKeyedService*
MediaHistoryUI::GetMediaHistoryService() {
Profile* profile = Profile::FromWebUI(web_ui());
DCHECK(profile);
media_history::MediaHistoryKeyedService* service =
media_history::MediaHistoryKeyedServiceFactory::GetForProfile(profile);
DCHECK(service);
return service->GetMediaHistoryStore();
return service;
}
......@@ -11,7 +11,7 @@
#include "ui/webui/mojo_web_ui_controller.h"
namespace media_history {
class MediaHistoryStore;
class MediaHistoryKeyedService;
} // namespace media_history
// The UI for chrome://media-history.
......@@ -38,7 +38,7 @@ class MediaHistoryUI : public ui::MojoWebUIController,
GetMediaHistoryPlaybackSessionRowsCallback callback) override;
private:
media_history::MediaHistoryStore* GetMediaHistoryStore();
media_history::MediaHistoryKeyedService* GetMediaHistoryService();
mojo::ReceiverSet<media_history::mojom::MediaHistoryStore> receivers_;
......
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