0

Deduplicate BrowserContext's ResourceContext

This seems to be an empty class meant to be removed at some point.
Today, this is only a class supporting `SupportsUserData`.

I observed every content/ embedder was required to provide one, and none
of them was really providing some kind of customization.

This patch merge all the different embedders implementations into
the content/ implementation. This has the
side effect of helping linnan@chromium.org to remove a dangling pointer.
This is an alternative to her patch from:
https://chromium-review.googlesource.com/c/chromium/src/+/5132493

Bug: chromium:1471070, chromium:908955
Change-Id: I4938957822d0a77be642aef3098faaa87616295f
Fixed: 1471070
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5139789
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: John Abd-El-Malek <jam@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1240500}
This commit is contained in:
Arthur Sonzogni
2023-12-22 10:05:45 +00:00
committed by Chromium LUCI CQ
parent b5167ecde3
commit ff8375879e
29 changed files with 33 additions and 179 deletions

@ -70,7 +70,6 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_request_utils.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
@ -413,13 +412,6 @@ bool AwBrowserContext::IsOffTheRecord() {
return false;
}
content::ResourceContext* AwBrowserContext::GetResourceContext() {
if (!resource_context_) {
resource_context_ = std::make_unique<content::ResourceContext>();
}
return resource_context_.get();
}
content::DownloadManagerDelegate*
AwBrowserContext::GetDownloadManagerDelegate() {
if (!GetUserData(kDownloadManagerDelegateKey)) {

@ -38,7 +38,6 @@ class AutocompleteHistoryManager;
namespace content {
class ClientHintsControllerDelegate;
class ResourceContext;
class SSLHostStateDelegate;
class WebContents;
}
@ -118,7 +117,6 @@ class AwBrowserContext : public content::BrowserContext,
// content::BrowserContext implementation.
base::FilePath GetPath() override;
bool IsOffTheRecord() override;
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
@ -194,7 +192,6 @@ class AwBrowserContext : public content::BrowserContext,
autocomplete_history_manager_;
std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_writer_;
std::unique_ptr<content::ResourceContext> resource_context_;
std::unique_ptr<PrefService> user_pref_service_;
std::unique_ptr<AwSSLHostStateDelegate> ssl_host_state_delegate_;

@ -37,10 +37,6 @@
#include "net/cert/nss_cert_database.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class ResourceContext;
}
namespace policy {
namespace {

@ -39,7 +39,6 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
@ -226,8 +225,7 @@ std::string Profile::OTRProfileID::Serialize() const {
}
#endif // BUILDFLAG(IS_ANDROID)
Profile::Profile()
: resource_context_(std::make_unique<content::ResourceContext>()) {
Profile::Profile() {
#if DCHECK_IS_ON()
base::AutoLock lock(g_profile_instances_lock.Get());
g_profile_instances.Get().insert(this);
@ -237,10 +235,6 @@ Profile::Profile()
}
Profile::~Profile() {
if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::IO)) {
content::GetIOThreadTaskRunner({})->DeleteSoon(
FROM_HERE, std::move(resource_context_));
}
#if DCHECK_IS_ON()
base::AutoLock lock(g_profile_instances_lock.Get());
g_profile_instances.Get().erase(this);
@ -567,10 +561,6 @@ variations::VariationsClient* Profile::GetVariationsClient() {
return chrome_variations_client_.get();
}
content::ResourceContext* Profile::GetResourceContext() {
return resource_context_.get();
}
base::WeakPtr<const Profile> Profile::GetWeakPtr() const {
return weak_factory_.GetWeakPtr();
}

@ -43,7 +43,6 @@ class Time;
}
namespace content {
class ResourceContext;
class WebUI;
}
@ -241,8 +240,6 @@ class Profile : public content::BrowserContext {
variations::VariationsClient* GetVariationsClient() override;
content::ResourceContext* GetResourceContext() override;
// Returns the creation time of this profile. This will either be the creation
// time of the profile directory or, for ephemeral off-the-record profiles,
// the creation time of the profile object instance.
@ -543,12 +540,6 @@ class Profile : public content::BrowserContext {
virtual bool IsSignedIn() = 0;
private:
// Created on the UI thread, and returned by GetResourceContext(), but
// otherwise lives on and is destroyed on the IO thread.
//
// TODO(https://crbug.com/908955): Get rid of ResourceContext.
std::unique_ptr<content::ResourceContext> resource_context_;
bool restored_last_session_ = false;
// Used to prevent the notification that this Profile is destroyed from

@ -831,19 +831,6 @@ TestingProfile::GetURLLoaderFactory() {
return url_loader_factory_;
}
content::ResourceContext* TestingProfile::GetResourceContext() {
// TODO(arthursonzogni): This should only be called on the IO thread. Consider
// adding a DCHECK_CURRENTLY_ON(content::BrowserThread::IO) after fixing the
// non compliant tests: SpellingMenuObserverTest.SuggestionsForceTopSeparator
if (!resource_context_) {
resource_context_ =
std::unique_ptr<content::ResourceContext,
content::BrowserThread::DeleteOnIOThread>(
new content::ResourceContext);
}
return resource_context_.get();
}
content::BrowserPluginGuestManager* TestingProfile::GetGuestManager() {
#if BUILDFLAG(ENABLE_EXTENSIONS)
return guest_view::GuestViewManager::FromBrowserContext(this);

@ -43,7 +43,6 @@ class HostContentSettingsMap;
class TestingPrefStore;
namespace content {
class ResourceContext;
class SSLHostStateDelegate;
class ZoomLevelDelegate;
} // namespace content
@ -334,7 +333,6 @@ class TestingProfile : public Profile {
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
const OTRProfileID& GetOTRProfileID() const override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::ResourceContext* GetResourceContext() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PlatformNotificationService* GetPlatformNotificationService()
@ -522,11 +520,6 @@ class TestingProfile : public Profile {
raw_ptr<BrowserContextDependencyManager> browser_context_dependency_manager_{
BrowserContextDependencyManager::GetInstance()};
// Live on the IO thread:
std::unique_ptr<content::ResourceContext,
content::BrowserThread::DeleteOnIOThread>
resource_context_;
std::unique_ptr<policy::SchemaRegistryService> schema_registry_service_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<policy::UserCloudPolicyManagerAsh> user_cloud_policy_manager_;

@ -18,7 +18,6 @@
#include "components/profile_metrics/browser_profile_type.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
@ -29,8 +28,7 @@ namespace {
const void* const kDownloadManagerDelegateKey = &kDownloadManagerDelegateKey;
} // namespace
CastBrowserContext::CastBrowserContext()
: resource_context_(new content::ResourceContext()) {
CastBrowserContext::CastBrowserContext() {
profile_metrics::SetBrowserProfileType(
this, profile_metrics::BrowserProfileType::kRegular);
InitWhileIOAllowed();
@ -43,8 +41,6 @@ CastBrowserContext::~CastBrowserContext() {
SimpleKeyMap::GetInstance()->Dissociate(this);
NotifyWillBeDestroyed();
ShutdownStoragePartitions();
content::GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE,
resource_context_.release());
}
void CastBrowserContext::InitWhileIOAllowed() {
@ -77,10 +73,6 @@ bool CastBrowserContext::IsOffTheRecord() {
return false;
}
content::ResourceContext* CastBrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::DownloadManagerDelegate*
CastBrowserContext::GetDownloadManagerDelegate() {
if (!GetUserData(kDownloadManagerDelegateKey)) {

@ -10,7 +10,6 @@
#include "base/files/file_path.h"
#include "components/keyed_service/core/simple_factory_key.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_context.h"
namespace chromecast {
namespace shell {
@ -32,7 +31,6 @@ class CastBrowserContext final : public content::BrowserContext {
const base::FilePath& partition_path) override;
base::FilePath GetPath() override;
bool IsOffTheRecord() override;
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
@ -58,7 +56,6 @@ class CastBrowserContext final : public content::BrowserContext {
void InitWhileIOAllowed();
base::FilePath path_;
std::unique_ptr<content::ResourceContext> resource_context_;
std::unique_ptr<content::PermissionControllerDelegate> permission_manager_;
std::unique_ptr<SimpleFactoryKey> simple_factory_key_;
};

@ -322,6 +322,10 @@ void BrowserContext::WriteIntoTrace(
perfetto::WriteIntoTracedProto(std::move(proto), impl());
}
ResourceContext* BrowserContext::GetResourceContext() const {
return impl()->GetResourceContext();
}
base::WeakPtr<BrowserContext> BrowserContext::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}

@ -105,6 +105,11 @@ BrowserContextImpl::~BrowserContextImpl() {
TtsControllerImpl::GetInstance()->OnBrowserContextDestroyed(self_);
if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) {
GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE,
std::move(resource_context_));
}
TRACE_EVENT_NESTABLE_ASYNC_END1(
"shutdown", "BrowserContextImpl::NotifyWillBeDestroyed() called.", this,
"browser_context_impl", static_cast<void*>(this));

@ -13,6 +13,7 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
namespace media {
@ -106,6 +107,10 @@ class CONTENT_EXPORT BrowserContextImpl {
// Write a representation of this object into a trace.
void WriteIntoTrace(perfetto::TracedProto<TraceProto> context) const;
ResourceContext* GetResourceContext() const {
return resource_context_.get();
}
private:
// Creates the media service for storing/retrieving WebRTC encoding and
// decoding performance stats. Exposed here rather than StoragePartition
@ -139,6 +144,12 @@ class CONTENT_EXPORT BrowserContextImpl {
std::unique_ptr<media::VideoDecodePerfHistory> video_decode_perf_history_;
std::unique_ptr<media::WebrtcVideoPerfHistory> webrtc_video_perf_history_;
// TODO(https://crbug.com/908955): Get rid of ResourceContext.
// Created on the UI thread, otherwise lives on and is destroyed on the IO
// thread.
std::unique_ptr<ResourceContext> resource_context_ =
std::make_unique<ResourceContext>();
#if BUILDFLAG(IS_CHROMEOS_ASH)
scoped_refptr<storage::ExternalMountPoints> external_mount_points_;
#endif

@ -679,8 +679,8 @@ class CONTENT_EXPORT ChildProcessSecurityPolicyImpl
// applies. |browser_context_| may be used on the UI thread, and
// |resource_context_| may be used on the IO thread. If these are null,
// then the isolated origin applies globally to all profiles.
raw_ptr<BrowserContext, DanglingUntriaged> browser_context_;
raw_ptr<ResourceContext, AcrossTasksDanglingUntriaged> resource_context_;
raw_ptr<BrowserContext> browser_context_;
raw_ptr<ResourceContext> resource_context_;
// True if origins at this or lower level should be treated as distinct
// isolated origins, effectively isolating all domains below a given domain,

@ -311,6 +311,10 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// to the declaration of ChromeBrowserContext proto.
void WriteIntoTrace(perfetto::TracedProto<TraceProto> context) const;
// Deprecated. Do not add new callers.
// TODO(https://crbug.com/908955): Get rid of ResourceContext.
ResourceContext* GetResourceContext() const;
base::WeakPtr<BrowserContext> GetWeakPtr();
//////////////////////////////////////////////////////////////////////////////
@ -337,9 +341,6 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// also off the record.
virtual bool IsOffTheRecord() = 0;
// Returns the resource context.
virtual ResourceContext* GetResourceContext() = 0;
// Returns the DownloadManagerDelegate for this context. This will be called
// once per context. The embedder owns the delegate and is responsible for
// ensuring that it outlives DownloadManager. Note in particular that it is

@ -14,7 +14,7 @@ namespace content {
// ResourceContext contains the relevant context information required for
// resource loading. It lives on the IO thread, although it is constructed on
// the UI thread. It must be destructed on the IO thread.
// TODO(mmenke): Get rid of this class.
// TODO(https://crbug.com/908955): Get rid of this class.
class CONTENT_EXPORT ResourceContext : public base::SupportsUserData {
public:
ResourceContext();

@ -103,12 +103,6 @@ DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
return nullptr;
}
ResourceContext* TestBrowserContext::GetResourceContext() {
if (!resource_context_)
resource_context_ = std::make_unique<content::ResourceContext>();
return resource_context_.get();
}
BrowserPluginGuestManager* TestBrowserContext::GetGuestManager() {
return nullptr;
}

@ -17,7 +17,6 @@ namespace content {
class MockBackgroundSyncController;
class MockReduceAcceptLanguageControllerDelegate;
class MockSSLHostStateDelegate;
class ResourceContext;
class ZoomLevelDelegate;
class TestBrowserContext : public BrowserContext {
@ -59,7 +58,6 @@ class TestBrowserContext : public BrowserContext {
const base::FilePath& partition_path) override;
bool IsOffTheRecord() override;
DownloadManagerDelegate* GetDownloadManagerDelegate() override;
ResourceContext* GetResourceContext() override;
BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
PlatformNotificationService* GetPlatformNotificationService() override;
@ -79,7 +77,6 @@ class TestBrowserContext : public BrowserContext {
private:
// Hold a reference here because BrowserContext owns lifetime.
base::ScopedTempDir browser_context_dir_;
std::unique_ptr<content::ResourceContext> resource_context_;
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
std::unique_ptr<MockSSLHostStateDelegate> ssl_host_state_delegate_;
std::unique_ptr<PermissionControllerDelegate> permission_controller_delegate_;

@ -41,15 +41,9 @@
namespace content {
ShellBrowserContext::ShellResourceContext::ShellResourceContext() {}
ShellBrowserContext::ShellResourceContext::~ShellResourceContext() {
}
ShellBrowserContext::ShellBrowserContext(bool off_the_record,
bool delay_services_creation)
: resource_context_(std::make_unique<ShellResourceContext>()),
off_the_record_(off_the_record) {
: off_the_record_(off_the_record) {
InitWhileIOAllowed();
#if BUILDFLAG(IS_WIN)
base::SetExtraNoExecuteAllowedPath(SHELL_DIR_USER_DATA);
@ -74,14 +68,6 @@ ShellBrowserContext::~ShellBrowserContext() {
SimpleKeyMap::GetInstance()->Dissociate(this);
// Need to destruct the ResourceContext before posting tasks which may delete
// the URLRequestContext because ResourceContext's destructor will remove any
// outstanding request while URLRequestContext's destructor ensures that there
// are no more outstanding requests.
if (resource_context_) {
GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE,
resource_context_.release());
}
ShutdownStoragePartitions();
}
@ -140,10 +126,6 @@ DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() {
return download_manager_delegate_.get();
}
ResourceContext* ShellBrowserContext::GetResourceContext() {
return resource_context_.get();
}
BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() {
return nullptr;
}

@ -10,7 +10,6 @@
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_context.h"
class SimpleFactoryKey;
@ -50,7 +49,6 @@ class ShellBrowserContext : public BrowserContext {
const base::FilePath& partition_path) override;
bool IsOffTheRecord() override;
DownloadManagerDelegate* GetDownloadManagerDelegate() override;
ResourceContext* GetResourceContext() override;
BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
PlatformNotificationService* GetPlatformNotificationService() override;
@ -76,20 +74,8 @@ class ShellBrowserContext : public BrowserContext {
ShellFederatedPermissionContext* GetShellFederatedPermissionContext();
protected:
// Contains URLRequestContextGetter required for resource loading.
class ShellResourceContext : public ResourceContext {
public:
ShellResourceContext();
ShellResourceContext(const ShellResourceContext&) = delete;
ShellResourceContext& operator=(const ShellResourceContext&) = delete;
~ShellResourceContext() override;
};
bool ignore_certificate_errors() const { return ignore_certificate_errors_; }
std::unique_ptr<ShellResourceContext> resource_context_;
std::unique_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<PermissionControllerDelegate> permission_manager_;
std::unique_ptr<BackgroundSyncController> background_sync_controller_;

@ -22,7 +22,6 @@
#include "components/site_isolation/site_isolation_policy.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
#include "fuchsia_web/webengine/browser/web_engine_net_log_observer.h"
#include "fuchsia_web/webengine/switches.h"
#include "media/capabilities/in_memory_video_decode_stats_db_impl.h"
@ -68,11 +67,6 @@ WebEngineBrowserContext::~WebEngineBrowserContext() {
SimpleKeyMap::GetInstance()->Dissociate(this);
NotifyWillBeDestroyed();
if (resource_context_) {
content::GetIOThreadTaskRunner({})->DeleteSoon(
FROM_HERE, std::move(resource_context_));
}
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
this);
@ -93,10 +87,6 @@ bool WebEngineBrowserContext::IsOffTheRecord() {
return data_dir_path_.empty();
}
content::ResourceContext* WebEngineBrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::DownloadManagerDelegate*
WebEngineBrowserContext::GetDownloadManagerDelegate() {
NOTIMPLEMENTED();
@ -195,7 +185,6 @@ WebEngineBrowserContext::WebEngineBrowserContext(
: data_dir_path_(std::move(data_directory)),
net_log_observer_(CreateNetLogObserver()),
simple_factory_key_(GetPath(), IsOffTheRecord()),
resource_context_(std::make_unique<content::ResourceContext>()),
client_hints_delegate_(network_quality_tracker,
IsJavaScriptAllowedCallback(),
AreThirdPartyCookiesBlockedCallback(),

@ -41,7 +41,6 @@ class WebEngineBrowserContext final : public content::BrowserContext {
const base::FilePath& partition_path) override;
base::FilePath GetPath() override;
bool IsOffTheRecord() override;
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
@ -73,7 +72,6 @@ class WebEngineBrowserContext final : public content::BrowserContext {
const std::unique_ptr<WebEngineNetLogObserver> net_log_observer_;
SimpleFactoryKey simple_factory_key_;
WebEnginePermissionDelegate permission_delegate_;
std::unique_ptr<content::ResourceContext> resource_context_;
client_hints::InMemoryClientHintsControllerDelegate client_hints_delegate_;
};

@ -188,10 +188,6 @@ bool HeadlessBrowserContextImpl::IsOffTheRecord() {
return context_options_->incognito_mode();
}
content::ResourceContext* HeadlessBrowserContextImpl::GetResourceContext() {
return request_context_manager_->GetResourceContext();
}
content::DownloadManagerDelegate*
HeadlessBrowserContextImpl::GetDownloadManagerDelegate() {
return nullptr;

@ -16,7 +16,6 @@
#include "components/keyed_service/core/simple_factory_key.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/resource_context.h"
#include "headless/lib/browser/headless_browser_context_options.h"
#include "headless/lib/browser/headless_request_context_manager.h"
#include "headless/public/headless_browser_context.h"
@ -59,7 +58,6 @@ class HEADLESS_EXPORT HeadlessBrowserContextImpl final
const base::FilePath& partition_path) override;
base::FilePath GetPath() override;
bool IsOffTheRecord() override;
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
::storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;

@ -11,7 +11,6 @@
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/resource_context.h"
#include "headless/lib/browser/headless_browser_context_options.h"
#include "headless/public/switches.h"
#include "mojo/public/cpp/bindings/receiver.h"
@ -223,8 +222,7 @@ HeadlessRequestContextManager::HeadlessRequestContextManager(
proxy_config_(
options->proxy_config()
? std::make_unique<net::ProxyConfig>(*options->proxy_config())
: nullptr),
resource_context_(std::make_unique<content::ResourceContext>()) {
: nullptr) {
if (!proxy_config_) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kNoSystemProxyConfigService)) {

@ -16,10 +16,6 @@
#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom-forward.h"
#include "services/network/public/mojom/network_context.mojom.h"
namespace content {
class ResourceContext;
}
namespace headless {
class HeadlessBrowserContextOptions;
@ -46,10 +42,6 @@ class HeadlessRequestContextManager {
::cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params);
content::ResourceContext* GetResourceContext() {
return resource_context_.get();
}
private:
void ConfigureNetworkContextParamsInternal(
::network::mojom::NetworkContextParams* network_context_params,
@ -66,7 +58,6 @@ class HeadlessRequestContextManager {
std::unique_ptr<HeadlessProxyConfigMonitor> proxy_config_monitor_;
mojo::PendingRemote<::network::mojom::NetworkContext> system_context_;
std::unique_ptr<content::ResourceContext> resource_context_;
};
} // namespace headless

@ -7,7 +7,6 @@
#import "build/blink_buildflags.h"
#import "content/public/browser/browser_context.h"
#import "content/public/browser/resource_context.h"
#import "ios/web/public/browser_state.h"
#if !BUILDFLAG(USE_BLINK)
@ -40,7 +39,6 @@ class ContentBrowserContext : public content::BrowserContext {
const base::FilePath& partition_path) override;
bool IsOffTheRecord() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::ResourceContext* GetResourceContext() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PlatformNotificationService* GetPlatformNotificationService()
@ -78,7 +76,6 @@ class ContentBrowserContext : public content::BrowserContext {
// allowed on the current thread.
void InitWhileIOAllowed();
void FinishInitWhileIOAllowed();
std::unique_ptr<content::ResourceContext> resource_context_;
web::BrowserState* browser_state_ = nullptr;
};

@ -46,8 +46,7 @@ content::BrowserContext* ContentBrowserContext::FromBrowserState(
}
ContentBrowserContext::ContentBrowserContext(web::BrowserState* browser_state)
: resource_context_(std::make_unique<content::ResourceContext>()),
browser_state_(browser_state) {
: browser_state_(browser_state) {
InitWhileIOAllowed();
// This should depend on browser_state_->GetStatePath(), but it is probably
@ -60,15 +59,6 @@ ContentBrowserContext::ContentBrowserContext(web::BrowserState* browser_state)
ContentBrowserContext::~ContentBrowserContext() {
NotifyWillBeDestroyed();
// Need to destruct the ResourceContext before posting tasks which may delete
// the URLRequestContext because ResourceContext's destructor will remove any
// outstanding request while URLRequestContext's destructor ensures that there
// are no more outstanding requests.
if (resource_context_) {
GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE,
resource_context_.release());
}
ShutdownStoragePartitions();
}
@ -96,10 +86,6 @@ ContentBrowserContext::GetDownloadManagerDelegate() {
return nullptr;
}
content::ResourceContext* ContentBrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::BrowserPluginGuestManager* ContentBrowserContext::GetGuestManager() {
return nullptr;
}

@ -5,18 +5,14 @@
#include "ui/webui/examples/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
namespace webui_examples {
BrowserContext::BrowserContext(const base::FilePath& temp_dir_path)
: temp_dir_path_(temp_dir_path),
resource_context_(std::make_unique<content::ResourceContext>()) {}
: temp_dir_path_(temp_dir_path) {}
BrowserContext::~BrowserContext() {
NotifyWillBeDestroyed();
content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE,
resource_context_.release());
ShutdownStoragePartitions();
}
@ -35,10 +31,6 @@ bool BrowserContext::IsOffTheRecord() {
return false;
}
content::ResourceContext* BrowserContext::GetResourceContext() {
return resource_context_.get();
}
content::DownloadManagerDelegate* BrowserContext::GetDownloadManagerDelegate() {
return nullptr;
}

@ -11,10 +11,6 @@
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
namespace content {
class ResourceContext;
}
namespace webui_examples {
class BrowserContext : public content::BrowserContext {
@ -30,7 +26,6 @@ class BrowserContext : public content::BrowserContext {
const base::FilePath& partition_path) override;
base::FilePath GetPath() override;
bool IsOffTheRecord() override;
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
@ -51,7 +46,6 @@ class BrowserContext : public content::BrowserContext {
override;
const base::FilePath temp_dir_path_;
std::unique_ptr<content::ResourceContext> resource_context_;
};
} // namespace webui_examples