Commit a424bb2e authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Add LearningSession to BrowserContext

This CL adds a singleton LearningSession to BrowserContext. This
provides a single location from which to get LearningTaskControllers,
which will allow aggregating observations accross multiple frames.

Bug: 994831
Change-Id: Ibeaf47a09ae7408d0afab9bc113a98e9f1532199
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758625Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688733}
parent 7f85049f
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/capabilities/in_memory_video_decode_stats_db_impl.h" #include "media/capabilities/in_memory_video_decode_stats_db_impl.h"
#include "media/capabilities/video_decode_stats_db_impl.h" #include "media/capabilities/video_decode_stats_db_impl.h"
#include "media/learning/impl/learning_session_impl.h"
#include "media/mojo/services/video_decode_perf_history.h" #include "media/mojo/services/video_decode_perf_history.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
...@@ -173,6 +174,7 @@ const char kServiceManagerConnection[] = "service-manager-connection"; ...@@ -173,6 +174,7 @@ const char kServiceManagerConnection[] = "service-manager-connection";
const char kServiceInstanceGroup[] = "service-instance-group"; const char kServiceInstanceGroup[] = "service-instance-group";
const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; const char kStoragePartitionMapKeyName[] = "content_storage_partition_map";
const char kVideoDecodePerfHistoryId[] = "video-decode-perf-history"; const char kVideoDecodePerfHistoryId[] = "video-decode-perf-history";
const char kLearningSession[] = "learning-session";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
const char kMountPointsKey[] = "mount_points"; const char kMountPointsKey[] = "mount_points";
...@@ -811,6 +813,24 @@ media::VideoDecodePerfHistory* BrowserContext::GetVideoDecodePerfHistory() { ...@@ -811,6 +813,24 @@ media::VideoDecodePerfHistory* BrowserContext::GetVideoDecodePerfHistory() {
return decode_history; return decode_history;
} }
media::learning::LearningSession* BrowserContext::GetLearningSession() {
media::learning::LearningSession* learning_session =
static_cast<media::learning::LearningSession*>(
GetUserData(kLearningSession));
if (!learning_session) {
auto new_learning_session =
std::make_unique<media::learning::LearningSessionImpl>(
base::SequencedTaskRunnerHandle::Get());
learning_session = new_learning_session.get();
SetUserData(kLearningSession, std::move(new_learning_session));
}
return learning_session;
}
download::InProgressDownloadManager* download::InProgressDownloadManager*
BrowserContext::RetriveInProgressDownloadManager() { BrowserContext::RetriveInProgressDownloadManager() {
return nullptr; return nullptr;
......
...@@ -55,6 +55,9 @@ class Origin; ...@@ -55,6 +55,9 @@ class Origin;
namespace media { namespace media {
class VideoDecodePerfHistory; class VideoDecodePerfHistory;
namespace learning {
class LearningSession;
}
} }
namespace storage { namespace storage {
...@@ -334,6 +337,14 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { ...@@ -334,6 +337,14 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// directly, so privacy is not compromised. // directly, so privacy is not compromised.
virtual media::VideoDecodePerfHistory* GetVideoDecodePerfHistory(); virtual media::VideoDecodePerfHistory* GetVideoDecodePerfHistory();
// Returns a LearningSession associated with |this|. Used as the central
// source from which to retrieve LearningTaskControllers for media machine
// learning.
// Exposed here rather than StoragePartition because learnings will cover
// general media trends rather than SiteInstance specific behavior. The
// learnings are not exposed to the web.
virtual media::learning::LearningSession* GetLearningSession();
// Retrieves the InProgressDownloadManager associated with this object if // Retrieves the InProgressDownloadManager associated with this object if
// available // available
virtual download::InProgressDownloadManager* virtual download::InProgressDownloadManager*
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/component_export.h" #include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/supports_user_data.h"
#include "media/learning/common/labelled_example.h" #include "media/learning/common/labelled_example.h"
#include "media/learning/common/learning_task.h" #include "media/learning/common/learning_task.h"
...@@ -19,10 +20,11 @@ namespace learning { ...@@ -19,10 +20,11 @@ namespace learning {
class LearningTaskController; class LearningTaskController;
// Interface to provide a Learner given the task name. // Interface to provide a Learner given the task name.
class COMPONENT_EXPORT(LEARNING_COMMON) LearningSession { class COMPONENT_EXPORT(LEARNING_COMMON) LearningSession
: public base::SupportsUserData::Data {
public: public:
LearningSession(); LearningSession();
virtual ~LearningSession(); ~LearningSession() override;
// Return a LearningTaskController for the given task. // Return a LearningTaskController for the given task.
virtual std::unique_ptr<LearningTaskController> GetController( virtual std::unique_ptr<LearningTaskController> GetController(
......
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