#ifndef CONTENT_BROWSER_BROWSER_CONTEXT_IMPL_H_
#define CONTENT_BROWSER_BROWSER_CONTEXT_IMPL_H_
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
namespace media {
class VideoDecodePerfHistory;
class WebrtcVideoPerfHistory;
namespace learning {
class LearningSession;
class LearningSessionImpl;
}
}
namespace storage {
class ExternalMountPoints;
}
namespace perfetto::protos::pbzero {
class ChromeBrowserContext;
}
namespace content {
class BackgroundSyncScheduler;
class BrowserContextImpl;
class BrowsingDataRemoverImpl;
class DownloadManager;
class NavigationEntryScreenshotManager;
class PermissionController;
class PrefetchService;
class StoragePartitionImplMap;
class CONTENT_EXPORT BrowserContextImpl {
public:
static BrowserContextImpl* From(BrowserContext* self);
~BrowserContextImpl();
BrowserContextImpl(const BrowserContextImpl&) = delete;
BrowserContextImpl& operator=(const BrowserContextImpl&) = delete;
const std::string& UniqueId() const { return unique_id_; }
bool ShutdownStarted();
void NotifyWillBeDestroyed();
StoragePartitionImplMap* GetOrCreateStoragePartitionMap();
StoragePartitionImplMap* storage_partition_map() {
return storage_partition_map_.get();
}
SharedCorsOriginAccessList* shared_cors_origin_access_list() {
return shared_cors_origin_access_list_.get();
}
BrowsingDataRemoverImpl* GetBrowsingDataRemover();
media::learning::LearningSession* GetLearningSession();
storage::ExternalMountPoints* GetMountPoints();
DownloadManager* GetDownloadManager();
void SetDownloadManagerForTesting(
std::unique_ptr<DownloadManager> download_manager);
PermissionController* GetPermissionController();
void SetPermissionControllerForTesting(
std::unique_ptr<PermissionController> permission_controller);
void ShutdownStoragePartitions();
media::VideoDecodePerfHistory* GetVideoDecodePerfHistory();
media::WebrtcVideoPerfHistory* GetWebrtcVideoPerfHistory();
BackgroundSyncScheduler* background_sync_scheduler() {
return background_sync_scheduler_.get();
}
PrefetchService* GetPrefetchService();
void SetPrefetchServiceForTesting(
std::unique_ptr<PrefetchService> prefetch_service);
NavigationEntryScreenshotManager* GetNavigationEntryScreenshotManager();
using TraceProto = perfetto::protos::pbzero::ChromeBrowserContext;
void WriteIntoTrace(perfetto::TracedProto<TraceProto> context) const;
private:
std::unique_ptr<media::WebrtcVideoPerfHistory> CreateWebrtcVideoPerfHistory();
friend BrowserContext;
explicit BrowserContextImpl(BrowserContext* self);
raw_ptr<BrowserContext> self_;
const std::string unique_id_ = base::UnguessableToken::Create().ToString();
bool will_be_destroyed_soon_ = false;
std::unique_ptr<StoragePartitionImplMap> storage_partition_map_;
scoped_refptr<SharedCorsOriginAccessList> shared_cors_origin_access_list_ =
SharedCorsOriginAccessList::Create();
std::unique_ptr<BrowsingDataRemoverImpl> browsing_data_remover_;
std::unique_ptr<DownloadManager> download_manager_;
std::unique_ptr<PermissionController> permission_controller_;
scoped_refptr<BackgroundSyncScheduler> background_sync_scheduler_;
std::unique_ptr<PrefetchService> prefetch_service_;
std::unique_ptr<NavigationEntryScreenshotManager>
nav_entry_screenshot_manager_;
std::unique_ptr<media::learning::LearningSessionImpl> learning_session_;
std::unique_ptr<media::VideoDecodePerfHistory> video_decode_perf_history_;
std::unique_ptr<media::WebrtcVideoPerfHistory> webrtc_video_perf_history_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
scoped_refptr<storage::ExternalMountPoints> external_mount_points_;
#endif
};
}
#endif