[WIP] refactor: (Part I) make the ownership of URLRequestContextGetter more clear (#13956)

* refactor: desttroy URLRequestContextGetter on IO thread

* Accepts a factory class that can customize the creation of URLRequestContext
* Use a separate request context for media which is derived from the default
* Notify URLRequestContextGetter observers and cleanup on IO thread
* Move most of brightray net/ classes into atom net/

* refactor: remove refs to URLRequestContextGetter on shutdown

* refactor: remove brigtray switches.{cc|h}

* refactor: remove brightray network_delegate.{cc|h}

* refactor: make AtomURLRequestJobFactory the top level factory.

* Allows to use the default handler from content/ for http{s}, ws{s} schemes.
* Removes the storage of job factory in URLRequestContextGetter.
This commit is contained in:
Robo 2018-08-14 03:52:45 +05:30 committed by Samuel Attard
parent cb4b3e7be0
commit 1c0bb06d4a
34 changed files with 985 additions and 1121 deletions

View file

@ -24,8 +24,7 @@ class SpecialStoragePolicy;
namespace brightray {
class BrowserContext : public base::RefCounted<BrowserContext>,
public content::BrowserContext,
public brightray::URLRequestContextGetter::Delegate {
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.
@ -67,10 +66,6 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
bool in_memory) override;
std::string GetMediaDeviceIDSalt() override;
URLRequestContextGetter* url_request_context_getter() const {
return url_request_getter_.get();
}
void InitPrefs();
PrefService* prefs() { return prefs_.get(); }
@ -80,15 +75,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;
virtual URLRequestContextGetterFactory* GetFactoryForMainRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) = 0;
base::FilePath GetPath() const override;
private:
friend class base::RefCounted<BrowserContext>;
class ResourceContext;
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
@ -117,11 +111,10 @@ 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_;
URLRequestContextGetter::Handle* io_handle_;
base::WeakPtrFactory<BrowserContext> weak_factory_;