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

[Media Feeds] Mark as displayed

Mark a Media Feed and its contents as being displayed
when it is shown in the UI. This will shuffle the
feeds to show new content.

BUG=1053599

Change-Id: Ibf48d01e10a010e07177a54ea2f0b3400b68867f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2309800Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790460}
parent 92b6f65c
......@@ -117,7 +117,9 @@ void KaleidoscopeDataProviderImpl::GetMediaFeedContents(
feed_id, kMediaFeedsItemsMaxCount,
// Require Safe Search checking if the integration is enabled.
base::FeatureList::IsEnabled(media::kMediaFeedsSafeSearch)),
std::move(callback));
base::BindOnce(&KaleidoscopeDataProviderImpl::OnGotMediaFeedContents,
weak_ptr_factory.GetWeakPtr(), std::move(callback),
feed_id));
}
void KaleidoscopeDataProviderImpl::GetContinueWatchingMediaFeedItems(
......@@ -128,7 +130,9 @@ void KaleidoscopeDataProviderImpl::GetContinueWatchingMediaFeedItems(
kMediaFeedsItemsMaxCount,
// Require Safe Search checking if the integration is enabled.
base::FeatureList::IsEnabled(media::kMediaFeedsSafeSearch)),
std::move(callback));
base::BindOnce(
&KaleidoscopeDataProviderImpl::OnGotContinueWatchingMediaFeedItems,
weak_ptr_factory.GetWeakPtr(), std::move(callback)));
}
media_history::MediaHistoryKeyedService*
......@@ -151,3 +155,31 @@ void KaleidoscopeDataProviderImpl::OnAccessTokenAvailable(
pending_callbacks_.clear();
}
void KaleidoscopeDataProviderImpl::OnGotMediaFeedContents(
GetMediaFeedContentsCallback callback,
const int64_t feed_id,
std::vector<media_feeds::mojom::MediaFeedItemPtr> items) {
std::set<int64_t> ids;
for (auto& item : items)
ids.insert(item->id);
// Mark the returned feed and feed items as having been displayed.
GetMediaHistoryService()->UpdateMediaFeedDisplayTime(feed_id);
GetMediaHistoryService()->IncrementMediaFeedItemsShownCount(ids);
std::move(callback).Run(std::move(items));
}
void KaleidoscopeDataProviderImpl::OnGotContinueWatchingMediaFeedItems(
GetContinueWatchingMediaFeedItemsCallback callback,
std::vector<media_feeds::mojom::MediaFeedItemPtr> items) {
std::set<int64_t> ids;
for (auto& item : items)
ids.insert(item->id);
// Mark the returned feed items as having been displayed.
GetMediaHistoryService()->IncrementMediaFeedItemsShownCount(ids);
std::move(callback).Run(std::move(items));
}
......@@ -7,6 +7,7 @@
#include <memory>
#include "base/memory/weak_ptr.h"
#include "chrome/browser/media/kaleidoscope/mojom/kaleidoscope.mojom.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
......@@ -52,6 +53,14 @@ class KaleidoscopeDataProviderImpl
void OnAccessTokenAvailable(GoogleServiceAuthError error,
signin::AccessTokenInfo access_token_info);
void OnGotMediaFeedContents(
GetMediaFeedContentsCallback callback,
const int64_t feed_id,
std::vector<media_feeds::mojom::MediaFeedItemPtr> items);
void OnGotContinueWatchingMediaFeedItems(
GetContinueWatchingMediaFeedItemsCallback callback,
std::vector<media_feeds::mojom::MediaFeedItemPtr> items);
// Helper for fetching OAuth2 access tokens. This is non-null iff an access
// token request is currently in progress.
std::unique_ptr<signin::PrimaryAccountAccessTokenFetcher> token_fetcher_;
......@@ -67,6 +76,8 @@ class KaleidoscopeDataProviderImpl
Profile* const profile_;
mojo::Receiver<media::mojom::KaleidoscopeDataProvider> receiver_;
base::WeakPtrFactory<KaleidoscopeDataProviderImpl> weak_ptr_factory{this};
};
#endif // CHROME_BROWSER_MEDIA_KALEIDOSCOPE_KALEIDOSCOPE_DATA_PROVIDER_IMPL_H_
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