fix: notify request context shutdown on IO before cleanup (#14058)
This commit is contained in:
parent
8c21762bee
commit
9989195f19
22 changed files with 504 additions and 387 deletions
|
@ -23,9 +23,15 @@ class SpecialStoragePolicy;
|
|||
|
||||
namespace brightray {
|
||||
|
||||
class BrowserContext : public base::RefCounted<BrowserContext>,
|
||||
public content::BrowserContext,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
class BrowserContext;
|
||||
|
||||
struct BrowserContextDeleter {
|
||||
static void Destruct(const BrowserContext* browser_context);
|
||||
};
|
||||
|
||||
class BrowserContext
|
||||
: public base::RefCountedThreadSafe<BrowserContext, BrowserContextDeleter>,
|
||||
public content::BrowserContext {
|
||||
public:
|
||||
// Get the BrowserContext according to its |partition| and |in_memory|,
|
||||
// empty pointer when be returned when there is no matching BrowserContext.
|
||||
|
@ -66,14 +72,14 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
|
|||
const base::FilePath& partition_path,
|
||||
bool in_memory) override;
|
||||
std::string GetMediaDeviceIDSalt() override;
|
||||
|
||||
URLRequestContextGetter* url_request_context_getter() const {
|
||||
return url_request_getter_.get();
|
||||
}
|
||||
base::FilePath GetPath() const override;
|
||||
|
||||
void InitPrefs();
|
||||
PrefService* prefs() { return prefs_.get(); }
|
||||
|
||||
virtual std::string GetUserAgent() const = 0;
|
||||
virtual void OnMainRequestContextCreated(URLRequestContextGetter* getter) {}
|
||||
|
||||
protected:
|
||||
BrowserContext(const std::string& partition, bool in_memory);
|
||||
~BrowserContext() override;
|
||||
|
@ -81,16 +87,14 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
|
|||
// Subclasses should override this to register custom preferences.
|
||||
virtual void RegisterPrefs(PrefRegistrySimple* pref_registry) {}
|
||||
|
||||
// URLRequestContextGetter::Delegate:
|
||||
std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate() override;
|
||||
|
||||
base::FilePath GetPath() const override;
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<BrowserContext>;
|
||||
class ResourceContext;
|
||||
friend class base::RefCountedThreadSafe<BrowserContext,
|
||||
BrowserContextDeleter>;
|
||||
friend class base::DeleteHelper<BrowserContext>;
|
||||
friend struct BrowserContextDeleter;
|
||||
|
||||
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||
void OnDestruct() const;
|
||||
|
||||
// partition_id => browser_context
|
||||
struct PartitionKey {
|
||||
|
@ -117,11 +121,12 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
|
|||
base::FilePath path_;
|
||||
bool in_memory_;
|
||||
|
||||
std::unique_ptr<ResourceContext> resource_context_;
|
||||
scoped_refptr<URLRequestContextGetter> url_request_getter_;
|
||||
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
|
||||
std::unique_ptr<PrefService> prefs_;
|
||||
std::unique_ptr<MediaDeviceIDSalt> media_device_id_salt_;
|
||||
// Self-destructing class responsible for creating URLRequestContextGetter
|
||||
// on the UI thread and deletes itself on the IO thread.
|
||||
URLRequestContextGetter::Handle* io_handle_;
|
||||
|
||||
base::WeakPtrFactory<BrowserContext> weak_factory_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue