electron/atom/browser/net/url_request_context_getter.h
Electron Bot d008d217f9 chore: bump chromium to 2a7aff41ce73adc0eeee67d364989 (master) (#18505)
* chore: bump chromium in DEPS to 07463d3cd628b037c11f36022cb4c788db4628e3

* chore: update patches

* fix: Don't leak system network context when nw service is disabled

https://chromium-review.googlesource.com/c/chromium/src/+/1632494
NetworkService is now deleted by using SequnceLocalStorageSlot
on the IO thread when the service is disabled, which expects
all associated NetworkContexts on that sequence to be destroyed.

* chore: bump chromium in DEPS to 7c16850e7e40990e141f47101b737ec1092175a1

* fix: Destroy all network contexts before primary network context

* Simplify out-of-process service registration

https://chromium-review.googlesource.com/c/chromium/src/+/1615882

* [ThreadPool] Rename base::ThreadPool to base::ThreadPoolInstance

https://chromium-review.googlesource.com/c/chromium/src/+/1634851

* chore: update patches

* fix: -Winconsistent-missing-override warnings

* chore: bump chromium in DEPS to 93ebfaccc12715df1d5426797998eed0932f7ae1

* Change CreateBrowserMainParts to return unique_ptrs

https://chromium-review.googlesource.com/c/chromium/src/+/1632532

* chore: update patches

* chore: bump chromium in DEPS to e656555ffb87bdd05e248d0a3ef9dd9d3433e17b

* chore: bump chromium in DEPS to 111e7a8d2e3ae9d70e535009d6afb066ac906063

* chore: bump chromium in DEPS to 9b6b84670d32a7aff41ce73adc0eeee67d364989

* chore: update patches

* chore: remove ShouldInterceptResourceAsStream as it is removed upstream

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639597

* chore: remove ResourceDispatcherHostCreated as it is removed upstream

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1610892

* chore: CreateWithStrongBinding --> CreateWithSelfOwnedReceiver

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1636722

* chore: rename all blink media enums

Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639237

* chore: add accidentally removed patch content back
2019-06-03 20:44:12 -07:00

114 lines
3.9 KiB
C++

// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_
#define ATOM_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_
#include <memory>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/network/public/mojom/network_service.mojom.h"
#if DCHECK_IS_ON()
#include "base/debug/leak_tracker.h"
#endif
namespace atom {
class AtomBrowserContext;
class AtomNetworkDelegate;
class AtomURLRequestJobFactory;
class RequireCTDelegate;
class ResourceContext;
class URLRequestContextGetter : public net::URLRequestContextGetter {
public:
// net::URLRequestContextGetter:
net::URLRequestContext* GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
const override;
// Discard reference to URLRequestContext and inform observers to
// shutdown. Must be called only on IO thread.
void NotifyContextShuttingDown();
AtomURLRequestJobFactory* job_factory() const {
return top_job_factory_.get();
}
AtomNetworkDelegate* network_delegate() const { return network_delegate_; }
private:
friend class AtomBrowserContext;
// Responsible for destroying URLRequestContextGetter
// on the IO thread.
class Handle {
public:
explicit Handle(base::WeakPtr<AtomBrowserContext> browser_context);
~Handle();
scoped_refptr<URLRequestContextGetter> CreateMainRequestContextGetter(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector protocol_interceptors);
content::ResourceContext* GetResourceContext();
scoped_refptr<URLRequestContextGetter> GetMainRequestContextGetter();
network::mojom::NetworkContextPtr GetNetworkContext();
network::mojom::NetworkContextParamsPtr CreateNetworkContextParams();
void ShutdownOnUIThread();
private:
friend class URLRequestContextGetter;
void LazyInitialize();
scoped_refptr<URLRequestContextGetter> main_request_context_getter_;
std::unique_ptr<content::ResourceContext> resource_context_;
base::WeakPtr<AtomBrowserContext> browser_context_;
// This is a NetworkContext interface that uses URLRequestContextGetter
// NetworkContext, ownership is passed to StoragePartition when
// CreateMainNetworkContext is called.
network::mojom::NetworkContextPtr main_network_context_;
// Request corresponding to |main_network_context_|. Ownership
// is passed to network service.
network::mojom::NetworkContextRequest main_network_context_request_;
network::mojom::NetworkContextParamsPtr main_network_context_params_;
bool initialized_;
DISALLOW_COPY_AND_ASSIGN(Handle);
};
URLRequestContextGetter(
URLRequestContextGetter::Handle* context_handle,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector protocol_interceptors);
~URLRequestContextGetter() override;
#if DCHECK_IS_ON()
base::debug::LeakTracker<URLRequestContextGetter> leak_tracker_;
#endif
std::unique_ptr<RequireCTDelegate> ct_delegate_;
std::unique_ptr<AtomURLRequestJobFactory> top_job_factory_;
std::unique_ptr<network::mojom::NetworkContext> network_context_;
URLRequestContextGetter::Handle* context_handle_;
net::URLRequestContext* url_request_context_;
AtomNetworkDelegate* network_delegate_;
content::ProtocolHandlerMap protocol_handlers_;
content::URLRequestInterceptorScopedVector protocol_interceptors_;
bool context_shutting_down_;
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
};
} // namespace atom
#endif // ATOM_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_